Class: ModernTreasury::Resources::Counterparties

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/resources/counterparties.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Counterparties

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Counterparties.

Parameters:



208
209
210
# File 'lib/modern_treasury/resources/counterparties.rb', line 208

def initialize(client:)
  @client = client
end

Instance Method Details

#collect_account(id, direction: , custom_redirect: nil, fields: nil, send_email: nil, request_options: {}) ⇒ ModernTreasury::Models::CounterpartyCollectAccountResponse

Some parameter documentations has been truncated, see Models::CounterpartyCollectAccountParams for more details.

Send an email requesting account details.

Parameters:

Returns:

See Also:



194
195
196
197
198
199
200
201
202
203
# File 'lib/modern_treasury/resources/counterparties.rb', line 194

def (id, params)
  parsed, options = ModernTreasury::CounterpartyCollectAccountParams.dump_request(params)
  @client.request(
    method: :post,
    path: ["api/counterparties/%1$s/collect_account", id],
    body: parsed,
    model: ModernTreasury::CounterpartyCollectAccountResponse,
    options: options
  )
end

#create(name: , accounting: nil, accounts: nil, email: nil, external_id: nil, ledger_type: nil, legal_entity: nil, legal_entity_id: nil, metadata: nil, send_remittance_advice: nil, taxpayer_identifier: nil, verification_status: nil, request_options: {}) ⇒ ModernTreasury::Models::Counterparty

Some parameter documentations has been truncated, see Models::CounterpartyCreateParams for more details.

Create a new counterparty.

Parameters:

Returns:

See Also:



42
43
44
45
46
47
48
49
50
51
# File 'lib/modern_treasury/resources/counterparties.rb', line 42

def create(params)
  parsed, options = ModernTreasury::CounterpartyCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "api/counterparties",
    body: parsed,
    model: ModernTreasury::Counterparty,
    options: options
  )
end

#delete(id, request_options: {}) ⇒ nil

Deletes a given counterparty.

Parameters:

Returns:

  • (nil)

See Also:



163
164
165
166
167
168
169
170
# File 'lib/modern_treasury/resources/counterparties.rb', line 163

def delete(id, params = {})
  @client.request(
    method: :delete,
    path: ["api/counterparties/%1$s", id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(after_cursor: nil, created_at_lower_bound: nil, created_at_upper_bound: nil, email: nil, external_id: nil, legal_entity_id: nil, metadata: nil, name: nil, per_page: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::Counterparty>

Some parameter documentations has been truncated, see Models::CounterpartyListParams for more details.

Get a paginated list of all counterparties.

Parameters:

  • after_cursor (String, nil)
  • created_at_lower_bound (Time)

    Used to return counterparties created after some datetime.

  • created_at_upper_bound (Time)

    Used to return counterparties created before some datetime.

  • email (String)

    Performs a partial string match of the email field. This is also case insensitiv

  • external_id (String)

    An optional user-defined 180 character unique identifier.

  • legal_entity_id (String)

    Filters for counterparties with the given legal entity ID.

  • metadata (Hash{Symbol=>String})

    For example, if you want to query for records with metadata key ‘Type` and value

  • name (String)

    Performs a partial string match of the name field. This is also case insensitive

  • per_page (Integer)
  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



140
141
142
143
144
145
146
147
148
149
150
# File 'lib/modern_treasury/resources/counterparties.rb', line 140

def list(params = {})
  parsed, options = ModernTreasury::CounterpartyListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "api/counterparties",
    query: parsed,
    page: ModernTreasury::Internal::Page,
    model: ModernTreasury::Counterparty,
    options: options
  )
end

#retrieve(id, request_options: {}) ⇒ ModernTreasury::Models::Counterparty

Get details on a single counterparty.

Parameters:

Returns:

See Also:



64
65
66
67
68
69
70
71
# File 'lib/modern_treasury/resources/counterparties.rb', line 64

def retrieve(id, params = {})
  @client.request(
    method: :get,
    path: ["api/counterparties/%1$s", id],
    model: ModernTreasury::Counterparty,
    options: params[:request_options]
  )
end

#update(id, email: nil, legal_entity_id: nil, metadata: nil, name: nil, send_remittance_advice: nil, taxpayer_identifier: nil, request_options: {}) ⇒ ModernTreasury::Models::Counterparty

Some parameter documentations has been truncated, see Models::CounterpartyUpdateParams for more details.

Updates a given counterparty with new information.

Parameters:

  • id (String)

    The id of an existing counterparty.

  • email (String)

    A new email for the counterparty.

  • legal_entity_id (String, nil)

    The id of the legal entity.

  • metadata (Hash{Symbol=>String})

    Additional data in the form of key-value pairs. Pairs can be removed by passing

  • name (String)

    A new name for the counterparty. Will only update if passed.

  • send_remittance_advice (Boolean)

    If this is ‘true`, Modern Treasury will send an email to the counterparty whenev

  • taxpayer_identifier (String)

    Either a valid SSN or EIN.

  • request_options (ModernTreasury::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



99
100
101
102
103
104
105
106
107
108
# File 'lib/modern_treasury/resources/counterparties.rb', line 99

def update(id, params = {})
  parsed, options = ModernTreasury::CounterpartyUpdateParams.dump_request(params)
  @client.request(
    method: :patch,
    path: ["api/counterparties/%1$s", id],
    body: parsed,
    model: ModernTreasury::Counterparty,
    options: options
  )
end