Class: ModernTreasury::ExpectedPaymentController

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

Overview

ExpectedPaymentController

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_expected_payment(idempotency_key: nil, body: nil) ⇒ ExpectedPayment

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 (ExpectedPaymentCreateRequest) (defaults to: nil)

    Optional parameter: TODO: type

Returns:



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/modern_treasury/controllers/expected_payment_controller.rb', line 75

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

#delete_expected_payment(id) ⇒ ExpectedPayment

TODO: type endpoint description here

Parameters:

  • id (String)

    Required parameter: id

Returns:



144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/modern_treasury/controllers/expected_payment_controller.rb', line 144

def delete_expected_payment(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/expected_payments/{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(ExpectedPayment.method(:from_hash))
                .local_error('422',
                             'parameter_invalid',
                             ErrorMessageException))
    .execute
end

#get_expected_payment(id) ⇒ ExpectedPayment

TODO: type endpoint description here

Parameters:

  • id (String)

    Required parameter: id

Returns:



99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/modern_treasury/controllers/expected_payment_controller.rb', line 99

def get_expected_payment(id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/expected_payments/{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(ExpectedPayment.method(:from_hash))
                .local_error('404',
                             'not found',
                             ErrorMessageException))
    .execute
end

#list_expected_payments(per_page: nil, status: nil, internal_account_id: nil, direction: nil, type: nil, counterparty_id: nil, metadata: nil, created_at_lower_bound: nil, created_at_upper_bound: nil, after_cursor: nil) ⇒ Array[ExpectedPayment]

TODO: type endpoint description here here reconciled, or archived. internal_account_id to see expected_payments for a specific account. debit book, check, eft, interac, provxchange, rtp,sen, sepa, signet, wire counterparty_id to see expected_payments for a specific account. you want to query for records with metadata key ‘Type` and value `Loan`, the query would be `metadata%5BType%5D=Loan`. This encodes the query parameters. return expected payments created after some datetime return expected payments created before some datetime here

Parameters:

  • per_page (Integer) (defaults to: nil)

    Optional parameter: TODO: type description

  • status (Status20Enum) (defaults to: nil)

    Optional parameter: One of unreconciled,

  • internal_account_id (String) (defaults to: nil)

    Optional parameter: Specify

  • direction (Direction15Enum) (defaults to: nil)

    Optional parameter: One of credit,

  • type (Type13Enum) (defaults to: nil)

    Optional parameter: One of: ach, au_becs, bacs,

  • counterparty_id (String) (defaults to: nil)

    Optional parameter: Specify

  • metadata (Hash[String, String]) (defaults to: nil)

    Optional parameter: For example, if

  • created_at_lower_bound (DateTime) (defaults to: nil)

    Optional parameter: Used to

  • created_at_upper_bound (DateTime) (defaults to: nil)

    Optional parameter: Used to

  • after_cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/modern_treasury/controllers/expected_payment_controller.rb', line 33

def list_expected_payments(per_page: nil,
                           status: nil,
                           internal_account_id: nil,
                           direction: nil,
                           type: nil,
                           counterparty_id: nil,
                           metadata: nil,
                           created_at_lower_bound: nil,
                           created_at_upper_bound: nil,
                           after_cursor: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/expected_payments',
                                 Server::DEFAULT)
               .query_param(new_parameter(per_page, key: 'per_page'))
               .query_param(new_parameter(status, key: 'status'))
               .query_param(new_parameter(, key: 'internal_account_id'))
               .query_param(new_parameter(direction, key: 'direction'))
               .query_param(new_parameter(type, key: 'type'))
               .query_param(new_parameter(counterparty_id, key: 'counterparty_id'))
               .query_param(new_parameter(, key: 'metadata'))
               .query_param(new_parameter(created_at_lower_bound, key: 'created_at_lower_bound'))
               .query_param(new_parameter(created_at_upper_bound, key: 'created_at_upper_bound'))
               .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(ExpectedPayment.method(:from_hash))
                .is_response_array(true)
                .local_error('401',
                             'unsuccessful',
                             ErrorMessageException))
    .execute
end

#update_expected_payment(id, body: nil) ⇒ ExpectedPayment

TODO: type endpoint description here description here

Parameters:

Returns:



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'lib/modern_treasury/controllers/expected_payment_controller.rb', line 122

def update_expected_payment(id,
                            body: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PATCH,
                                 '/api/expected_payments/{id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(id, key: 'id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .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(ExpectedPayment.method(:from_hash)))
    .execute
end