Skip to content
This repository has been archived by the owner on Aug 26, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from adamdecaf/customer-address-approval-and-a…
Browse files Browse the repository at this point in the history
…dditions

Customer address approval and additions
  • Loading branch information
adamdecaf committed Jun 10, 2019
2 parents f832f4a + 7bd2274 commit 27d44df
Show file tree
Hide file tree
Showing 13 changed files with 875 additions and 174 deletions.
1 change: 1 addition & 0 deletions client/README.md
Expand Up @@ -33,6 +33,7 @@ All URIs are relative to *http://localhost:8087*

Class | Method | HTTP request | Description
------------ | ------------- | ------------- | -------------
*CustomersApi* | [**AddCustomerAddress**](docs/CustomersApi.md#addcustomeraddress) | **Post** /customers/{customer_id}/address | Add an Address onto an existing Customer record
*CustomersApi* | [**CreateCustomer**](docs/CustomersApi.md#createcustomer) | **Post** /customers | Create a new customer
*CustomersApi* | [**GetCustomer**](docs/CustomersApi.md#getcustomer) | **Get** /customers/{customer_id} | Retrieves a Customer object associated with the customer ID.
*CustomersApi* | [**GetCustomerDocumentContents**](docs/CustomersApi.md#getcustomerdocumentcontents) | **Get** /customers/{customer_id}/documents/{document_id} | Retrieve the referenced document
Expand Down
61 changes: 61 additions & 0 deletions client/api/openapi.yaml
Expand Up @@ -114,6 +114,60 @@ paths:
summary: Retrieves a Customer object associated with the customer ID.
tags:
- Customers
/customers/{customer_id}/address:
post:
operationId: addCustomerAddress
parameters:
- description: Optional Request ID allows application developer to trace requests
through the systems logs
example: rs4f9915
explode: false
in: header
name: X-Request-Id
required: false
schema:
type: string
style: simple
- description: Moov User ID header, required in all requests
example: e3cdf999
explode: false
in: header
name: X-User-Id
required: false
schema:
type: string
style: simple
- description: Customer Id
explode: false
in: path
name: customer_id
required: true
schema:
example: e210a9d6-d755-4455-9bd2-9577ea7e1081
type: string
style: simple
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/CreateAddress'
required: true
responses:
200:
content:
application/json:
schema:
$ref: '#/components/schemas/Customer'
description: A customer object
400:
content:
application/json:
schema:
$ref: '#/components/schemas/Error'
description: Customer metadata was not updated, see error(s)
summary: Add an Address onto an existing Customer record
tags:
- Customers
/customers/{customer_id}/metadata:
put:
operationId: replaceCustomerMetadata
Expand Down Expand Up @@ -501,6 +555,7 @@ components:
address1: address1
postalCode: postalCode
active: true
id: 851233a1
state: state
type: Primary
- country: US
Expand All @@ -510,6 +565,7 @@ components:
address1: address1
postalCode: postalCode
active: true
id: 851233a1
state: state
type: Primary
metadata:
Expand Down Expand Up @@ -730,9 +786,14 @@ components:
address1: address1
postalCode: postalCode
active: true
id: 851233a1
state: state
type: Primary
properties:
id:
description: Unique identifier for this Address
example: 851233a1
type: string
type:
enum:
- Primary
Expand Down
115 changes: 115 additions & 0 deletions client/api_customers.go
Expand Up @@ -27,6 +27,121 @@ var (

type CustomersApiService service

/*
CustomersApiService Add an Address onto an existing Customer record
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param customerId Customer Id
* @param createAddress
* @param optional nil or *AddCustomerAddressOpts - Optional Parameters:
* @param "XRequestId" (optional.String) - Optional Request ID allows application developer to trace requests through the systems logs
* @param "XUserId" (optional.String) - Moov User ID header, required in all requests
@return Customer
*/

type AddCustomerAddressOpts struct {
XRequestId optional.String
XUserId optional.String
}

func (a *CustomersApiService) AddCustomerAddress(ctx context.Context, customerId string, createAddress CreateAddress, localVarOptionals *AddCustomerAddressOpts) (Customer, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Post")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Customer
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/customers/{customer_id}/address"
localVarPath = strings.Replace(localVarPath, "{"+"customer_id"+"}", fmt.Sprintf("%v", customerId), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := url.Values{}
localVarFormParams := url.Values{}

// to determine the Content-Type header
localVarHttpContentTypes := []string{"application/json"}

// set Content-Type header
localVarHttpContentType := selectHeaderContentType(localVarHttpContentTypes)
if localVarHttpContentType != "" {
localVarHeaderParams["Content-Type"] = localVarHttpContentType
}

// to determine the Accept header
localVarHttpHeaderAccepts := []string{"application/json"}

// set Accept header
localVarHttpHeaderAccept := selectHeaderAccept(localVarHttpHeaderAccepts)
if localVarHttpHeaderAccept != "" {
localVarHeaderParams["Accept"] = localVarHttpHeaderAccept
}
if localVarOptionals != nil && localVarOptionals.XRequestId.IsSet() {
localVarHeaderParams["X-Request-Id"] = parameterToString(localVarOptionals.XRequestId.Value(), "")
}
if localVarOptionals != nil && localVarOptionals.XUserId.IsSet() {
localVarHeaderParams["X-User-Id"] = parameterToString(localVarOptionals.XUserId.Value(), "")
}
// body params
localVarPostBody = &createAddress
r, err := a.client.prepareRequest(ctx, localVarPath, localVarHttpMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHttpResponse, err := a.client.callAPI(r)
if err != nil || localVarHttpResponse == nil {
return localVarReturnValue, localVarHttpResponse, err
}

localVarBody, err := ioutil.ReadAll(localVarHttpResponse.Body)
localVarHttpResponse.Body.Close()
if err != nil {
return localVarReturnValue, localVarHttpResponse, err
}

if localVarHttpResponse.StatusCode >= 300 {
newErr := GenericOpenAPIError{
body: localVarBody,
error: localVarHttpResponse.Status,
}
if localVarHttpResponse.StatusCode == 200 {
var v Customer
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
if localVarHttpResponse.StatusCode == 400 {
var v Error
err = a.client.decode(&v, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr.error = err.Error()
return localVarReturnValue, localVarHttpResponse, newErr
}
newErr.model = v
return localVarReturnValue, localVarHttpResponse, newErr
}
return localVarReturnValue, localVarHttpResponse, newErr
}

err = a.client.decode(&localVarReturnValue, localVarBody, localVarHttpResponse.Header.Get("Content-Type"))
if err != nil {
newErr := GenericOpenAPIError{
body: localVarBody,
error: err.Error(),
}
return localVarReturnValue, localVarHttpResponse, newErr
}

return localVarReturnValue, localVarHttpResponse, nil
}

/*
CustomersApiService Create a new customer
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
Expand Down
1 change: 1 addition & 0 deletions client/docs/Address.md
Expand Up @@ -4,6 +4,7 @@

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Id** | **string** | Unique identifier for this Address | [optional]
**Type** | **string** | | [optional]
**Address1** | **string** | First line of the address | [optional]
**Address2** | **string** | Second line of the address | [optional]
Expand Down
46 changes: 46 additions & 0 deletions client/docs/CustomersApi.md
Expand Up @@ -4,6 +4,7 @@ All URIs are relative to *http://localhost:8087*

Method | HTTP request | Description
------------- | ------------- | -------------
[**AddCustomerAddress**](CustomersApi.md#AddCustomerAddress) | **Post** /customers/{customer_id}/address | Add an Address onto an existing Customer record
[**CreateCustomer**](CustomersApi.md#CreateCustomer) | **Post** /customers | Create a new customer
[**GetCustomer**](CustomersApi.md#GetCustomer) | **Get** /customers/{customer_id} | Retrieves a Customer object associated with the customer ID.
[**GetCustomerDocumentContents**](CustomersApi.md#GetCustomerDocumentContents) | **Get** /customers/{customer_id}/documents/{document_id} | Retrieve the referenced document
Expand All @@ -15,6 +16,51 @@ Method | HTTP request | Description



## AddCustomerAddress

> Customer AddCustomerAddress(ctx, customerId, createAddress, optional)
Add an Address onto an existing Customer record

### Required Parameters


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------
**ctx** | **context.Context** | context for authentication, logging, cancellation, deadlines, tracing, etc.
**customerId** | **string**| Customer Id |
**createAddress** | [**CreateAddress**](CreateAddress.md)| |
**optional** | ***AddCustomerAddressOpts** | optional parameters | nil if no parameters

### Optional Parameters

Optional parameters are passed through a pointer to a AddCustomerAddressOpts struct


Name | Type | Description | Notes
------------- | ------------- | ------------- | -------------


**xRequestId** | **optional.String**| Optional Request ID allows application developer to trace requests through the systems logs |
**xUserId** | **optional.String**| Moov User ID header, required in all requests |

### Return type

[**Customer**](Customer.md)

### Authorization

No authorization required

### HTTP request headers

- **Content-Type**: application/json
- **Accept**: application/json

[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints)
[[Back to Model list]](../README.md#documentation-for-models)
[[Back to README]](../README.md)


## CreateCustomer

> Customer CreateCustomer(ctx, createCustomer, optional)
Expand Down
2 changes: 2 additions & 0 deletions client/model_address.go
Expand Up @@ -10,6 +10,8 @@
package openapi

type Address struct {
// Unique identifier for this Address
Id string `json:"id,omitempty"`
Type string `json:"type,omitempty"`
// First line of the address
Address1 string `json:"address1,omitempty"`
Expand Down

0 comments on commit 27d44df

Please sign in to comment.