Class: CheckoutSdk::Accounts::AccountsClient

Inherits:
Client
  • Object
show all
Defined in:
lib/checkout_sdk/accounts/accounts_client.rb

Instance Attribute Summary collapse

Attributes inherited from Client

#api_client, #authorization_type, #configuration

Instance Method Summary collapse

Constructor Details

#initialize(api_client, files_client, configuration) ⇒ AccountsClient

Returns a new instance of AccountsClient.

Parameters:



23
24
25
26
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 23

def initialize(api_client, files_client, configuration)
  super(api_client, configuration, CheckoutSdk::AuthorizationType::SECRET_KEY_OR_OAUTH)
  @files_client = files_client
end

Instance Attribute Details

#files_clientObject (readonly)

Returns the value of attribute files_client.



6
7
8
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 6

def files_client
  @files_client
end

Instance Method Details

#add_payment_instrument(entity_id, payment_instrument) ⇒ Object

Parameters:



54
55
56
57
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 54

def add_payment_instrument(entity_id, payment_instrument)
  api_client.invoke_post(build_path(ACCOUNTS, ENTITIES, entity_id, PAYMENT_INSTRUMENTS), sdk_authorization,
                         payment_instrument)
end

#add_reserve_rule(entity_id, reserve_rule_request) ⇒ Object

Add a reserve rule for a sub-entity.

Parameters:



135
136
137
138
139
140
141
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 135

def add_reserve_rule(entity_id, reserve_rule_request)
  api_client.invoke_post(
    build_path(ACCOUNTS, ENTITIES, entity_id, RESERVE_RULES),
    sdk_authorization,
    reserve_rule_request
  )
end

#create_entity(entity_request) ⇒ Object

Parameters:



29
30
31
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 29

def create_entity(entity_request)
  api_client.invoke_post(build_path(ACCOUNTS, ENTITIES), sdk_authorization, entity_request)
end

#create_payment_instrument(entity_id, payment_instrument) ⇒ Object

Deprecated.

Please use #add_payment_instrument instead

Parameters:



47
48
49
50
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 47

def create_payment_instrument(entity_id, payment_instrument)
  api_client.invoke_post(build_path(ACCOUNTS, ENTITIES, entity_id, INSTRUMENT), sdk_authorization,
                         payment_instrument)
end

#get_entity(entity_id) ⇒ Object

Parameters:

  • entity_id (String)


34
35
36
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 34

def get_entity(entity_id)
  api_client.invoke_get(build_path(ACCOUNTS, ENTITIES, entity_id), sdk_authorization)
end

#get_entity_file(entity_id, file_id) ⇒ Object

Retrieve a file scoped to a sub-entity. Hits GET /entities/entityId/files/fileId.

Parameters:

  • entity_id (String)
  • file_id (String)


223
224
225
226
227
228
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 223

def get_entity_file(entity_id, file_id)
  files_client.invoke_get(
    build_path(ENTITIES, entity_id, FILES, file_id),
    sdk_authorization
  )
end

#get_entity_requirement_details(entity_id, requirement_id) ⇒ Object

Retrieve detailed information for a single requirement.

Parameters:

  • entity_id (String)
  • requirement_id (String)


113
114
115
116
117
118
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 113

def get_entity_requirement_details(entity_id, requirement_id)
  api_client.invoke_get(
    build_path(ACCOUNTS, ENTITIES, entity_id, REQUIREMENTS, requirement_id),
    sdk_authorization
  )
end

#get_entity_requirements(entity_id) ⇒ Object

Retrieve the list of pending requirements that a sub-entity must resolve.

Parameters:

  • entity_id (String)


103
104
105
106
107
108
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 103

def get_entity_requirements(entity_id)
  api_client.invoke_get(
    build_path(ACCOUNTS, ENTITIES, entity_id, REQUIREMENTS),
    sdk_authorization
  )
end

#get_reserve_rule(entity_id, reserve_rule_id) ⇒ Object

Retrieve a reserve rule by id.

Parameters:

  • entity_id (String)
  • reserve_rule_id (String)


155
156
157
158
159
160
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 155

def get_reserve_rule(entity_id, reserve_rule_id)
  api_client.invoke_get(
    build_path(ACCOUNTS, ENTITIES, entity_id, RESERVE_RULES, reserve_rule_id),
    sdk_authorization
  )
end

#get_sub_entity_members(entity_id) ⇒ Object

List sub-entity members.

Parameters:

  • entity_id (String)


187
188
189
190
191
192
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 187

def get_sub_entity_members(entity_id)
  api_client.invoke_get(
    build_path(ACCOUNTS, ENTITIES, entity_id, MEMBERS),
    sdk_authorization
  )
end

#query_payment_instruments(entity_id, payment_instruments_query = nil) ⇒ Object

Parameters:



61
62
63
64
65
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 61

def query_payment_instruments(entity_id, payment_instruments_query = nil)
  api_client.invoke_get(build_path(ACCOUNTS, ENTITIES, entity_id, PAYMENT_INSTRUMENTS),
                        sdk_authorization,
                        payment_instruments_query)
end

#query_reserve_rules(entity_id) ⇒ Object

Query reserve rules for a sub-entity.

Parameters:

  • entity_id (String)


145
146
147
148
149
150
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 145

def query_reserve_rules(entity_id)
  api_client.invoke_get(
    build_path(ACCOUNTS, ENTITIES, entity_id, RESERVE_RULES),
    sdk_authorization
  )
end

#reinvite_sub_entity_member(entity_id, user_id, reinvite_request) ⇒ Object

Reinvite a sub-entity member. The API marks the request body as required; callers must provide a Hash (or ‘PlatformsHostedOnboardReinviteRequest`-shaped object), even if it is empty `{}` per the current swagger contract.

Parameters:

  • entity_id (String)
  • user_id (String)
  • reinvite_request (Hash)

    Required body per swagger; pass ‘{}` if no fields are needed.



201
202
203
204
205
206
207
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 201

def reinvite_sub_entity_member(entity_id, user_id, reinvite_request)
  api_client.invoke_put(
    build_path(ACCOUNTS, ENTITIES, entity_id, MEMBERS, user_id),
    sdk_authorization,
    reinvite_request
  )
end

#resolve_entity_requirement(entity_id, requirement_id, update_request) ⇒ Object

Submit a response to resolve a requirement.

Parameters:



124
125
126
127
128
129
130
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 124

def resolve_entity_requirement(entity_id, requirement_id, update_request)
  api_client.invoke_put(
    build_path(ACCOUNTS, ENTITIES, entity_id, REQUIREMENTS, requirement_id),
    sdk_authorization,
    update_request
  )
end

#retrieve_payment_instrument_details(entity_id, payment_instrument_id) ⇒ Object

Parameters:

  • entity_id (String)
  • payment_instrument_id (String)


69
70
71
72
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 69

def retrieve_payment_instrument_details(entity_id, payment_instrument_id)
  api_client.invoke_get(build_path(ACCOUNTS, ENTITIES, entity_id, PAYMENT_INSTRUMENTS, payment_instrument_id),
                        sdk_authorization)
end

#retrieve_payout_schedule(entity_id) ⇒ Object

Parameters:

  • entity_id (String)


92
93
94
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 92

def retrieve_payout_schedule(entity_id)
  api_client.invoke_get(build_path(ACCOUNTS, ENTITIES, entity_id, PAYOUT_SCHEDULE), sdk_authorization)
end

#update_entity(entity_id, entity_request) ⇒ Object

Parameters:



40
41
42
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 40

def update_entity(entity_id, entity_request)
  api_client.invoke_put(build_path(ACCOUNTS, ENTITIES, entity_id), sdk_authorization, entity_request)
end

#update_payment_instrument(entity_id, instrument_id, update_payment_instrument) ⇒ Object

Parameters:



77
78
79
80
81
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 77

def update_payment_instrument(entity_id, instrument_id, update_payment_instrument)
  api_client.invoke_patch(build_path(ACCOUNTS, ENTITIES, entity_id, PAYMENT_INSTRUMENTS, instrument_id),
                          sdk_authorization,
                          update_payment_instrument)
end

#update_payout_schedule(entity_id, currency, update_schedule) ⇒ Object

Parameters:



86
87
88
89
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 86

def update_payout_schedule(entity_id, currency, update_schedule)
  api_client.invoke_put(build_path(ACCOUNTS, ENTITIES, entity_id, PAYOUT_SCHEDULE), sdk_authorization,
                        { currency => update_schedule })
end

#update_reserve_rule(entity_id, reserve_rule_id, etag, reserve_rule_request) ⇒ Object

Update a reserve rule. The API enforces optimistic concurrency: the ETag returned by GET must be echoed back via Common::Headers#if_match, otherwise the API responds 428 Precondition Required.

Parameters:

  • entity_id (String)
  • reserve_rule_id (String)
  • etag (String)

    ETag value to forward as the ‘If-Match` HTTP header.

  • reserve_rule_request (Hash, ReserveRuleUpdateRequest)


170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 170

def update_reserve_rule(entity_id, reserve_rule_id, etag, reserve_rule_request)
  headers = nil
  if !etag.nil? && !etag.empty?
    headers = CheckoutSdk::Common::Headers.new
    headers.if_match = etag
  end

  api_client.invoke_put(
    build_path(ACCOUNTS, ENTITIES, entity_id, RESERVE_RULES, reserve_rule_id),
    sdk_authorization,
    reserve_rule_request,
    headers
  )
end

#upload_entity_file(entity_id, file_request) ⇒ Object

Upload a file scoped to a sub-entity. Hits POST /entities/entityId/files.

Parameters:



212
213
214
215
216
217
218
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 212

def upload_entity_file(entity_id, file_request)
  files_client.submit_file(
    build_path(ENTITIES, entity_id, FILES),
    sdk_authorization,
    file_request
  )
end

#upload_file(file_request) ⇒ Object

Parameters:



97
98
99
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 97

def upload_file(file_request)
  files_client.submit_file(FILES, sdk_authorization, file_request)
end