Class: CheckoutSdk::Accounts::AccountsClient

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

Constant Summary collapse

DEFAULT_SCHEMA_VERSION =
'3.0'

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:



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

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:



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

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:



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

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, schema_version = DEFAULT_SCHEMA_VERSION) ⇒ Object

Parameters:

  • entity_request (Hash, OnboardEntity)
  • schema_version (String) (defaults to: DEFAULT_SCHEMA_VERSION)

    Accounts API schema version negotiated via the Accept header.



31
32
33
34
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 31

def create_entity(entity_request, schema_version = DEFAULT_SCHEMA_VERSION)
  api_client.invoke_post(build_path(ACCOUNTS, ENTITIES), sdk_authorization, entity_request, nil,
                         build_schema_version_headers(schema_version))
end

#create_payment_instrument(entity_id, payment_instrument) ⇒ Object

Deprecated.

Please use #add_payment_instrument instead

Parameters:



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

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, schema_version = DEFAULT_SCHEMA_VERSION) ⇒ Object

Parameters:

  • entity_id (String)
  • schema_version (String) (defaults to: DEFAULT_SCHEMA_VERSION)

    Accounts API schema version negotiated via the Accept header.



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

def get_entity(entity_id, schema_version = DEFAULT_SCHEMA_VERSION)
  api_client.invoke_get(build_path(ACCOUNTS, ENTITIES, entity_id), sdk_authorization, nil,
                        build_schema_version_headers(schema_version))
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)


233
234
235
236
237
238
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 233

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)


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

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, schema_version = DEFAULT_SCHEMA_VERSION) ⇒ Object

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

Parameters:

  • entity_id (String)
  • schema_version (String) (defaults to: DEFAULT_SCHEMA_VERSION)

    Accounts API schema version negotiated via the Accept header.



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

def get_entity_requirements(entity_id, schema_version = DEFAULT_SCHEMA_VERSION)
  api_client.invoke_get(
    build_path(ACCOUNTS, ENTITIES, entity_id, REQUIREMENTS),
    sdk_authorization,
    nil,
    build_schema_version_headers(schema_version)
  )
end

#get_reserve_rule(entity_id, reserve_rule_id) ⇒ Object

Retrieve a reserve rule by id.

Parameters:

  • entity_id (String)
  • reserve_rule_id (String)


165
166
167
168
169
170
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 165

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)


197
198
199
200
201
202
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 197

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:



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

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)


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

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.



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

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:



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

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)


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

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)


99
100
101
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 99

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, schema_version = DEFAULT_SCHEMA_VERSION) ⇒ Object

Parameters:

  • entity_id (String)
  • entity_request (Hash, OnboardEntity)
  • schema_version (String) (defaults to: DEFAULT_SCHEMA_VERSION)

    Accounts API schema version negotiated via the Accept header.



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

def update_entity(entity_id, entity_request, schema_version = DEFAULT_SCHEMA_VERSION)
  api_client.invoke_put(build_path(ACCOUNTS, ENTITIES, entity_id), sdk_authorization, entity_request,
                        build_schema_version_headers(schema_version))
end

#update_payment_instrument(entity_id, instrument_id, update_payment_instrument) ⇒ Object

Parameters:



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

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:



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

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)


180
181
182
183
184
185
186
187
188
189
190
191
192
193
# File 'lib/checkout_sdk/accounts/accounts_client.rb', line 180

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:



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

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:



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

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