Class: Merge::Accounting::AsyncExpenseReportsClient

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Parameters:



391
392
393
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 391

def initialize(request_client:)
  @request_client = request_client
end

Instance Attribute Details

#request_clientMerge::AsyncRequestClient (readonly)



387
388
389
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 387

def request_client
  @request_client
end

Instance Method Details

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

Creates an ‘ExpenseReport` 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.expense_reports.create(model: { tracking_categories: ["a1b2c3d4-e5f6-4a5b-9c3d-2e1f0a9b8c7d", "d4c3b2a1-9e8f-7g6h-5i4j-3k2l1m0n9o8p"] })

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::ExpenseReportRequest, as a Hash

    • :report_date (DateTime)

    • :report_identifier (String)

    • :employee (Hash)

    • :status (Merge::Accounting::ExpenseReportStatusEnum)

    • :total_amount (Float)

    • :currency (Merge::Accounting::TransactionCurrencyEnum)

    • :description (String)

    • :accounting_period (Hash)

    • :company (Hash)

    • :tracking_categories (Array<String>)

    • :integration_params (Hash=> Object)

    • :linked_account_params (Hash=> Object)

    • :remote_fields (Array<Merge::Accounting::RemoteFieldRequest>)

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

Returns:



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

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/expense-reports"
    end
    Merge::Accounting::ExpenseReportResponse.from_json(json_object: response.body)
  end
end

#lines_list(expense_report_id:, cursor: nil, expand: nil, include_deleted_data: nil, include_remote_data: nil, include_remote_fields: nil, include_shell_data: nil, page_size: nil, request_options: nil) ⇒ Merge::Accounting::PaginatedExpenseReportLineList

Returns a list of ‘ExpenseReportLine` objects that point to a `ExpenseReport`

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.expense_reports.lines_list(expense_report_id: "expense_report_id", cursor: "cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw")

Parameters:

  • expense_report_id (String)
  • cursor (String) (defaults to: nil)

    The pagination cursor value.

  • expand (Merge::Accounting::ExpenseReports::ExpenseReportsLinesListRequestExpand) (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)

    Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).

  • include_remote_data (Boolean) (defaults to: nil)

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

  • include_remote_fields (Boolean) (defaults to: nil)

    Whether to include all remote fields, including fields that Merge did not map to common models, in a normalized format.

  • include_shell_data (Boolean) (defaults to: nil)

    Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null).

  • page_size (Integer) (defaults to: nil)

    Number of results to return per page.

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

Returns:



541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 541

def lines_list(expense_report_id:, cursor: nil, expand: nil, include_deleted_data: nil, include_remote_data: nil,
               include_remote_fields: nil, include_shell_data: nil, page_size: 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 || {}),
        "cursor": cursor,
        "expand": expand,
        "include_deleted_data": include_deleted_data,
        "include_remote_data": include_remote_data,
        "include_remote_fields": include_remote_fields,
        "include_shell_data": include_shell_data,
        "page_size": page_size
      }.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/expense-reports/#{expense_report_id}/lines"
    end
    Merge::Accounting::PaginatedExpenseReportLineList.from_json(json_object: response.body)
  end
end

#lines_remote_field_classes_list(cursor: nil, include_deleted_data: nil, include_remote_data: nil, include_shell_data: nil, is_common_model_field: nil, is_custom: nil, page_size: nil, request_options: nil) ⇒ Merge::Accounting::PaginatedRemoteFieldClassList

Returns a list of ‘RemoteFieldClass` objects.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.expense_reports.lines_remote_field_classes_list(cursor: "cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw")

Parameters:

  • cursor (String) (defaults to: nil)

    The pagination cursor value.

  • include_deleted_data (Boolean) (defaults to: nil)

    Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).

  • include_remote_data (Boolean) (defaults to: nil)

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

  • include_shell_data (Boolean) (defaults to: nil)

    Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null).

  • is_common_model_field (Boolean) (defaults to: nil)

    If provided, will only return remote field classes with this is_common_model_field value

  • is_custom (Boolean) (defaults to: nil)

    If provided, will only return remote fields classes with this is_custom value

  • page_size (Integer) (defaults to: nil)

    Number of results to return per page.

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

Returns:



644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 644

def lines_remote_field_classes_list(cursor: nil, include_deleted_data: nil, include_remote_data: nil,
                                    include_shell_data: nil, is_common_model_field: nil, is_custom: nil, page_size: 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 || {}),
        "cursor": cursor,
        "include_deleted_data": include_deleted_data,
        "include_remote_data": include_remote_data,
        "include_shell_data": include_shell_data,
        "is_common_model_field": is_common_model_field,
        "is_custom": is_custom,
        "page_size": page_size
      }.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/expense-reports/lines/remote-field-classes"
    end
    Merge::Accounting::PaginatedRemoteFieldClassList.from_json(json_object: response.body)
  end
end

#list(company_id: nil, created_after: nil, created_before: nil, cursor: nil, expand: nil, include_deleted_data: nil, include_remote_data: nil, include_remote_fields: nil, include_shell_data: nil, modified_after: nil, modified_before: nil, page_size: nil, remote_id: nil, request_options: nil) ⇒ Merge::Accounting::PaginatedExpenseReportList

Returns a list of ‘ExpenseReport` objects.

Examples:

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

Parameters:

  • company_id (String) (defaults to: nil)

    If provided, will only return expense reports for this company.

  • 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::ExpenseReports::ExpenseReportsListRequestExpand) (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)

    Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).

  • include_remote_data (Boolean) (defaults to: nil)

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

  • include_remote_fields (Boolean) (defaults to: nil)

    Whether to include all remote fields, including fields that Merge did not map to common models, in a normalized format.

  • include_shell_data (Boolean) (defaults to: nil)

    Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null).

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

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

Returns:



427
428
429
430
431
432
433
434
435
436
437
438
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/expense_reports/client.rb', line 427

def list(company_id: nil, created_after: nil, created_before: nil, cursor: nil, expand: nil,
         include_deleted_data: nil, include_remote_data: nil, include_remote_fields: nil, include_shell_data: nil, modified_after: nil, modified_before: nil, page_size: nil, remote_id: 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 || {}),
        "company_id": company_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,
        "include_remote_fields": include_remote_fields,
        "include_shell_data": include_shell_data,
        "modified_after": modified_after,
        "modified_before": modified_before,
        "page_size": page_size,
        "remote_id": remote_id
      }.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/expense-reports"
    end
    Merge::Accounting::PaginatedExpenseReportList.from_json(json_object: response.body)
  end
end

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

Returns metadata for ‘ExpenseReport` POSTs.

Examples:

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

Parameters:

Returns:



686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 686

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/expense-reports/meta/post"
    end
    Merge::Accounting::MetaResponse.from_json(json_object: response.body)
  end
end

#remote_field_classes_list(cursor: nil, include_deleted_data: nil, include_remote_data: nil, include_shell_data: nil, is_common_model_field: nil, is_custom: nil, page_size: nil, request_options: nil) ⇒ Merge::Accounting::PaginatedRemoteFieldClassList

Returns a list of ‘RemoteFieldClass` objects.

Examples:

api = Merge::Client.new(
  base_url: "https://api.example.com",
  environment: Merge::Environment::PRODUCTION,
  api_key: "YOUR_AUTH_TOKEN"
)
api.accounting.expense_reports.remote_field_classes_list(cursor: "cD0yMDIxLTAxLTA2KzAzJTNBMjQlM0E1My40MzQzMjYlMkIwMCUzQTAw")

Parameters:

  • cursor (String) (defaults to: nil)

    The pagination cursor value.

  • include_deleted_data (Boolean) (defaults to: nil)

    Indicates whether or not this object has been deleted in the third party platform. Full coverage deletion detection is a premium add-on. Native deletion detection is offered for free with limited coverage. [Learn more](docs.merge.dev/integrations/hris/supported-features/).

  • include_remote_data (Boolean) (defaults to: nil)

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

  • include_shell_data (Boolean) (defaults to: nil)

    Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null).

  • is_common_model_field (Boolean) (defaults to: nil)

    If provided, will only return remote field classes with this is_common_model_field value

  • is_custom (Boolean) (defaults to: nil)

    If provided, will only return remote fields classes with this is_custom value

  • page_size (Integer) (defaults to: nil)

    Number of results to return per page.

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

Returns:



733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 733

def remote_field_classes_list(cursor: nil, include_deleted_data: nil, include_remote_data: nil,
                              include_shell_data: nil, is_common_model_field: nil, is_custom: nil, page_size: 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 || {}),
        "cursor": cursor,
        "include_deleted_data": include_deleted_data,
        "include_remote_data": include_remote_data,
        "include_shell_data": include_shell_data,
        "is_common_model_field": is_common_model_field,
        "is_custom": is_custom,
        "page_size": page_size
      }.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/expense-reports/remote-field-classes"
    end
    Merge::Accounting::PaginatedRemoteFieldClassList.from_json(json_object: response.body)
  end
end

#retrieve(id:, expand: nil, include_remote_data: nil, include_remote_fields: nil, include_shell_data: nil, request_options: nil) ⇒ Merge::Accounting::ExpenseReport

Returns an ‘ExpenseReport` 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.expense_reports.retrieve(id: "id")

Parameters:

  • id (String)
  • expand (Merge::Accounting::ExpenseReports::ExpenseReportsRetrieveRequestExpand) (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.

  • include_remote_fields (Boolean) (defaults to: nil)

    Whether to include all remote fields, including fields that Merge did not map to common models, in a normalized format.

  • include_shell_data (Boolean) (defaults to: nil)

    Whether to include shell records. Shell records are empty records (they may contain some metadata but all other fields are null).

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

Returns:



592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/merge_ruby_client/accounting/expense_reports/client.rb', line 592

def retrieve(id:, expand: nil, include_remote_data: nil, include_remote_fields: nil, include_shell_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,
        "include_remote_fields": include_remote_fields,
        "include_shell_data": include_shell_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/expense-reports/#{id}"
    end
    Merge::Accounting::ExpenseReport.from_json(json_object: response.body)
  end
end