Skip to content
This repository has been archived by the owner on Dec 9, 2021. It is now read-only.

Commit

Permalink
Merge pull request moov-io#17 from adamdecaf/update-customer-status
Browse files Browse the repository at this point in the history
cmd/server: add endpoint for updating a Customer's status
  • Loading branch information
adamdecaf authored Jun 3, 2019
2 parents 8294560 + 677e159 commit e06933b
Show file tree
Hide file tree
Showing 10 changed files with 559 additions and 21 deletions.
2 changes: 2 additions & 0 deletions client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ Class | Method | HTTP request | Description
*CustomersApi* | [**GetCustomerDocuments**](docs/CustomersApi.md#getcustomerdocuments) | **Get** /customers/{customer_id}/documents | Get documents for a customer
*CustomersApi* | [**Ping**](docs/CustomersApi.md#ping) | **Get** /ping | Ping the Customers service to check if running
*CustomersApi* | [**ReplaceCustomerMetadata**](docs/CustomersApi.md#replacecustomermetadata) | **Put** /customers/{customer_id}/metadata | Replace the metadata object for a customer. Metadata is a map of unique keys associated to values to act as foreign key relationships or arbitrary data associated to a Customer.
*CustomersApi* | [**UpdateCustomerStatus**](docs/CustomersApi.md#updatecustomerstatus) | **Put** /customers/{customer_id}/status | Update the status for a customer, which can only be updated by authenticated users with permissions.
*CustomersApi* | [**UploadCustomerDocument**](docs/CustomersApi.md#uploadcustomerdocument) | **Post** /customers/{customer_id}/documents | Upload a document for the given customer.


Expand All @@ -53,6 +54,7 @@ Class | Method | HTTP request | Description
- [Document](docs/Document.md)
- [Error](docs/Error.md)
- [Phone](docs/Phone.md)
- [UpdateCustomerStatus](docs/UpdateCustomerStatus.md)


## Documentation For Authorization
Expand Down
79 changes: 78 additions & 1 deletion client/api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,61 @@ paths:
data associated to a Customer.
tags:
- Customers
/customers/{customer_id}/status:
put:
operationId: updateCustomerStatus
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/UpdateCustomerStatus'
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: Update the status for a customer, which can only be updated by authenticated
users with permissions.
tags:
- Customers
/customers/{customer_id}/documents:
get:
operationId: getCustomerDocuments
Expand Down Expand Up @@ -511,8 +566,8 @@ components:
enum:
- Deceased
- Rejected
- ReviewRequired
- None
- ReviewRequired
- KYC
- OFAC
- CIP
Expand Down Expand Up @@ -564,6 +619,28 @@ components:
type: object
required:
- metadata
UpdateCustomerStatus:
example:
comment: Customer was approved from KYC confirmation
status: Deceased
properties:
comment:
description: Free form comment about the customer status update
example: Customer was approved from KYC confirmation
type: string
status:
description: State of the customer
enum:
- Deceased
- Rejected
- None
- ReviewRequired
- KYC
- OFAC
- CIP
type: string
required:
- status
CreatePhone:
example:
number: +1.818.555.1212
Expand Down
115 changes: 115 additions & 0 deletions client/api_customers.go
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,121 @@ func (a *CustomersApiService) ReplaceCustomerMetadata(ctx context.Context, custo
return localVarReturnValue, localVarHttpResponse, nil
}

/*
CustomersApiService Update the status for a customer, which can only be updated by authenticated users with permissions.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
* @param customerId Customer Id
* @param updateCustomerStatus
* @param optional nil or *UpdateCustomerStatusOpts - 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 UpdateCustomerStatusOpts struct {
XRequestId optional.String
XUserId optional.String
}

func (a *CustomersApiService) UpdateCustomerStatus(ctx context.Context, customerId string, updateCustomerStatus UpdateCustomerStatus, localVarOptionals *UpdateCustomerStatusOpts) (Customer, *http.Response, error) {
var (
localVarHttpMethod = strings.ToUpper("Put")
localVarPostBody interface{}
localVarFormFileName string
localVarFileName string
localVarFileBytes []byte
localVarReturnValue Customer
)

// create path and map variables
localVarPath := a.client.cfg.BasePath + "/customers/{customer_id}/status"
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 = &updateCustomerStatus
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 Upload a document for the given customer.
* @param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
Expand Down
46 changes: 46 additions & 0 deletions client/docs/CustomersApi.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Method | HTTP request | Description
[**GetCustomerDocuments**](CustomersApi.md#GetCustomerDocuments) | **Get** /customers/{customer_id}/documents | Get documents for a customer
[**Ping**](CustomersApi.md#Ping) | **Get** /ping | Ping the Customers service to check if running
[**ReplaceCustomerMetadata**](CustomersApi.md#ReplaceCustomerMetadata) | **Put** /customers/{customer_id}/metadata | Replace the metadata object for a customer. Metadata is a map of unique keys associated to values to act as foreign key relationships or arbitrary data associated to a Customer.
[**UpdateCustomerStatus**](CustomersApi.md#UpdateCustomerStatus) | **Put** /customers/{customer_id}/status | Update the status for a customer, which can only be updated by authenticated users with permissions.
[**UploadCustomerDocument**](CustomersApi.md#UploadCustomerDocument) | **Post** /customers/{customer_id}/documents | Upload a document for the given customer.


Expand Down Expand Up @@ -260,6 +261,51 @@ No authorization required
[[Back to README]](../README.md)


## UpdateCustomerStatus

> Customer UpdateCustomerStatus(ctx, customerId, updateCustomerStatus, optional)
Update the status for a customer, which can only be updated by authenticated users with permissions.

### Required Parameters


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

### Optional Parameters

Optional parameters are passed through a pointer to a UpdateCustomerStatusOpts 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)


## UploadCustomerDocument

> Document UploadCustomerDocument(ctx, customerId, type_, file, optional)
Expand Down
12 changes: 12 additions & 0 deletions client/docs/UpdateCustomerStatus.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# UpdateCustomerStatus

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**Comment** | **string** | Free form comment about the customer status update | [optional]
**Status** | **string** | State of the customer |

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


17 changes: 17 additions & 0 deletions client/model_update_customer_status.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Customers API
*
* Customers ...
*
* API version: v1
* Generated by: OpenAPI Generator (https://openapi-generator.tech)
*/

package openapi

type UpdateCustomerStatus struct {
// Free form comment about the customer status update
Comment string `json:"comment,omitempty"`
// State of the customer
Status string `json:"status"`
}
Loading

0 comments on commit e06933b

Please sign in to comment.