Class: ModernTreasury::Resources::Transactions

Inherits:
Object
  • Object
show all
Defined in:
lib/modern_treasury/resources/transactions.rb,
lib/modern_treasury/resources/transactions/line_items.rb

Defined Under Namespace

Classes: LineItems

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Transactions

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 Transactions.

Parameters:



176
177
178
179
# File 'lib/modern_treasury/resources/transactions.rb', line 176

def initialize(client:)
  @client = client
  @line_items = ModernTreasury::Resources::Transactions::LineItems.new(client: client)
end

Instance Attribute Details

#line_itemsModernTreasury::Resources::Transactions::LineItems (readonly)



7
8
9
# File 'lib/modern_treasury/resources/transactions.rb', line 7

def line_items
  @line_items
end

Instance Method Details

#create(amount: , as_of_date: , direction: , internal_account_id: , vendor_code: , vendor_code_type: , metadata: nil, posted: nil, type: nil, vendor_customer_id: nil, vendor_description: nil, request_options: {}) ⇒ ModernTreasury::Models::Transaction

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

create transaction

Parameters:

  • amount (Integer)

    Value in specified currency’s smallest unit. e.g. $10 would be represented as 10

  • as_of_date (Date, nil)

    The date on which the transaction occurred.

  • direction (String)

    Either ‘credit` or `debit`.

  • internal_account_id (String)

    The ID of the relevant Internal Account.

  • vendor_code (String, nil)

    When applicable, the bank-given code that determines the transaction’s category.

  • vendor_code_type (String, nil)

    The type of ‘vendor_code` being reported. Can be one of `bai2`, `bankprov`, `bnk

  • metadata (Hash{Symbol=>String})

    Additional data represented as key-value pairs. Both the key and value must be s

  • posted (Boolean)

    This field will be ‘true` if the transaction has posted to the account.

  • type (Symbol, ModernTreasury::Models::TransactionCreateParams::Type, nil)

    The type of the transaction. Examples could be ‘card, `ach`, `wire`, `check`, `r

  • vendor_customer_id (String, nil)

    An identifier given to this transaction by the bank, often ‘null`.

  • vendor_description (String, nil)

    The transaction detail text that often appears in on your bank statement and in

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

Returns:

See Also:



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

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

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

delete transaction

Parameters:

Returns:

  • (nil)

See Also:



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

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

#list(after_cursor: nil, as_of_date_end: nil, as_of_date_start: nil, counterparty_id: nil, description: nil, direction: nil, internal_account_id: nil, metadata: nil, payment_type: nil, per_page: nil, posted: nil, transactable_type: nil, vendor_id: nil, virtual_account_id: nil, request_options: {}) ⇒ ModernTreasury::Internal::Page<ModernTreasury::Models::Transaction>

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

Get a list of all transactions.

Parameters:

  • after_cursor (String, nil)
  • as_of_date_end (Date)

    Filters transactions with an ‘as_of_date` starting on or before the specified da

  • as_of_date_start (Date)

    Filters transactions with an ‘as_of_date` starting on or after the specified dat

  • counterparty_id (String)
  • description (String)

    Filters for transactions including the queried string in the description.

  • direction (String)
  • internal_account_id (String)

    Specify ‘internal_account_id` if you wish to see transactions to/from a specific

  • metadata (Hash{Symbol=>String})

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

  • payment_type (String)
  • per_page (Integer)
  • posted (Boolean)

    Either ‘true` or `false`.

  • transactable_type (String)
  • vendor_id (String)

    Filters for transactions including the queried vendor id (an identifier given to

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

Returns:

See Also:



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

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

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

Get details on a single transaction.

Parameters:

Returns:

See Also:



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

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

#update(id, metadata: nil, request_options: {}) ⇒ ModernTreasury::Models::Transaction

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

Update a single transaction.

Parameters:

  • id (String)

    Transaction ID

  • metadata (Hash{Symbol=>String})

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

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

Returns:

See Also:



90
91
92
93
94
95
96
97
98
99
# File 'lib/modern_treasury/resources/transactions.rb', line 90

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