Class: ModernTreasury::PaymentFlowController

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

Overview

PaymentFlowController

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, user_agent_parameters

Constructor Details

This class inherits a constructor from ModernTreasury::BaseController

Instance Method Details

#create_payment_flow(idempotency_key: nil, body: nil) ⇒ ApiResponse

TODO: type endpoint description here something unique, preferably something like an UUID. description here

Parameters:

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (PaymentFlowCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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/payment_flow_controller.rb', line 62

def create_payment_flow(idempotency_key: nil,
                        body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/payment_flows',
                                 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(PaymentFlow.method(:from_hash))
                .is_api_response(true)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#get_payment_flow(id, idempotency_key: nil) ⇒ ApiResponse

TODO: type endpoint description here something unique, preferably something like an UUID.

Parameters:

  • id (String)

    Required parameter: id

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/modern_treasury/controllers/payment_flow_controller.rb', line 89

def get_payment_flow(id,
                     idempotency_key: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/payment_flows/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .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(PaymentFlow.method(:from_hash))
                .is_api_response(true))
    .execute
end

#list_payment_flows(after_cursor: nil, per_page: nil, client_token: nil, status: nil, counterparty_id: nil, receiving_account_id: nil, originating_account_id: nil, payment_order_id: nil) ⇒ ApiResponse

TODO: type endpoint description here here here here here description here description here description here

Parameters:

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • client_token (String) (defaults to: nil)

    Optional parameter: TODO: type description

  • status (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • counterparty_id (String) (defaults to: nil)

    Optional parameter: TODO: type description

  • receiving_account_id (String) (defaults to: nil)

    Optional parameter: TODO: type

  • originating_account_id (String) (defaults to: nil)

    Optional parameter: TODO: type

  • payment_order_id (String) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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
53
54
# File 'lib/modern_treasury/controllers/payment_flow_controller.rb', line 26

def list_payment_flows(after_cursor: nil,
                       per_page: nil,
                       client_token: nil,
                       status: nil,
                       counterparty_id: nil,
                       receiving_account_id: nil,
                       originating_account_id: nil,
                       payment_order_id: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/payment_flows',
                                 Server::DEFAULT)
               .query_param(new_parameter(after_cursor, key: 'after_cursor'))
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(client_token, key: 'client_token'))
               .query_param(new_parameter(status, key: 'status'))
               .query_param(new_parameter(counterparty_id, key: 'counterparty_id'))
               .query_param(new_parameter(, key: 'receiving_account_id'))
               .query_param(new_parameter(, key: 'originating_account_id'))
               .query_param(new_parameter(payment_order_id, key: 'payment_order_id'))
               .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(PaymentFlow.method(:from_hash))
                .is_api_response(true)
                .is_response_array(true))
    .execute
end

#update_payment_flow(id, idempotency_key: nil, body: nil) ⇒ ApiResponse

TODO: type endpoint description here something unique, preferably something like an UUID. description here

Parameters:

  • id (String)

    Required parameter: id

  • idempotency_key (String) (defaults to: nil)

    Optional parameter: This key should be

  • body (PaymentFlowUpdateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/modern_treasury/controllers/payment_flow_controller.rb', line 115

def update_payment_flow(id,
                        idempotency_key: nil,
                        body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/payment_flows/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .is_required(true)
                                .should_encode(true))
               .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(PaymentFlow.method(:from_hash))
                .is_api_response(true)
                .local_error('404',
                             'not found',
                             ErrorMessageException)
                .local_error('422',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end