Class: ModernTreasury::ReturnController

Inherits:
BaseController show all
Defined in:
lib/modern_treasury/controllers/return_controller.rb

Overview

ReturnController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from ModernTreasury::BaseController

Instance Method Details

#create_return(idempotency_key: nil, body: nil) ⇒ Return

Create a return. something unique, preferably something like an UUID. description here

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (ReturnCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (Return)

    Response from the API call.



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/modern_treasury/controllers/return_controller.rb', line 60

def create_return(idempotency_key: nil,
                  body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/returns',
                                 Server::DEFAULT)
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .body_param(new_parameter(body))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Return.method(:from_hash))
                .local_error('404',
                             'unsuccessful',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#get_return(id) ⇒ Return

Get a single return.

Parameters:

  • id (String)

    Required parameter: The ID of an existing return.

Returns:

  • (Return)

    Response from the API call.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/modern_treasury/controllers/return_controller.rb', line 87

def get_return(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/returns/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Return.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end

#list_returns(per_page: nil, internal_account_id: nil, counterparty_id: nil, returnable_id: nil, returnable_type: nil, after_cursor: nil) ⇒ Array[Return]

Get a list of returns. here ‘internal_account_id` if you wish to see returns to/from a specific account. `counterparty_id` if you wish to see returns that occurred with a specific counterparty. returnable. Must be accompanied by `returnable_type`. `payment_order`, `paper_item`, `reversal`, or `incoming_payment_detail`. Must be accompanied by `returnable_id`. here

Parameters:

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • internal_account_id (String) (defaults to: nil)

    Optional parameter: Specify

  • counterparty_id (String) (defaults to: nil)

    Optional parameter: Specify

  • returnable_id (String) (defaults to: nil)

    Optional parameter: The ID of a valid

  • returnable_type (ReturnableType1Enum) (defaults to: nil)

    Optional parameter: One of

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:

  • (Array[Return])

    Response from the API call.



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/modern_treasury/controllers/return_controller.rb', line 26

def list_returns(per_page: nil,
                 internal_account_id: nil,
                 counterparty_id: nil,
                 returnable_id: nil,
                 returnable_type: nil,
                 after_cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/returns',
                                 Server::DEFAULT)
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(, key: 'internal_account_id'))
               .query_param(new_parameter(counterparty_id, key: 'counterparty_id'))
               .query_param(new_parameter(returnable_id, key: 'returnable_id'))
               .query_param(new_parameter(returnable_type, key: 'returnable_type'))
               .query_param(new_parameter(after_cursor, key: 'after_cursor'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('basic_auth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Return.method(:from_hash))
                .is_response_array(true)
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end