Class: Merge::Accounting::AsyncPaymentsClient

Inherits:
Object
  • Object
show all
Defined in:
lib/merge_ruby_client/accounting/payments/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ Merge::Accounting::AsyncPaymentsClient

Parameters:



301
302
303
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 301

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientMerge::AsyncRequestClient (readonly)



297
298
299
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 297

def request_client
  @request_client
end

Instance Method Details

#create(model:, is_debug_mode: nil, run_async: nil, request_options: nil) ⇒ Merge::Accounting::PaymentResponse

Creates a ‘Payment` object with the given values.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.payments.create(model: {  })

Parameters:

  • is_debug_mode (Boolean) (defaults to: nil)

    Whether to include debug fields (such as log file links) in the response.

  • run_async (Boolean) (defaults to: nil)

    Whether or not third-party updates should be run asynchronously.

  • model (Hash)

    Request of type Merge::Accounting::PaymentRequest, as a Hash

    • :transaction_date (DateTime)

    • :contact (Hash)

    • :account (Hash)

    • :currency (Merge::Accounting::CurrencyEnum)

    • :exchange_rate (String)

    • :company (Hash)

    • :total_amount (Float)

    • :type (Merge::Accounting::PaymentTypeEnum)

    • :tracking_categories (Array<Merge::Accounting::PaymentRequestTrackingCategoriesItem>)

    • :accounting_period (Hash)

    • :applied_to_lines (Array<Merge::Accounting::PaymentRequestAppliedToLinesItem>)

    • :integration_params (Hash=> Object)

    • :linked_account_params (Hash=> Object)

  • request_options (Merge::RequestOptions) (defaults to: nil)

Returns:



400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 400

def create(model:, is_debug_mode: nil, run_async: nil, request_options: nil)
  Async do
    response = @request_client.conn.post do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers["X-Account-Token"] = request_options. unless request_options&..nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "is_debug_mode": is_debug_mode,
        "run_async": run_async
      }.compact
      req.body = { **(request_options&.additional_body_parameters || {}), model: model }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/payments"
    end
    Merge::Accounting::PaymentResponse.from_json(json_object: response.body)
  end
end

#list(account_id: nil, company_id: nil, contact_id: nil, created_after: nil, created_before: nil, cursor: nil, expand: nil, include_deleted_data: nil, include_remote_data: nil, modified_after: nil, modified_before: nil, page_size: nil, remote_id: nil, transaction_date_after: nil, transaction_date_before: nil, request_options: nil) ⇒ Merge::Accounting::PaginatedPaymentList

Returns a list of ‘Payment` objects.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.payments.list

Parameters:

  • account_id (String) (defaults to: nil)

    If provided, will only return payments for this account.

  • company_id (String) (defaults to: nil)

    If provided, will only return payments for this company.

  • contact_id (String) (defaults to: nil)

    If provided, will only return payments for this contact.

  • created_after (DateTime) (defaults to: nil)

    If provided, will only return objects created after this datetime.

  • created_before (DateTime) (defaults to: nil)

    If provided, will only return objects created before this datetime.

  • cursor (String) (defaults to: nil)

    The pagination cursor value.

  • expand (Merge::Accounting::Payments::PaymentsListRequestExpand) (defaults to: nil)

    Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.

  • include_deleted_data (Boolean) (defaults to: nil)

    Whether to include data that was marked as deleted by third party webhooks.

  • include_remote_data (Boolean) (defaults to: nil)

    Whether to include the original data Merge fetched from the third-party to produce these models.

  • modified_after (DateTime) (defaults to: nil)

    If provided, only objects synced by Merge after this date time will be returned.

  • modified_before (DateTime) (defaults to: nil)

    If provided, only objects synced by Merge before this date time will be returned.

  • page_size (Integer) (defaults to: nil)

    Number of results to return per page.

  • remote_id (String) (defaults to: nil)

    The API provider’s ID for the given object.

  • transaction_date_after (DateTime) (defaults to: nil)

    If provided, will only return objects created after this datetime.

  • transaction_date_before (DateTime) (defaults to: nil)

    If provided, will only return objects created before this datetime.

  • request_options (Merge::RequestOptions) (defaults to: nil)

Returns:



334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 334

def list(account_id: nil, company_id: nil, contact_id: nil, created_after: nil, created_before: nil, cursor: nil,
         expand: nil, include_deleted_data: nil, include_remote_data: nil, modified_after: nil, modified_before: nil, page_size: nil, remote_id: nil, transaction_date_after: nil, transaction_date_before: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers["X-Account-Token"] = request_options. unless request_options&..nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "account_id": ,
        "company_id": company_id,
        "contact_id": contact_id,
        "created_after": created_after,
        "created_before": created_before,
        "cursor": cursor,
        "expand": expand,
        "include_deleted_data": include_deleted_data,
        "include_remote_data": include_remote_data,
        "modified_after": modified_after,
        "modified_before": modified_before,
        "page_size": page_size,
        "remote_id": remote_id,
        "transaction_date_after": transaction_date_after,
        "transaction_date_before": transaction_date_before
      }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/payments"
    end
    Merge::Accounting::PaginatedPaymentList.from_json(json_object: response.body)
  end
end

#meta_patch_retrieve(id:, request_options: nil) ⇒ Merge::Accounting::MetaResponse

Returns metadata for ‘Payment` PATCHs.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.payments.meta_patch_retrieve(id: "id")

Parameters:

Returns:



527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 527

def meta_patch_retrieve(id:, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers["X-Account-Token"] = request_options. unless request_options&..nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/payments/meta/patch/#{id}"
    end
    Merge::Accounting::MetaResponse.from_json(json_object: response.body)
  end
end

#meta_post_retrieve(request_options: nil) ⇒ Merge::Accounting::MetaResponse

Returns metadata for ‘Payment` POSTs.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.payments.meta_post_retrieve

Parameters:

Returns:



561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 561

def meta_post_retrieve(request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers["X-Account-Token"] = request_options. unless request_options&..nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      unless request_options.nil? || request_options&.additional_query_parameters.nil?
        req.params = { **(request_options&.additional_query_parameters || {}) }.compact
      end
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/payments/meta/post"
    end
    Merge::Accounting::MetaResponse.from_json(json_object: response.body)
  end
end

#partial_update(id:, model:, is_debug_mode: nil, run_async: nil, request_options: nil) ⇒ Merge::Accounting::PaymentResponse

Updates a ‘Payment` object with the given `id`.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.payments.partial_update(id: "id", model: {  })

Parameters:

  • id (String)
  • is_debug_mode (Boolean) (defaults to: nil)

    Whether to include debug fields (such as log file links) in the response.

  • run_async (Boolean) (defaults to: nil)

    Whether or not third-party updates should be run asynchronously.

  • model (Hash)

    Request of type Merge::Accounting::PatchedPaymentRequest, as a Hash

    • :transaction_date (DateTime)

    • :contact (Hash)

    • :account (Hash)

    • :currency (Merge::Accounting::CurrencyEnum)

    • :exchange_rate (String)

    • :company (Hash)

    • :total_amount (Float)

    • :type (Merge::Accounting::PaymentTypeEnum)

    • :tracking_categories (Array<Merge::Accounting::PatchedPaymentRequestTrackingCategoriesItem>)

    • :accounting_period (Hash)

    • :applied_to_lines (Array<Merge::Accounting::PatchedPaymentRequestAppliedToLinesItem>)

    • :integration_params (Hash=> Object)

    • :linked_account_params (Hash=> Object)

  • request_options (Merge::RequestOptions) (defaults to: nil)

Returns:



492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 492

def partial_update(id:, model:, is_debug_mode: nil, run_async: nil, request_options: nil)
  Async do
    response = @request_client.conn.patch do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers["X-Account-Token"] = request_options. unless request_options&..nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "is_debug_mode": is_debug_mode,
        "run_async": run_async
      }.compact
      req.body = { **(request_options&.additional_body_parameters || {}), model: model }.compact
      req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/payments/#{id}"
    end
    Merge::Accounting::PaymentResponse.from_json(json_object: response.body)
  end
end

#retrieve(id:, expand: nil, include_remote_data: nil, request_options: nil) ⇒ Merge::Accounting::Payment

Returns a ‘Payment` object with the given `id`.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.payments.retrieve(id: "id")

Parameters:

  • id (String)
  • expand (Merge::Accounting::Payments::PaymentsRetrieveRequestExpand) (defaults to: nil)

    Which relations should be returned in expanded form. Multiple relation names should be comma separated without spaces.

  • include_remote_data (Boolean) (defaults to: nil)

    Whether to include the original data Merge fetched from the third-party to produce these models.

  • request_options (Merge::RequestOptions) (defaults to: nil)

Returns:



439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
# File 'lib/merge_ruby_client/accounting/payments/client.rb', line 439

def retrieve(id:, expand: nil, include_remote_data: nil, request_options: nil)
  Async do
    response = @request_client.conn.get do |req|
      req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
      req.headers["Authorization"] = request_options.api_key unless request_options&.api_key.nil?
      req.headers["X-Account-Token"] = request_options. unless request_options&..nil?
      req.headers = {
    **(req.headers || {}),
    **@request_client.get_headers,
    **(request_options&.additional_headers || {})
      }.compact
      req.params = {
        **(request_options&.additional_query_parameters || {}),
        "expand": expand,
        "include_remote_data": include_remote_data
      }.compact
      unless request_options.nil? || request_options&.additional_body_parameters.nil?
        req.body = { **(request_options&.additional_body_parameters || {}) }.compact
      end
      req.url "#{@request_client.get_url(request_options: request_options)}/accounting/v1/payments/#{id}"
    end
    Merge::Accounting::Payment.from_json(json_object: response.body)
  end
end