diff --git a/.fernignore b/.fernignore new file mode 100644 index 0000000..084a8eb --- /dev/null +++ b/.fernignore @@ -0,0 +1 @@ +# Specify files that shouldn't be modified by Fern diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..08ea818 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: Publish + +on: [push] +jobs: + publish: + if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') + runs-on: ubuntu-latest + steps: + - name: Checkout repo + uses: actions/checkout@v3 + + - uses: ruby/setup-ruby@v1 + with: + ruby-version: 2.7 + bundler-cache: true + + - name: Test gem + run: bundle install && bundle exec rake test + + - name: Build and Push Gem + env: + GEM_HOST_API_KEY: ${{ secrets.RUBY_GEMS_API_KEY }} + run: | + gem build monite.gemspec + + gem push monite-*.gem --host https://rubygems.org/ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a97c182 --- /dev/null +++ b/.gitignore @@ -0,0 +1,10 @@ +/.bundle/ +/.yardoc +/_yardoc/ +/coverage/ +/doc/ +/pkg/ +/spec/reports/ +/tmp/ +*.gem +.env diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 0000000..c1d2344 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,36 @@ +AllCops: + TargetRubyVersion: 2.7 + +Style/StringLiterals: + Enabled: true + EnforcedStyle: double_quotes + +Style/StringLiteralsInInterpolation: + Enabled: true + EnforcedStyle: double_quotes + +Layout/FirstHashElementLineBreak: + Enabled: true + +Layout/MultilineHashKeyLineBreaks: + Enabled: true + +# Generated files may be more complex than standard, disable +# these rules for now as a known limitation. +Metrics/ParameterLists: + Enabled: false + +Metrics/MethodLength: + Enabled: false + +Metrics/AbcSize: + Enabled: false + +Metrics/ClassLength: + Enabled: false + +Metrics/CyclomaticComplexity: + Enabled: false + +Metrics/PerceivedComplexity: + Enabled: false diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..49bd9cd --- /dev/null +++ b/Gemfile @@ -0,0 +1,9 @@ +# frozen_string_literal: true + +source "https://rubygems.org" + +gemspec + +gem "minitest", "~> 5.0" +gem "rake", "~> 13.0" +gem "rubocop", "~> 1.21" diff --git a/README.md b/README.md index 1eacb5d..e69de29 100644 --- a/README.md +++ b/README.md @@ -1 +0,0 @@ -# monite-ruby-client \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..678615e --- /dev/null +++ b/Rakefile @@ -0,0 +1,11 @@ +# frozen_string_literal: true +require "rake/testtask" +require "rubocop/rake_task" + +task default: %i[test rubocop] + +Rake::TestTask.new do |t| + t.pattern = "./test/**/test_*.rb" +end + +RuboCop::RakeTask.new diff --git a/lib/core/file_utilities.rb b/lib/core/file_utilities.rb new file mode 100644 index 0000000..153583d --- /dev/null +++ b/lib/core/file_utilities.rb @@ -0,0 +1,27 @@ +# frozen_string_literal: true +require "faraday/multipart" +require "mini_mime" + +module Monite +# Utility class for managing files. + class FileUtilities + + + # @param file_like [String, IO] The file to be uploaded, or a string path to the file. + # @return [Faraday::Multipart::FilePart] + def self.as_faraday_multipart(file_like:) + unless file_like.is_a?(String) + path = file_like.path + else + path = file_like + end + mime_type = MiniMime.lookup_by_filename(path) + unless mime_type.nil? + mime_type = mime_type.content_type + else + mime_type = "application/octet-stream" + end + Faraday::Multipart::FilePart.new(file_like, mime_type) + end + end +end \ No newline at end of file diff --git a/lib/environment.rb b/lib/environment.rb new file mode 100644 index 0000000..4822b58 --- /dev/null +++ b/lib/environment.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class Environment + + SANDBOX = "https://api.sandbox.monite.com/v1" + EU_PRODUCTION = "https://api.monite.com/v1" + NA_PRODUCTION = "https://us.api.monite.com/v1" + + end +end \ No newline at end of file diff --git a/lib/gemconfig.rb b/lib/gemconfig.rb new file mode 100644 index 0000000..f3569df --- /dev/null +++ b/lib/gemconfig.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true +module Monite + module Gemconfig + VERSION = "" + AUTHORS = [""].freeze + EMAIL = "" + SUMMARY = "" + DESCRIPTION = "" + HOMEPAGE = "https://github.com/team-monite/monite-ruby-client" + SOURCE_CODE_URI = "https://github.com/team-monite/monite-ruby-client" + CHANGELOG_URI = "https://github.com/team-monite/monite-ruby-client/blob/master/CHANGELOG.md" + end +end \ No newline at end of file diff --git a/lib/monite.rb b/lib/monite.rb new file mode 100644 index 0000000..a9701e1 --- /dev/null +++ b/lib/monite.rb @@ -0,0 +1,328 @@ +# frozen_string_literal: true +require_relative "environment" +require_relative "types_export" +require_relative "requests" +require_relative "monite/analytics/client" +require_relative "monite/approval_policies/client" +require_relative "monite/approval_requests/client" +require_relative "monite/access_tokens/client" +require_relative "monite/comments/client" +require_relative "monite/counterparts/client" +require_relative "monite/data_exports/client" +require_relative "monite/pdf_templates/client" +require_relative "monite/e_invoicing_connections/client" +require_relative "monite/entities/client" +require_relative "monite/entity_users/client" +require_relative "monite/events/client" +require_relative "monite/files/client" +require_relative "monite/financing/client" +require_relative "monite/mail_templates/client" +require_relative "monite/mailbox_domains/client" +require_relative "monite/mailboxes/client" +require_relative "monite/measure_units/client" +require_relative "monite/overdue_reminders/client" +require_relative "monite/credit_notes/client" +require_relative "monite/purchase_orders/client" +require_relative "monite/payables/client" +require_relative "monite/payment_intents/client" +require_relative "monite/payment_links/client" +require_relative "monite/payment_records/client" +require_relative "monite/payment_reminders/client" +require_relative "monite/payment_terms/client" +require_relative "monite/products/client" +require_relative "monite/projects/client" +require_relative "monite/receivables/client" +require_relative "monite/recurrences/client" +require_relative "monite/roles/client" +require_relative "monite/partner_settings/client" +require_relative "monite/tags/client" +require_relative "monite/text_templates/client" +require_relative "monite/vat_rates/client" +require_relative "monite/webhook_deliveries/client" +require_relative "monite/webhook_subscriptions/client" +require_relative "monite/accounting/client" +require_relative "requests" +require_relative "monite/accounting/client" + +module Monite + class Client + # @return [Monite::AnalyticsClient] + attr_reader :analytics + # @return [Monite::ApprovalPoliciesClient] + attr_reader :approval_policies + # @return [Monite::ApprovalRequestsClient] + attr_reader :approval_requests + # @return [Monite::AccessTokensClient] + attr_reader :access_tokens + # @return [Monite::CommentsClient] + attr_reader :comments + # @return [Monite::CounterpartsClient] + attr_reader :counterparts + # @return [Monite::DataExportsClient] + attr_reader :data_exports + # @return [Monite::PdfTemplatesClient] + attr_reader :pdf_templates + # @return [Monite::EInvoicingConnectionsClient] + attr_reader :e_invoicing_connections + # @return [Monite::EntitiesClient] + attr_reader :entities + # @return [Monite::EntityUsersClient] + attr_reader :entity_users + # @return [Monite::EventsClient] + attr_reader :events + # @return [Monite::FilesClient] + attr_reader :files + # @return [Monite::FinancingClient] + attr_reader :financing + # @return [Monite::MailTemplatesClient] + attr_reader :mail_templates + # @return [Monite::MailboxDomainsClient] + attr_reader :mailbox_domains + # @return [Monite::MailboxesClient] + attr_reader :mailboxes + # @return [Monite::MeasureUnitsClient] + attr_reader :measure_units + # @return [Monite::OverdueRemindersClient] + attr_reader :overdue_reminders + # @return [Monite::CreditNotesClient] + attr_reader :credit_notes + # @return [Monite::PurchaseOrdersClient] + attr_reader :purchase_orders + # @return [Monite::PayablesClient] + attr_reader :payables + # @return [Monite::PaymentIntentsClient] + attr_reader :payment_intents + # @return [Monite::PaymentLinksClient] + attr_reader :payment_links + # @return [Monite::PaymentRecordsClient] + attr_reader :payment_records + # @return [Monite::PaymentRemindersClient] + attr_reader :payment_reminders + # @return [Monite::PaymentTermsClient] + attr_reader :payment_terms + # @return [Monite::ProductsClient] + attr_reader :products + # @return [Monite::ProjectsClient] + attr_reader :projects + # @return [Monite::ReceivablesClient] + attr_reader :receivables + # @return [Monite::RecurrencesClient] + attr_reader :recurrences + # @return [Monite::RolesClient] + attr_reader :roles + # @return [Monite::PartnerSettingsClient] + attr_reader :partner_settings + # @return [Monite::TagsClient] + attr_reader :tags + # @return [Monite::TextTemplatesClient] + attr_reader :text_templates + # @return [Monite::VatRatesClient] + attr_reader :vat_rates + # @return [Monite::WebhookDeliveriesClient] + attr_reader :webhook_deliveries + # @return [Monite::WebhookSubscriptionsClient] + attr_reader :webhook_subscriptions + # @return [Monite::Accounting::Client] + attr_reader :accounting + + + # @param base_url [String] + # @param environment [Monite::Environment] + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. + # @param timeout_in_seconds [Long] + # @param token [String] + # @param monite_version [String] + # @param monite_entity_id [String] The ID of the entity that owns the requested resource. + # @return [Monite::Client] + def initialize(base_url: nil, environment: Monite::Environment::SANDBOX, max_retries: nil, timeout_in_seconds: nil, token:, monite_version:, monite_entity_id: nil) + @request_client = Monite::RequestClient.new( + base_url: base_url, + environment: environment, + max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, + token: token, + monite_version: monite_version, + monite_entity_id: monite_entity_id +) + @analytics = Monite::AnalyticsClient.new(request_client: @request_client) + @approval_policies = Monite::ApprovalPoliciesClient.new(request_client: @request_client) + @approval_requests = Monite::ApprovalRequestsClient.new(request_client: @request_client) + @access_tokens = Monite::AccessTokensClient.new(request_client: @request_client) + @comments = Monite::CommentsClient.new(request_client: @request_client) + @counterparts = Monite::CounterpartsClient.new(request_client: @request_client) + @data_exports = Monite::DataExportsClient.new(request_client: @request_client) + @pdf_templates = Monite::PdfTemplatesClient.new(request_client: @request_client) + @e_invoicing_connections = Monite::EInvoicingConnectionsClient.new(request_client: @request_client) + @entities = Monite::EntitiesClient.new(request_client: @request_client) + @entity_users = Monite::EntityUsersClient.new(request_client: @request_client) + @events = Monite::EventsClient.new(request_client: @request_client) + @files = Monite::FilesClient.new(request_client: @request_client) + @financing = Monite::FinancingClient.new(request_client: @request_client) + @mail_templates = Monite::MailTemplatesClient.new(request_client: @request_client) + @mailbox_domains = Monite::MailboxDomainsClient.new(request_client: @request_client) + @mailboxes = Monite::MailboxesClient.new(request_client: @request_client) + @measure_units = Monite::MeasureUnitsClient.new(request_client: @request_client) + @overdue_reminders = Monite::OverdueRemindersClient.new(request_client: @request_client) + @credit_notes = Monite::CreditNotesClient.new(request_client: @request_client) + @purchase_orders = Monite::PurchaseOrdersClient.new(request_client: @request_client) + @payables = Monite::PayablesClient.new(request_client: @request_client) + @payment_intents = Monite::PaymentIntentsClient.new(request_client: @request_client) + @payment_links = Monite::PaymentLinksClient.new(request_client: @request_client) + @payment_records = Monite::PaymentRecordsClient.new(request_client: @request_client) + @payment_reminders = Monite::PaymentRemindersClient.new(request_client: @request_client) + @payment_terms = Monite::PaymentTermsClient.new(request_client: @request_client) + @products = Monite::ProductsClient.new(request_client: @request_client) + @projects = Monite::ProjectsClient.new(request_client: @request_client) + @receivables = Monite::ReceivablesClient.new(request_client: @request_client) + @recurrences = Monite::RecurrencesClient.new(request_client: @request_client) + @roles = Monite::RolesClient.new(request_client: @request_client) + @partner_settings = Monite::PartnerSettingsClient.new(request_client: @request_client) + @tags = Monite::TagsClient.new(request_client: @request_client) + @text_templates = Monite::TextTemplatesClient.new(request_client: @request_client) + @vat_rates = Monite::VatRatesClient.new(request_client: @request_client) + @webhook_deliveries = Monite::WebhookDeliveriesClient.new(request_client: @request_client) + @webhook_subscriptions = Monite::WebhookSubscriptionsClient.new(request_client: @request_client) + @accounting = Monite::Accounting::Client.new(request_client: @request_client) + end + end + class AsyncClient + # @return [Monite::AsyncAnalyticsClient] + attr_reader :analytics + # @return [Monite::AsyncApprovalPoliciesClient] + attr_reader :approval_policies + # @return [Monite::AsyncApprovalRequestsClient] + attr_reader :approval_requests + # @return [Monite::AsyncAccessTokensClient] + attr_reader :access_tokens + # @return [Monite::AsyncCommentsClient] + attr_reader :comments + # @return [Monite::AsyncCounterpartsClient] + attr_reader :counterparts + # @return [Monite::AsyncDataExportsClient] + attr_reader :data_exports + # @return [Monite::AsyncPdfTemplatesClient] + attr_reader :pdf_templates + # @return [Monite::AsyncEInvoicingConnectionsClient] + attr_reader :e_invoicing_connections + # @return [Monite::AsyncEntitiesClient] + attr_reader :entities + # @return [Monite::AsyncEntityUsersClient] + attr_reader :entity_users + # @return [Monite::AsyncEventsClient] + attr_reader :events + # @return [Monite::AsyncFilesClient] + attr_reader :files + # @return [Monite::AsyncFinancingClient] + attr_reader :financing + # @return [Monite::AsyncMailTemplatesClient] + attr_reader :mail_templates + # @return [Monite::AsyncMailboxDomainsClient] + attr_reader :mailbox_domains + # @return [Monite::AsyncMailboxesClient] + attr_reader :mailboxes + # @return [Monite::AsyncMeasureUnitsClient] + attr_reader :measure_units + # @return [Monite::AsyncOverdueRemindersClient] + attr_reader :overdue_reminders + # @return [Monite::AsyncCreditNotesClient] + attr_reader :credit_notes + # @return [Monite::AsyncPurchaseOrdersClient] + attr_reader :purchase_orders + # @return [Monite::AsyncPayablesClient] + attr_reader :payables + # @return [Monite::AsyncPaymentIntentsClient] + attr_reader :payment_intents + # @return [Monite::AsyncPaymentLinksClient] + attr_reader :payment_links + # @return [Monite::AsyncPaymentRecordsClient] + attr_reader :payment_records + # @return [Monite::AsyncPaymentRemindersClient] + attr_reader :payment_reminders + # @return [Monite::AsyncPaymentTermsClient] + attr_reader :payment_terms + # @return [Monite::AsyncProductsClient] + attr_reader :products + # @return [Monite::AsyncProjectsClient] + attr_reader :projects + # @return [Monite::AsyncReceivablesClient] + attr_reader :receivables + # @return [Monite::AsyncRecurrencesClient] + attr_reader :recurrences + # @return [Monite::AsyncRolesClient] + attr_reader :roles + # @return [Monite::AsyncPartnerSettingsClient] + attr_reader :partner_settings + # @return [Monite::AsyncTagsClient] + attr_reader :tags + # @return [Monite::AsyncTextTemplatesClient] + attr_reader :text_templates + # @return [Monite::AsyncVatRatesClient] + attr_reader :vat_rates + # @return [Monite::AsyncWebhookDeliveriesClient] + attr_reader :webhook_deliveries + # @return [Monite::AsyncWebhookSubscriptionsClient] + attr_reader :webhook_subscriptions + # @return [Monite::Accounting::AsyncClient] + attr_reader :accounting + + + # @param base_url [String] + # @param environment [Monite::Environment] + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. + # @param timeout_in_seconds [Long] + # @param token [String] + # @param monite_version [String] + # @param monite_entity_id [String] The ID of the entity that owns the requested resource. + # @return [Monite::AsyncClient] + def initialize(base_url: nil, environment: Monite::Environment::SANDBOX, max_retries: nil, timeout_in_seconds: nil, token:, monite_version:, monite_entity_id: nil) + @async_request_client = Monite::AsyncRequestClient.new( + base_url: base_url, + environment: environment, + max_retries: max_retries, + timeout_in_seconds: timeout_in_seconds, + token: token, + monite_version: monite_version, + monite_entity_id: monite_entity_id +) + @analytics = Monite::AsyncAnalyticsClient.new(request_client: @async_request_client) + @approval_policies = Monite::AsyncApprovalPoliciesClient.new(request_client: @async_request_client) + @approval_requests = Monite::AsyncApprovalRequestsClient.new(request_client: @async_request_client) + @access_tokens = Monite::AsyncAccessTokensClient.new(request_client: @async_request_client) + @comments = Monite::AsyncCommentsClient.new(request_client: @async_request_client) + @counterparts = Monite::AsyncCounterpartsClient.new(request_client: @async_request_client) + @data_exports = Monite::AsyncDataExportsClient.new(request_client: @async_request_client) + @pdf_templates = Monite::AsyncPdfTemplatesClient.new(request_client: @async_request_client) + @e_invoicing_connections = Monite::AsyncEInvoicingConnectionsClient.new(request_client: @async_request_client) + @entities = Monite::AsyncEntitiesClient.new(request_client: @async_request_client) + @entity_users = Monite::AsyncEntityUsersClient.new(request_client: @async_request_client) + @events = Monite::AsyncEventsClient.new(request_client: @async_request_client) + @files = Monite::AsyncFilesClient.new(request_client: @async_request_client) + @financing = Monite::AsyncFinancingClient.new(request_client: @async_request_client) + @mail_templates = Monite::AsyncMailTemplatesClient.new(request_client: @async_request_client) + @mailbox_domains = Monite::AsyncMailboxDomainsClient.new(request_client: @async_request_client) + @mailboxes = Monite::AsyncMailboxesClient.new(request_client: @async_request_client) + @measure_units = Monite::AsyncMeasureUnitsClient.new(request_client: @async_request_client) + @overdue_reminders = Monite::AsyncOverdueRemindersClient.new(request_client: @async_request_client) + @credit_notes = Monite::AsyncCreditNotesClient.new(request_client: @async_request_client) + @purchase_orders = Monite::AsyncPurchaseOrdersClient.new(request_client: @async_request_client) + @payables = Monite::AsyncPayablesClient.new(request_client: @async_request_client) + @payment_intents = Monite::AsyncPaymentIntentsClient.new(request_client: @async_request_client) + @payment_links = Monite::AsyncPaymentLinksClient.new(request_client: @async_request_client) + @payment_records = Monite::AsyncPaymentRecordsClient.new(request_client: @async_request_client) + @payment_reminders = Monite::AsyncPaymentRemindersClient.new(request_client: @async_request_client) + @payment_terms = Monite::AsyncPaymentTermsClient.new(request_client: @async_request_client) + @products = Monite::AsyncProductsClient.new(request_client: @async_request_client) + @projects = Monite::AsyncProjectsClient.new(request_client: @async_request_client) + @receivables = Monite::AsyncReceivablesClient.new(request_client: @async_request_client) + @recurrences = Monite::AsyncRecurrencesClient.new(request_client: @async_request_client) + @roles = Monite::AsyncRolesClient.new(request_client: @async_request_client) + @partner_settings = Monite::AsyncPartnerSettingsClient.new(request_client: @async_request_client) + @tags = Monite::AsyncTagsClient.new(request_client: @async_request_client) + @text_templates = Monite::AsyncTextTemplatesClient.new(request_client: @async_request_client) + @vat_rates = Monite::AsyncVatRatesClient.new(request_client: @async_request_client) + @webhook_deliveries = Monite::AsyncWebhookDeliveriesClient.new(request_client: @async_request_client) + @webhook_subscriptions = Monite::AsyncWebhookSubscriptionsClient.new(request_client: @async_request_client) + @accounting = Monite::Accounting::AsyncClient.new(request_client: @async_request_client) + end + end +end \ No newline at end of file diff --git a/lib/monite/access_tokens/client.rb b/lib/monite/access_tokens/client.rb new file mode 100644 index 0000000..e72a1f6 --- /dev/null +++ b/lib/monite/access_tokens/client.rb @@ -0,0 +1,207 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/message_response" +require_relative "../types/grant_type" +require_relative "../types/access_token_response" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class AccessTokensClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AccessTokensClient] + def initialize(request_client:) + @request_client = request_client + end +# Revoke an existing token immediately. + # + # @param client_id [String] + # @param client_secret [String] + # @param token [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::MessageResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.access_tokens.revoke( +# client_id: "client_id", +# client_secret: "client_secret", +# token: "token" +# ) + def revoke(client_id:, client_secret:, token:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), client_id: client_id, client_secret: client_secret, token: token }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/auth/revoke" +end + Monite::MessageResponse.from_json(json_object: response.body) + end +# Create a new access token based on client ID and client secret. + # + # @param client_id [String] + # @param client_secret [String] + # @param entity_user_id [String] + # @param grant_type [Monite::GrantType] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccessTokenResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.access_tokens.create( +# client_id: "client_id", +# client_secret: "client_secret", +# grant_type: CLIENT_CREDENTIALS +# ) + def create(client_id:, client_secret:, entity_user_id: nil, grant_type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), client_id: client_id, client_secret: client_secret, entity_user_id: entity_user_id, grant_type: grant_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/auth/token" +end + Monite::AccessTokenResponse.from_json(json_object: response.body) + end + end + class AsyncAccessTokensClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncAccessTokensClient] + def initialize(request_client:) + @request_client = request_client + end +# Revoke an existing token immediately. + # + # @param client_id [String] + # @param client_secret [String] + # @param token [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::MessageResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.access_tokens.revoke( +# client_id: "client_id", +# client_secret: "client_secret", +# token: "token" +# ) + def revoke(client_id:, client_secret:, token:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), client_id: client_id, client_secret: client_secret, token: token }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/auth/revoke" +end + Monite::MessageResponse.from_json(json_object: response.body) + end + end +# Create a new access token based on client ID and client secret. + # + # @param client_id [String] + # @param client_secret [String] + # @param entity_user_id [String] + # @param grant_type [Monite::GrantType] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccessTokenResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.access_tokens.create( +# client_id: "client_id", +# client_secret: "client_secret", +# grant_type: CLIENT_CREDENTIALS +# ) + def create(client_id:, client_secret:, entity_user_id: nil, grant_type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), client_id: client_id, client_secret: client_secret, entity_user_id: entity_user_id, grant_type: grant_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/auth/token" +end + Monite::AccessTokenResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/client.rb b/lib/monite/accounting/client.rb new file mode 100644 index 0000000..aa57da6 --- /dev/null +++ b/lib/monite/accounting/client.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "payables/client" +require_relative "receivables/client" +require_relative "connections/client" +require_relative "synced_records/client" +require_relative "tax_rates/client" +require_relative "ledger_accounts/client" +require_relative "../../requests" + +module Monite + module Accounting + class Client + # @return [Monite::Accounting::PayablesClient] + attr_reader :payables + # @return [Monite::Accounting::ReceivablesClient] + attr_reader :receivables + # @return [Monite::Accounting::ConnectionsClient] + attr_reader :connections + # @return [Monite::Accounting::SyncedRecordsClient] + attr_reader :synced_records + # @return [Monite::Accounting::TaxRatesClient] + attr_reader :tax_rates + # @return [Monite::Accounting::LedgerAccountsClient] + attr_reader :ledger_accounts + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::Client] + def initialize(request_client:) + @payables = Monite::Accounting::PayablesClient.new(request_client: request_client) + @receivables = Monite::Accounting::ReceivablesClient.new(request_client: request_client) + @connections = Monite::Accounting::ConnectionsClient.new(request_client: request_client) + @synced_records = Monite::Accounting::SyncedRecordsClient.new(request_client: request_client) + @tax_rates = Monite::Accounting::TaxRatesClient.new(request_client: request_client) + @ledger_accounts = Monite::Accounting::LedgerAccountsClient.new(request_client: request_client) + end + end + class AsyncClient + # @return [Monite::Accounting::AsyncPayablesClient] + attr_reader :payables + # @return [Monite::Accounting::AsyncReceivablesClient] + attr_reader :receivables + # @return [Monite::Accounting::AsyncConnectionsClient] + attr_reader :connections + # @return [Monite::Accounting::AsyncSyncedRecordsClient] + attr_reader :synced_records + # @return [Monite::Accounting::AsyncTaxRatesClient] + attr_reader :tax_rates + # @return [Monite::Accounting::AsyncLedgerAccountsClient] + attr_reader :ledger_accounts + + + # @param request_client [Monite::AsyncRequestClient] + # @return [Monite::Accounting::AsyncClient] + def initialize(request_client:) + @payables = Monite::Accounting::AsyncPayablesClient.new(request_client: request_client) + @receivables = Monite::Accounting::AsyncReceivablesClient.new(request_client: request_client) + @connections = Monite::Accounting::AsyncConnectionsClient.new(request_client: request_client) + @synced_records = Monite::Accounting::AsyncSyncedRecordsClient.new(request_client: request_client) + @tax_rates = Monite::Accounting::AsyncTaxRatesClient.new(request_client: request_client) + @ledger_accounts = Monite::Accounting::AsyncLedgerAccountsClient.new(request_client: request_client) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/connections/client.rb b/lib/monite/accounting/connections/client.rb new file mode 100644 index 0000000..bfbba4a --- /dev/null +++ b/lib/monite/accounting/connections/client.rb @@ -0,0 +1,420 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/accounting_connection_list" +require_relative "../../types/accounting_connection_response" +require_relative "../../types/accounting_message_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Accounting + class ConnectionsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::ConnectionsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all connections + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections" +end + Monite::AccountingConnectionList.from_json(json_object: response.body) + end +# Create new connection + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.create + def create(request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections" +end + Monite::AccountingConnectionResponse.from_json(json_object: response.body) + end +# Get connection by id + # + # @param connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.get_by_id(connection_id: "connection_id") + def get_by_id(connection_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections/#{connection_id}" +end + Monite::AccountingConnectionResponse.from_json(json_object: response.body) + end +# Disconnect + # + # @param connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.disconnect_by_id(connection_id: "connection_id") + def disconnect_by_id(connection_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections/#{connection_id}/disconnect" +end + Monite::AccountingConnectionResponse.from_json(json_object: response.body) + end + # @param connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingMessageResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.sync_by_id(connection_id: "connection_id") + def sync_by_id(connection_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections/#{connection_id}/sync" +end + Monite::AccountingMessageResponse.from_json(json_object: response.body) + end + end + class AsyncConnectionsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::AsyncConnectionsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all connections + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections" +end + Monite::AccountingConnectionList.from_json(json_object: response.body) + end + end +# Create new connection + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.create + def create(request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections" +end + Monite::AccountingConnectionResponse.from_json(json_object: response.body) + end + end +# Get connection by id + # + # @param connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.get_by_id(connection_id: "connection_id") + def get_by_id(connection_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections/#{connection_id}" +end + Monite::AccountingConnectionResponse.from_json(json_object: response.body) + end + end +# Disconnect + # + # @param connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.disconnect_by_id(connection_id: "connection_id") + def disconnect_by_id(connection_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections/#{connection_id}/disconnect" +end + Monite::AccountingConnectionResponse.from_json(json_object: response.body) + end + end + # @param connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingMessageResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.connections.sync_by_id(connection_id: "connection_id") + def sync_by_id(connection_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_connections/#{connection_id}/sync" +end + Monite::AccountingMessageResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/ledger_accounts/client.rb b/lib/monite/accounting/ledger_accounts/client.rb new file mode 100644 index 0000000..dc70c87 --- /dev/null +++ b/lib/monite/accounting/ledger_accounts/client.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/order_enum" +require_relative "../../types/ledger_account_cursor_fields" +require_relative "../../types/ledger_account_list_response" +require_relative "../../types/ledger_account_response" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Accounting + class LedgerAccountsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::LedgerAccountsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all ledger accounts + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::LEDGER_ACCOUNT_CURSOR_FIELDS] Allowed sort fields + # @param request_options [Monite::RequestOptions] + # @return [Monite::LedgerAccountListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.ledger_accounts.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort }.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)}/ledger_accounts" +end + Monite::LedgerAccountListResponse.from_json(json_object: response.body) + end +# Get ledger account by id + # + # @param ledger_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::LedgerAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.ledger_accounts.get_by_id(ledger_account_id: "ledger_account_id") + def get_by_id(ledger_account_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/ledger_accounts/#{ledger_account_id}" +end + Monite::LedgerAccountResponse.from_json(json_object: response.body) + end + end + class AsyncLedgerAccountsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::AsyncLedgerAccountsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all ledger accounts + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::LEDGER_ACCOUNT_CURSOR_FIELDS] Allowed sort fields + # @param request_options [Monite::RequestOptions] + # @return [Monite::LedgerAccountListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.ledger_accounts.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort }.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)}/ledger_accounts" +end + Monite::LedgerAccountListResponse.from_json(json_object: response.body) + end + end +# Get ledger account by id + # + # @param ledger_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::LedgerAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.ledger_accounts.get_by_id(ledger_account_id: "ledger_account_id") + def get_by_id(ledger_account_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/ledger_accounts/#{ledger_account_id}" +end + Monite::LedgerAccountResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/payables/client.rb b/lib/monite/accounting/payables/client.rb new file mode 100644 index 0000000..6bde62f --- /dev/null +++ b/lib/monite/accounting/payables/client.rb @@ -0,0 +1,220 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/accounting_payable_list" +require_relative "../../types/accounting_payable" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Accounting + class PayablesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::PayablesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of accounts payable invoices (bills) that exist in the entity's +# accounting system. This requires that an accounting connection has been +# previously established. Refer to the [Accounting integration +# guide](https://docs.monite.com/accounting/integration/index) for details. +# This endpoint only provides read-only access to the accounting system's data but +# does not pull those payables into Monite. You can use it to review the data in +# the accounting system and find out which of those payables already exist or do +# not exist in Monite. +# Data is actual as of the date and time of the last accounting synchronization, +# which is specified by the `last_pull` value in the response from `GET +# /accounting_connections/{connection_id}`. To make sure you are accessing the +# most up-to-date accounting data, you can use `POST +# /accounting_connections/{connection_id}/sync` to trigger on-demand +# synchronization before getting the list of payables. + # + # @param limit [Integer] Number of results per page. + # @param offset [Integer] Number of results to skip before selecting items to return. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingPayableList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.payables.get + def get(limit: nil, offset: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "offset": offset }.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/payables" +end + Monite::AccountingPayableList.from_json(json_object: response.body) + end +# Returns information about an individual payable invoice (bill) that exists in +# the entity's accounting system. This payable may or may not also exist in +# Monite. + # + # @param payable_id [String] An internal ID of the payable invoice (bill) in the accounting system. You can +# get these IDs from `GET /accounting/payables`. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingPayable] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.payables.get_by_id(payable_id: "payable_id") + def get_by_id(payable_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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/payables/#{payable_id}" +end + Monite::AccountingPayable.from_json(json_object: response.body) + end + end + class AsyncPayablesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::AsyncPayablesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of accounts payable invoices (bills) that exist in the entity's +# accounting system. This requires that an accounting connection has been +# previously established. Refer to the [Accounting integration +# guide](https://docs.monite.com/accounting/integration/index) for details. +# This endpoint only provides read-only access to the accounting system's data but +# does not pull those payables into Monite. You can use it to review the data in +# the accounting system and find out which of those payables already exist or do +# not exist in Monite. +# Data is actual as of the date and time of the last accounting synchronization, +# which is specified by the `last_pull` value in the response from `GET +# /accounting_connections/{connection_id}`. To make sure you are accessing the +# most up-to-date accounting data, you can use `POST +# /accounting_connections/{connection_id}/sync` to trigger on-demand +# synchronization before getting the list of payables. + # + # @param limit [Integer] Number of results per page. + # @param offset [Integer] Number of results to skip before selecting items to return. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingPayableList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.payables.get + def get(limit: nil, offset: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "offset": offset }.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/payables" +end + Monite::AccountingPayableList.from_json(json_object: response.body) + end + end +# Returns information about an individual payable invoice (bill) that exists in +# the entity's accounting system. This payable may or may not also exist in +# Monite. + # + # @param payable_id [String] An internal ID of the payable invoice (bill) in the accounting system. You can +# get these IDs from `GET /accounting/payables`. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingPayable] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.payables.get_by_id(payable_id: "payable_id") + def get_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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/payables/#{payable_id}" +end + Monite::AccountingPayable.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/receivables/client.rb b/lib/monite/accounting/receivables/client.rb new file mode 100644 index 0000000..c318ff0 --- /dev/null +++ b/lib/monite/accounting/receivables/client.rb @@ -0,0 +1,218 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/accounting_receivable_list" +require_relative "../../types/accounting_receivable" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Accounting + class ReceivablesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::ReceivablesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of invoices that exist in the entity's accounting system. This +# requires that an accounting connection has been previously established. Refer to +# the [Accounting integration +# guide](https://docs.monite.com/accounting/integration/index) for details. +# This endpoint only provides read-only access to the accounting system's data but +# does not pull those invoices into Monite. You can use it to review the data in +# the accounting system and find out which of those invoices already exist or do +# not exist in Monite. +# Data is actual as of the date and time of the last accounting synchronization, +# which is specified by the `last_pull` value in the response from `GET +# /accounting_connections/{connection_id}`. To make sure you are accessing the +# most up-to-date accounting data, you can use `POST +# /accounting_connections/{connection_id}/sync` to trigger on-demand +# synchronization before getting the invoice list. + # + # @param limit [Integer] Number of results per page. + # @param offset [Integer] Number of results to skip before selecting items to return. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingReceivableList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.receivables.get + def get(limit: nil, offset: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "offset": offset }.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/receivables" +end + Monite::AccountingReceivableList.from_json(json_object: response.body) + end +# Returns information about an individual invoice that exists in the entity's +# accounting system. This invoice may or may not also exist in Monite. + # + # @param invoice_id [String] An internal ID of the invoice in the accounting system. You can get these IDs +# from `GET /accounting/receivables`. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingReceivable] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.receivables.get_by_id(invoice_id: "invoice_id") + def get_by_id(invoice_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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/receivables/#{invoice_id}" +end + Monite::AccountingReceivable.from_json(json_object: response.body) + end + end + class AsyncReceivablesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::AsyncReceivablesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of invoices that exist in the entity's accounting system. This +# requires that an accounting connection has been previously established. Refer to +# the [Accounting integration +# guide](https://docs.monite.com/accounting/integration/index) for details. +# This endpoint only provides read-only access to the accounting system's data but +# does not pull those invoices into Monite. You can use it to review the data in +# the accounting system and find out which of those invoices already exist or do +# not exist in Monite. +# Data is actual as of the date and time of the last accounting synchronization, +# which is specified by the `last_pull` value in the response from `GET +# /accounting_connections/{connection_id}`. To make sure you are accessing the +# most up-to-date accounting data, you can use `POST +# /accounting_connections/{connection_id}/sync` to trigger on-demand +# synchronization before getting the invoice list. + # + # @param limit [Integer] Number of results per page. + # @param offset [Integer] Number of results to skip before selecting items to return. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingReceivableList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.receivables.get + def get(limit: nil, offset: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "limit": limit, "offset": offset }.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/receivables" +end + Monite::AccountingReceivableList.from_json(json_object: response.body) + end + end +# Returns information about an individual invoice that exists in the entity's +# accounting system. This invoice may or may not also exist in Monite. + # + # @param invoice_id [String] An internal ID of the invoice in the accounting system. You can get these IDs +# from `GET /accounting/receivables`. + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingReceivable] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.receivables.get_by_id(invoice_id: "invoice_id") + def get_by_id(invoice_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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/receivables/#{invoice_id}" +end + Monite::AccountingReceivable.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/synced_records/client.rb b/lib/monite/accounting/synced_records/client.rb new file mode 100644 index 0000000..0ea75ab --- /dev/null +++ b/lib/monite/accounting/synced_records/client.rb @@ -0,0 +1,304 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/object_match_types" +require_relative "../../types/order_enum" +require_relative "../../types/sync_record_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../../types/sync_record_resource_list" +require_relative "../../types/sync_record_resource" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Accounting + class SyncedRecordsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::SyncedRecordsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get synchronized records + # + # @param object_type [Monite::ObjectMatchTypes] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::SyncRecordCursorFields] Allowed sort fields + # @param object_id [String] + # @param object_id_in [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::SyncRecordResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.synced_records.get(object_type: PRODUCT) + def get(object_type:, order: nil, limit: nil, pagination_token: nil, sort: nil, object_id: nil, object_id_in: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "object_type": object_type, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_id": object_id, "object_id__in": object_id_in, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte }.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_synced_records" +end + Monite::SyncRecordResourceList.from_json(json_object: response.body) + end +# Get synchronized record by id + # + # @param synced_record_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::SyncRecordResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.synced_records.get_by_id(synced_record_id: "synced_record_id") + def get_by_id(synced_record_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_synced_records/#{synced_record_id}" +end + Monite::SyncRecordResource.from_json(json_object: response.body) + end +# Push object to the accounting system manually + # + # @param synced_record_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::SyncRecordResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.synced_records.push_by_id(synced_record_id: "synced_record_id") + def push_by_id(synced_record_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_synced_records/#{synced_record_id}/push" +end + Monite::SyncRecordResource.from_json(json_object: response.body) + end + end + class AsyncSyncedRecordsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::AsyncSyncedRecordsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get synchronized records + # + # @param object_type [Monite::ObjectMatchTypes] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::SyncRecordCursorFields] Allowed sort fields + # @param object_id [String] + # @param object_id_in [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::SyncRecordResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.synced_records.get(object_type: PRODUCT) + def get(object_type:, order: nil, limit: nil, pagination_token: nil, sort: nil, object_id: nil, object_id_in: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "object_type": object_type, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_id": object_id, "object_id__in": object_id_in, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte }.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_synced_records" +end + Monite::SyncRecordResourceList.from_json(json_object: response.body) + end + end +# Get synchronized record by id + # + # @param synced_record_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::SyncRecordResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.synced_records.get_by_id(synced_record_id: "synced_record_id") + def get_by_id(synced_record_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_synced_records/#{synced_record_id}" +end + Monite::SyncRecordResource.from_json(json_object: response.body) + end + end +# Push object to the accounting system manually + # + # @param synced_record_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::SyncRecordResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.synced_records.push_by_id(synced_record_id: "synced_record_id") + def push_by_id(synced_record_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_synced_records/#{synced_record_id}/push" +end + Monite::SyncRecordResource.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/accounting/tax_rates/client.rb b/lib/monite/accounting/tax_rates/client.rb new file mode 100644 index 0000000..87a6d9b --- /dev/null +++ b/lib/monite/accounting/tax_rates/client.rb @@ -0,0 +1,194 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/order_enum" +require_relative "../../types/tax_rate_account_cursor_fields" +require_relative "../../types/accounting_tax_rate_list_response" +require_relative "../../types/accounting_tax_rate_response" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Accounting + class TaxRatesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::TaxRatesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all tax rate accounts + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::TAX_RATE_ACCOUNT_CURSOR_FIELDS] Allowed sort fields + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingTaxRateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.tax_rates.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort }.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_tax_rates" +end + Monite::AccountingTaxRateListResponse.from_json(json_object: response.body) + end +# Get tax rate account by id + # + # @param tax_rate_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingTaxRateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.tax_rates.get_by_id(tax_rate_id: "tax_rate_id") + def get_by_id(tax_rate_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_tax_rates/#{tax_rate_id}" +end + Monite::AccountingTaxRateResponse.from_json(json_object: response.body) + end + end + class AsyncTaxRatesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Accounting::AsyncTaxRatesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all tax rate accounts + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::TAX_RATE_ACCOUNT_CURSOR_FIELDS] Allowed sort fields + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingTaxRateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.tax_rates.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort }.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_tax_rates" +end + Monite::AccountingTaxRateListResponse.from_json(json_object: response.body) + end + end +# Get tax rate account by id + # + # @param tax_rate_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AccountingTaxRateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.accounting.tax_rates.get_by_id(tax_rate_id: "tax_rate_id") + def get_by_id(tax_rate_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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_tax_rates/#{tax_rate_id}" +end + Monite::AccountingTaxRateResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/analytics/client.rb b/lib/monite/analytics/client.rb new file mode 100644 index 0000000..a8e1d85 --- /dev/null +++ b/lib/monite/analytics/client.rb @@ -0,0 +1,414 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/credit_note_dimension_enum" +require_relative "../types/credit_note_metric_enum" +require_relative "../types/aggregation_function_enum" +require_relative "../types/date_dimension_breakdown_enum" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/credit_note_state_enum" +require_relative "../types/currency_enum" +require_relative "../types/payable_analytics_response" +require_relative "../types/payable_dimension_enum" +require_relative "../types/payable_metric_enum" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/payable_state_enum" +require_relative "../types/source_of_payable_data_enum" +require_relative "../types/ocr_status_enum" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class AnalyticsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AnalyticsClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve aggregated statistics for payables with different breakdowns. + # + # @param dimension [Monite::CreditNoteDimensionEnum] + # @param metric [Monite::CreditNoteMetricEnum] + # @param aggregation_function [Monite::AggregationFunctionEnum] + # @param date_dimension_breakdown [Monite::DateDimensionBreakdownEnum] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param issued_at [String] + # @param issued_at_gt [String] + # @param issued_at_lt [String] + # @param issued_at_gte [String] + # @param issued_at_lte [String] + # @param document_id [String] + # @param document_id_iexact [String] + # @param document_id_contains [String] + # @param document_id_icontains [String] + # @param total_amount_gt [Integer] + # @param total_amount_lt [Integer] + # @param total_amount_gte [Integer] + # @param total_amount_lte [Integer] + # @param subtotal_gt [Integer] + # @param subtotal_lt [Integer] + # @param subtotal_gte [Integer] + # @param subtotal_lte [Integer] + # @param based_on [String] + # @param counterpart_id [String] + # @param created_by_entity_user_id [String] + # @param status [Monite::CreditNoteStateEnum] + # @param status_in [Monite::CreditNoteStateEnum] + # @param status_not_in [Monite::CreditNoteStateEnum] + # @param currency [Monite::CurrencyEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableAnalyticsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.analytics.get_analytics_credit_notes(metric: ID, aggregation_function: COUNT) + def get_analytics_credit_notes(dimension: nil, metric:, aggregation_function:, date_dimension_breakdown: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, issued_at: nil, issued_at_gt: nil, issued_at_lt: nil, issued_at_gte: nil, issued_at_lte: nil, document_id: nil, document_id_iexact: nil, document_id_contains: nil, document_id_icontains: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, subtotal_gt: nil, subtotal_lt: nil, subtotal_gte: nil, subtotal_lte: nil, based_on: nil, counterpart_id: nil, created_by_entity_user_id: nil, status: nil, status_in: nil, status_not_in: nil, currency: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "dimension": dimension, "metric": metric, "aggregation_function": aggregation_function, "date_dimension_breakdown": date_dimension_breakdown, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "issued_at": issued_at, "issued_at__gt": issued_at_gt, "issued_at__lt": issued_at_lt, "issued_at__gte": issued_at_gte, "issued_at__lte": issued_at_lte, "document_id": document_id, "document_id__iexact": document_id_iexact, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "subtotal__gt": subtotal_gt, "subtotal__lt": subtotal_lt, "subtotal__gte": subtotal_gte, "subtotal__lte": subtotal_lte, "based_on": based_on, "counterpart_id": counterpart_id, "created_by_entity_user_id": created_by_entity_user_id, "status": status, "status__in": status_in, "status__not_in": status_not_in, "currency": currency }.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)}/analytics/credit_notes" +end + Monite::PayableAnalyticsResponse.from_json(json_object: response.body) + end +# Retrieve aggregated statistics for payables with different breakdowns. + # + # @param dimension [Monite::PayableDimensionEnum] + # @param metric [Monite::PayableMetricEnum] + # @param aggregation_function [Monite::AggregationFunctionEnum] + # @param date_dimension_breakdown [Monite::DateDimensionBreakdownEnum] + # @param created_at_gt [DateTime] Return only payables created in Monite after the specified date and time. The +# value must be in the ISO 8601 format YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]. + # @param created_at_lt [DateTime] Return only payables created in Monite before the specified date and time. + # @param created_at_gte [DateTime] Return only payables created in Monite on or after the specified date and time. + # @param created_at_lte [DateTime] Return only payables created in Monite before or on the specified date and time. + # @param status [Monite::PayableStateEnum] Return only payables that have the specified +# [status](https://docs.monite.com/accounts-payable/payables/index). +# To query multiple statuses at once, use the `status__in` parameter instead. + # @param status_in [Monite::PayableStateEnum] Return only payables that have the specified +# [statuses](https://docs.monite.com/accounts-payable/payables/index). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=new` + # @param id_in [String] Return only payables with specified IDs. Valid but nonexistent IDs do not raise +# errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param total_amount [Integer] Return only payables with the exact specified total amount. The amount must be +# specified in the minor units of currency. For example, $12.5 is represented as +# 1250. + # @param total_amount_gt [Integer] Return only payables whose total amount (in minor units) exceeds the specified +# value. + # @param total_amount_lt [Integer] Return only payables whose total amount (in minor units) is less than the +# specified value. + # @param total_amount_gte [Integer] Return only payables whose total amount (in minor units) is greater than or +# equal to the specified value. + # @param total_amount_lte [Integer] Return only payables whose total amount (in minor units) is less than or equal +# to the specified value. + # @param amount [Integer] Return only payables with the specified amount. + # @param amount_gt [Integer] Return only payables whose amount (in minor units) exceeds the specified value. + # @param amount_lt [Integer] Return only payables whose amount (in minor units) is less than the specified +# value. + # @param amount_gte [Integer] Return only payables whose amount (in minor units) is greater than or equal to +# the specified value. + # @param amount_lte [Integer] Return only payables whose amount (in minor units) is less than or equal to the +# specified value. + # @param currency [Monite::CurrencyEnum] Return only payables that use the specified currency. + # @param counterpart_name [String] Return only payables received from counterparts with the specified name (exact +# match, case-sensitive). +# For counterparts of `type = individual`, the full name is formatted as +# `first_name last_name`. + # @param counterpart_name_contains [String] Return only payables received from counterparts whose name contains the +# specified string (case-sensitive). + # @param counterpart_name_icontains [String] Return only payables received from counterparts whose name contains the +# specified string (case-insensitive). + # @param search_text [String] Apply the `icontains` condition to search for the specified text in the +# `document_id` and `counterpart_name` fields in the payables. + # @param due_date [String] Return payables that are due on the specified date (YYYY-MM-DD) + # @param due_date_gt [String] Return payables that are due after the specified date (exclusive, YYYY-MM-DD). + # @param due_date_lt [String] Return payables that are due before the specified date (exclusive, YYYY-MM-DD). + # @param due_date_gte [String] Return payables that are due on or after the specified date (YYYY-MM-DD). + # @param due_date_lte [String] Return payables that are due before or on the specified date (YYYY-MM-DD). + # @param document_id [String] Return a payable with the exact specified document number (case-sensitive). +# The `document_id` is the user-facing document number such as INV-00042, not to +# be confused with Monite resource IDs (`id`). + # @param document_id_contains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-sensitive). + # @param document_id_icontains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-insensitive). + # @param was_created_by_user_id [String] Return only payables created in Monite by the entity user with the specified ID. + # @param counterpart_id [String] Return only payables received from the counterpart with the specified ID. +# Counterparts that have been deleted but have associated payables will still +# return results here because the payables contain a frozen copy of the +# counterpart data. +# If the specified counterpart ID does not exist and never existed, no results are +# returned. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Return only payables coming from the specified source. + # @param ocr_status [Monite::OcrStatusEnum] Return only payables with specific OCR statuses. + # @param line_item_id [String] Search for a payable by the identifier of the line item associated with it. + # @param purchase_order_id [String] Search for a payable by the identifier of the purchase order associated with it. + # @param project_id [String] Return only payables assigned to the project with the specified ID. +# Valid but nonexistent project IDs do not raise errors but return no results. + # @param tag_ids [String] Return only payables whose `tags` include at least one of the tags with the +# specified IDs. Valid but nonexistent tag IDs do not raise errors but produce no +# results. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableAnalyticsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.analytics.get_analytics_payables(metric: ID, aggregation_function: COUNT) + def get_analytics_payables(dimension: nil, metric:, aggregation_function:, date_dimension_breakdown: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, status: nil, status_in: nil, id_in: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, amount: nil, amount_gt: nil, amount_lt: nil, amount_gte: nil, amount_lte: nil, currency: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, search_text: nil, due_date: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, was_created_by_user_id: nil, counterpart_id: nil, source_of_payable_data: nil, ocr_status: nil, line_item_id: nil, purchase_order_id: nil, project_id: nil, tag_ids: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "dimension": dimension, "metric": metric, "aggregation_function": aggregation_function, "date_dimension_breakdown": date_dimension_breakdown, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "status": status, "status__in": status_in, "id__in": id_in, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "amount": amount, "amount__gt": amount_gt, "amount__lt": amount_lt, "amount__gte": amount_gte, "amount__lte": amount_lte, "currency": currency, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "search_text": search_text, "due_date": due_date, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "was_created_by_user_id": was_created_by_user_id, "counterpart_id": counterpart_id, "source_of_payable_data": source_of_payable_data, "ocr_status": ocr_status, "line_item_id": line_item_id, "purchase_order_id": purchase_order_id, "project_id": project_id, "tag_ids": tag_ids }.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)}/analytics/payables" +end + Monite::PayableAnalyticsResponse.from_json(json_object: response.body) + end + end + class AsyncAnalyticsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncAnalyticsClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve aggregated statistics for payables with different breakdowns. + # + # @param dimension [Monite::CreditNoteDimensionEnum] + # @param metric [Monite::CreditNoteMetricEnum] + # @param aggregation_function [Monite::AggregationFunctionEnum] + # @param date_dimension_breakdown [Monite::DateDimensionBreakdownEnum] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param issued_at [String] + # @param issued_at_gt [String] + # @param issued_at_lt [String] + # @param issued_at_gte [String] + # @param issued_at_lte [String] + # @param document_id [String] + # @param document_id_iexact [String] + # @param document_id_contains [String] + # @param document_id_icontains [String] + # @param total_amount_gt [Integer] + # @param total_amount_lt [Integer] + # @param total_amount_gte [Integer] + # @param total_amount_lte [Integer] + # @param subtotal_gt [Integer] + # @param subtotal_lt [Integer] + # @param subtotal_gte [Integer] + # @param subtotal_lte [Integer] + # @param based_on [String] + # @param counterpart_id [String] + # @param created_by_entity_user_id [String] + # @param status [Monite::CreditNoteStateEnum] + # @param status_in [Monite::CreditNoteStateEnum] + # @param status_not_in [Monite::CreditNoteStateEnum] + # @param currency [Monite::CurrencyEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableAnalyticsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.analytics.get_analytics_credit_notes(metric: ID, aggregation_function: COUNT) + def get_analytics_credit_notes(dimension: nil, metric:, aggregation_function:, date_dimension_breakdown: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, issued_at: nil, issued_at_gt: nil, issued_at_lt: nil, issued_at_gte: nil, issued_at_lte: nil, document_id: nil, document_id_iexact: nil, document_id_contains: nil, document_id_icontains: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, subtotal_gt: nil, subtotal_lt: nil, subtotal_gte: nil, subtotal_lte: nil, based_on: nil, counterpart_id: nil, created_by_entity_user_id: nil, status: nil, status_in: nil, status_not_in: nil, currency: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "dimension": dimension, "metric": metric, "aggregation_function": aggregation_function, "date_dimension_breakdown": date_dimension_breakdown, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "issued_at": issued_at, "issued_at__gt": issued_at_gt, "issued_at__lt": issued_at_lt, "issued_at__gte": issued_at_gte, "issued_at__lte": issued_at_lte, "document_id": document_id, "document_id__iexact": document_id_iexact, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "subtotal__gt": subtotal_gt, "subtotal__lt": subtotal_lt, "subtotal__gte": subtotal_gte, "subtotal__lte": subtotal_lte, "based_on": based_on, "counterpart_id": counterpart_id, "created_by_entity_user_id": created_by_entity_user_id, "status": status, "status__in": status_in, "status__not_in": status_not_in, "currency": currency }.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)}/analytics/credit_notes" +end + Monite::PayableAnalyticsResponse.from_json(json_object: response.body) + end + end +# Retrieve aggregated statistics for payables with different breakdowns. + # + # @param dimension [Monite::PayableDimensionEnum] + # @param metric [Monite::PayableMetricEnum] + # @param aggregation_function [Monite::AggregationFunctionEnum] + # @param date_dimension_breakdown [Monite::DateDimensionBreakdownEnum] + # @param created_at_gt [DateTime] Return only payables created in Monite after the specified date and time. The +# value must be in the ISO 8601 format YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]. + # @param created_at_lt [DateTime] Return only payables created in Monite before the specified date and time. + # @param created_at_gte [DateTime] Return only payables created in Monite on or after the specified date and time. + # @param created_at_lte [DateTime] Return only payables created in Monite before or on the specified date and time. + # @param status [Monite::PayableStateEnum] Return only payables that have the specified +# [status](https://docs.monite.com/accounts-payable/payables/index). +# To query multiple statuses at once, use the `status__in` parameter instead. + # @param status_in [Monite::PayableStateEnum] Return only payables that have the specified +# [statuses](https://docs.monite.com/accounts-payable/payables/index). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=new` + # @param id_in [String] Return only payables with specified IDs. Valid but nonexistent IDs do not raise +# errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param total_amount [Integer] Return only payables with the exact specified total amount. The amount must be +# specified in the minor units of currency. For example, $12.5 is represented as +# 1250. + # @param total_amount_gt [Integer] Return only payables whose total amount (in minor units) exceeds the specified +# value. + # @param total_amount_lt [Integer] Return only payables whose total amount (in minor units) is less than the +# specified value. + # @param total_amount_gte [Integer] Return only payables whose total amount (in minor units) is greater than or +# equal to the specified value. + # @param total_amount_lte [Integer] Return only payables whose total amount (in minor units) is less than or equal +# to the specified value. + # @param amount [Integer] Return only payables with the specified amount. + # @param amount_gt [Integer] Return only payables whose amount (in minor units) exceeds the specified value. + # @param amount_lt [Integer] Return only payables whose amount (in minor units) is less than the specified +# value. + # @param amount_gte [Integer] Return only payables whose amount (in minor units) is greater than or equal to +# the specified value. + # @param amount_lte [Integer] Return only payables whose amount (in minor units) is less than or equal to the +# specified value. + # @param currency [Monite::CurrencyEnum] Return only payables that use the specified currency. + # @param counterpart_name [String] Return only payables received from counterparts with the specified name (exact +# match, case-sensitive). +# For counterparts of `type = individual`, the full name is formatted as +# `first_name last_name`. + # @param counterpart_name_contains [String] Return only payables received from counterparts whose name contains the +# specified string (case-sensitive). + # @param counterpart_name_icontains [String] Return only payables received from counterparts whose name contains the +# specified string (case-insensitive). + # @param search_text [String] Apply the `icontains` condition to search for the specified text in the +# `document_id` and `counterpart_name` fields in the payables. + # @param due_date [String] Return payables that are due on the specified date (YYYY-MM-DD) + # @param due_date_gt [String] Return payables that are due after the specified date (exclusive, YYYY-MM-DD). + # @param due_date_lt [String] Return payables that are due before the specified date (exclusive, YYYY-MM-DD). + # @param due_date_gte [String] Return payables that are due on or after the specified date (YYYY-MM-DD). + # @param due_date_lte [String] Return payables that are due before or on the specified date (YYYY-MM-DD). + # @param document_id [String] Return a payable with the exact specified document number (case-sensitive). +# The `document_id` is the user-facing document number such as INV-00042, not to +# be confused with Monite resource IDs (`id`). + # @param document_id_contains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-sensitive). + # @param document_id_icontains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-insensitive). + # @param was_created_by_user_id [String] Return only payables created in Monite by the entity user with the specified ID. + # @param counterpart_id [String] Return only payables received from the counterpart with the specified ID. +# Counterparts that have been deleted but have associated payables will still +# return results here because the payables contain a frozen copy of the +# counterpart data. +# If the specified counterpart ID does not exist and never existed, no results are +# returned. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Return only payables coming from the specified source. + # @param ocr_status [Monite::OcrStatusEnum] Return only payables with specific OCR statuses. + # @param line_item_id [String] Search for a payable by the identifier of the line item associated with it. + # @param purchase_order_id [String] Search for a payable by the identifier of the purchase order associated with it. + # @param project_id [String] Return only payables assigned to the project with the specified ID. +# Valid but nonexistent project IDs do not raise errors but return no results. + # @param tag_ids [String] Return only payables whose `tags` include at least one of the tags with the +# specified IDs. Valid but nonexistent tag IDs do not raise errors but produce no +# results. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableAnalyticsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.analytics.get_analytics_payables(metric: ID, aggregation_function: COUNT) + def get_analytics_payables(dimension: nil, metric:, aggregation_function:, date_dimension_breakdown: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, status: nil, status_in: nil, id_in: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, amount: nil, amount_gt: nil, amount_lt: nil, amount_gte: nil, amount_lte: nil, currency: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, search_text: nil, due_date: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, was_created_by_user_id: nil, counterpart_id: nil, source_of_payable_data: nil, ocr_status: nil, line_item_id: nil, purchase_order_id: nil, project_id: nil, tag_ids: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "dimension": dimension, "metric": metric, "aggregation_function": aggregation_function, "date_dimension_breakdown": date_dimension_breakdown, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "status": status, "status__in": status_in, "id__in": id_in, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "amount": amount, "amount__gt": amount_gt, "amount__lt": amount_lt, "amount__gte": amount_gte, "amount__lte": amount_lte, "currency": currency, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "search_text": search_text, "due_date": due_date, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "was_created_by_user_id": was_created_by_user_id, "counterpart_id": counterpart_id, "source_of_payable_data": source_of_payable_data, "ocr_status": ocr_status, "line_item_id": line_item_id, "purchase_order_id": purchase_order_id, "project_id": project_id, "tag_ids": tag_ids }.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)}/analytics/payables" +end + Monite::PayableAnalyticsResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/client.rb b/lib/monite/approval_policies/client.rb new file mode 100644 index 0000000..2eed3cb --- /dev/null +++ b/lib/monite/approval_policies/client.rb @@ -0,0 +1,545 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "processes/client" +require_relative "../types/order_enum" +require_relative "../types/approval_policy_cursor_fields" +require_relative "types/approval_policies_get_request_status" +require_relative "types/approval_policies_get_request_status_in_item" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/approval_policy_resource_list" +require "date" +require "date" +require_relative "types/approval_policy_create_script_item" +require_relative "types/approval_policy_create_trigger" +require_relative "../types/approval_policy_resource" +require "date" +require "date" +require_relative "types/approval_policy_update_script_item" +require_relative "types/approval_policy_update_trigger" +require_relative "../types/approval_policy_status" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class ApprovalPoliciesClient + # @return [Monite::RequestClient] + attr_reader :request_client + # @return [Monite::ApprovalPolicies::ProcessesClient] + attr_reader :processes + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ApprovalPoliciesClient] + def initialize(request_client:) + @request_client = request_client + @processes = Monite::ApprovalPolicies::ProcessesClient.new(request_client: request_client) + end +# Retrieve a list of all approval policies with pagination. + # + # @param process_id [String] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ApprovalPolicyCursorFields] Allowed sort fields + # @param id_in [String] + # @param status [Monite::ApprovalPolicies::ApprovalPoliciesGetRequestStatus] + # @param status_in [Monite::ApprovalPolicies::ApprovalPoliciesGetRequestStatusInItem] + # @param name [String] + # @param name_contains [String] + # @param name_ncontains [String] + # @param created_by [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.get + def get(process_id: nil, order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, status: nil, status_in: nil, name: nil, name_contains: nil, name_ncontains: nil, created_by: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "process_id": process_id, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "status": status, "status__in": status_in, "name": name, "name__contains": name_contains, "name__ncontains": name_ncontains, "created_by": created_by, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte }.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)}/approval_policies" +end + Monite::ApprovalPolicyResourceList.from_json(json_object: response.body) + end +# Create a new approval policy. + # + # @param starts_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy becomes +# active. Only payables submitted for approval during the policy's active period +# will trigger this policy. If omitted or `null`, the policy is effective +# immediately. The value will be converted to UTC. + # @param ends_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy stops being +# active and stops triggering approval workflows.If `ends_at` is provided in the +# request, then `starts_at` must also be provided and `ends_at` must be later than +# `starts_at`. The value will be converted to UTC. + # @param name [String] The name of the approval policy. + # @param description [String] A brief description of the approval policy. + # @param script [Array] A list of JSON objects that represents the approval policy script. The script +# contains the logic that determines whether an action should be sent to approval. +# This field is required, and it should contain at least one script object.Request of type Array, as a Hash + # @param trigger [Boolean, Float, String, Array, Hash{String => Object}] A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.create( +# name: "name", +# description: "description", +# script: [true] +# ) + def create(starts_at: nil, ends_at: nil, name:, description:, script:, trigger: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), starts_at: starts_at, ends_at: ends_at, name: name, description: description, script: script, trigger: trigger }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/approval_policies" +end + Monite::ApprovalPolicyResource.from_json(json_object: response.body) + end +# Retrieve a specific approval policy. + # + # @param approval_policy_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.get_by_id(approval_policy_id: "approval_policy_id") + def get_by_id(approval_policy_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}" +end + Monite::ApprovalPolicyResource.from_json(json_object: response.body) + end +# Delete an existing approval policy. + # + # @param approval_policy_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.delete_by_id(approval_policy_id: "approval_policy_id") + def delete_by_id(approval_policy_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}" +end + end +# Update an existing approval policy. + # + # @param approval_policy_id [String] + # @param starts_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy becomes +# active. Only payables submitted for approval during the policy's active period +# will trigger this policy. If omitted or `null`, the policy is effective +# immediately. The value will be converted to UTC. + # @param ends_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy stops being +# active and stops triggering approval workflows.If `ends_at` is provided in the +# request, then `starts_at` must also be provided and `ends_at` must be later than +# `starts_at`. The value will be converted to UTC. + # @param name [String] The name of the approval policy. + # @param description [String] A brief description of the approval policy. + # @param script [Array] A list of JSON objects that represents the approval policy script. The script +# contains the logic that determines whether an action should be sent to approval. +# This field is required, and it should contain at least one script object.Request of type Array, as a Hash + # @param trigger [Boolean, Float, String, Array, Hash{String => Object}] A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + # @param status [Monite::ApprovalPolicyStatus] A string that represents the current status of the approval policy. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.update_by_id(approval_policy_id: "approval_policy_id") + def update_by_id(approval_policy_id:, starts_at: nil, ends_at: nil, name: nil, description: nil, script: nil, trigger: nil, status: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), starts_at: starts_at, ends_at: ends_at, name: name, description: description, script: script, trigger: trigger, status: status }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/approval_policies/#{approval_policy_id}" +end + Monite::ApprovalPolicyResource.from_json(json_object: response.body) + end + end + class AsyncApprovalPoliciesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + # @return [Monite::ApprovalPolicies::ProcessesClient] + attr_reader :processes + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncApprovalPoliciesClient] + def initialize(request_client:) + @request_client = request_client + @processes = Monite::ApprovalPolicies::AsyncProcessesClient.new(request_client: request_client) + end +# Retrieve a list of all approval policies with pagination. + # + # @param process_id [String] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ApprovalPolicyCursorFields] Allowed sort fields + # @param id_in [String] + # @param status [Monite::ApprovalPolicies::ApprovalPoliciesGetRequestStatus] + # @param status_in [Monite::ApprovalPolicies::ApprovalPoliciesGetRequestStatusInItem] + # @param name [String] + # @param name_contains [String] + # @param name_ncontains [String] + # @param created_by [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.get + def get(process_id: nil, order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, status: nil, status_in: nil, name: nil, name_contains: nil, name_ncontains: nil, created_by: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "process_id": process_id, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "status": status, "status__in": status_in, "name": name, "name__contains": name_contains, "name__ncontains": name_ncontains, "created_by": created_by, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte }.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)}/approval_policies" +end + Monite::ApprovalPolicyResourceList.from_json(json_object: response.body) + end + end +# Create a new approval policy. + # + # @param starts_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy becomes +# active. Only payables submitted for approval during the policy's active period +# will trigger this policy. If omitted or `null`, the policy is effective +# immediately. The value will be converted to UTC. + # @param ends_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy stops being +# active and stops triggering approval workflows.If `ends_at` is provided in the +# request, then `starts_at` must also be provided and `ends_at` must be later than +# `starts_at`. The value will be converted to UTC. + # @param name [String] The name of the approval policy. + # @param description [String] A brief description of the approval policy. + # @param script [Array] A list of JSON objects that represents the approval policy script. The script +# contains the logic that determines whether an action should be sent to approval. +# This field is required, and it should contain at least one script object.Request of type Array, as a Hash + # @param trigger [Boolean, Float, String, Array, Hash{String => Object}] A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.create( +# name: "name", +# description: "description", +# script: [true] +# ) + def create(starts_at: nil, ends_at: nil, name:, description:, script:, trigger: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), starts_at: starts_at, ends_at: ends_at, name: name, description: description, script: script, trigger: trigger }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/approval_policies" +end + Monite::ApprovalPolicyResource.from_json(json_object: response.body) + end + end +# Retrieve a specific approval policy. + # + # @param approval_policy_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.get_by_id(approval_policy_id: "approval_policy_id") + def get_by_id(approval_policy_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}" +end + Monite::ApprovalPolicyResource.from_json(json_object: response.body) + end + end +# Delete an existing approval policy. + # + # @param approval_policy_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.delete_by_id(approval_policy_id: "approval_policy_id") + def delete_by_id(approval_policy_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}" +end + end + end +# Update an existing approval policy. + # + # @param approval_policy_id [String] + # @param starts_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy becomes +# active. Only payables submitted for approval during the policy's active period +# will trigger this policy. If omitted or `null`, the policy is effective +# immediately. The value will be converted to UTC. + # @param ends_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy stops being +# active and stops triggering approval workflows.If `ends_at` is provided in the +# request, then `starts_at` must also be provided and `ends_at` must be later than +# `starts_at`. The value will be converted to UTC. + # @param name [String] The name of the approval policy. + # @param description [String] A brief description of the approval policy. + # @param script [Array] A list of JSON objects that represents the approval policy script. The script +# contains the logic that determines whether an action should be sent to approval. +# This field is required, and it should contain at least one script object.Request of type Array, as a Hash + # @param trigger [Boolean, Float, String, Array, Hash{String => Object}] A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + # @param status [Monite::ApprovalPolicyStatus] A string that represents the current status of the approval policy. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalPolicyResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.update_by_id(approval_policy_id: "approval_policy_id") + def update_by_id(approval_policy_id:, starts_at: nil, ends_at: nil, name: nil, description: nil, script: nil, trigger: nil, status: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), starts_at: starts_at, ends_at: ends_at, name: name, description: description, script: script, trigger: trigger, status: status }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/approval_policies/#{approval_policy_id}" +end + Monite::ApprovalPolicyResource.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/processes/client.rb b/lib/monite/approval_policies/processes/client.rb new file mode 100644 index 0000000..dfaf3b7 --- /dev/null +++ b/lib/monite/approval_policies/processes/client.rb @@ -0,0 +1,355 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/approval_process_resource_list" +require_relative "../../types/process_resource" +require_relative "../../types/approval_process_step_resource_list" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module ApprovalPolicies + class ProcessesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ApprovalPolicies::ProcessesClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve a list of all approval policy processes. + # + # @param approval_policy_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalProcessResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.get(approval_policy_id: "approval_policy_id") + def get(approval_policy_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes" +end + Monite::ApprovalProcessResourceList.from_json(json_object: response.body) + end +# Retrieve a specific approval policy process. + # + # @param approval_policy_id [String] + # @param process_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProcessResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.get_by_id(approval_policy_id: "approval_policy_id", process_id: "process_id") + def get_by_id(approval_policy_id:, process_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes/#{process_id}" +end + Monite::ProcessResource.from_json(json_object: response.body) + end +# Cancel an ongoing approval process for a specific approval policy. + # + # @param approval_policy_id [String] + # @param process_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProcessResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.cancel_by_id(approval_policy_id: "approval_policy_id", process_id: "process_id") + def cancel_by_id(approval_policy_id:, process_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes/#{process_id}/cancel" +end + Monite::ProcessResource.from_json(json_object: response.body) + end +# Retrieve a list of approval policy process steps. + # + # @param approval_policy_id [String] + # @param process_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalProcessStepResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.get_steps(approval_policy_id: "approval_policy_id", process_id: "process_id") + def get_steps(approval_policy_id:, process_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes/#{process_id}/steps" +end + Monite::ApprovalProcessStepResourceList.from_json(json_object: response.body) + end + end + class AsyncProcessesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ApprovalPolicies::AsyncProcessesClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve a list of all approval policy processes. + # + # @param approval_policy_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalProcessResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.get(approval_policy_id: "approval_policy_id") + def get(approval_policy_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes" +end + Monite::ApprovalProcessResourceList.from_json(json_object: response.body) + end + end +# Retrieve a specific approval policy process. + # + # @param approval_policy_id [String] + # @param process_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProcessResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.get_by_id(approval_policy_id: "approval_policy_id", process_id: "process_id") + def get_by_id(approval_policy_id:, process_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes/#{process_id}" +end + Monite::ProcessResource.from_json(json_object: response.body) + end + end +# Cancel an ongoing approval process for a specific approval policy. + # + # @param approval_policy_id [String] + # @param process_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProcessResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.cancel_by_id(approval_policy_id: "approval_policy_id", process_id: "process_id") + def cancel_by_id(approval_policy_id:, process_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes/#{process_id}/cancel" +end + Monite::ProcessResource.from_json(json_object: response.body) + end + end +# Retrieve a list of approval policy process steps. + # + # @param approval_policy_id [String] + # @param process_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalProcessStepResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_policies.processes.get_steps(approval_policy_id: "approval_policy_id", process_id: "process_id") + def get_steps(approval_policy_id:, process_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_policies/#{approval_policy_id}/processes/#{process_id}/steps" +end + Monite::ApprovalProcessStepResourceList.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/types/approval_policies_get_request_status.rb b/lib/monite/approval_policies/types/approval_policies_get_request_status.rb new file mode 100644 index 0000000..f90c2f2 --- /dev/null +++ b/lib/monite/approval_policies/types/approval_policies_get_request_status.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + module ApprovalPolicies + class ApprovalPoliciesGetRequestStatus + + ACTIVE = "active" + PENDING = "pending" + + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/types/approval_policies_get_request_status_in_item.rb b/lib/monite/approval_policies/types/approval_policies_get_request_status_in_item.rb new file mode 100644 index 0000000..82e0397 --- /dev/null +++ b/lib/monite/approval_policies/types/approval_policies_get_request_status_in_item.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + module ApprovalPolicies + class ApprovalPoliciesGetRequestStatusInItem + + ACTIVE = "active" + PENDING = "pending" + + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/types/approval_policy_create_script_item.rb b/lib/monite/approval_policies/types/approval_policy_create_script_item.rb new file mode 100644 index 0000000..e3ee0e3 --- /dev/null +++ b/lib/monite/approval_policies/types/approval_policy_create_script_item.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require "json" + +module Monite + module ApprovalPolicies + class ApprovalPolicyCreateScriptItem + + +# Deserialize a JSON object to an instance of ApprovalPolicyCreateScriptItem + # + # @param json_object [String] + # @return [Monite::ApprovalPolicies::ApprovalPolicyCreateScriptItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/types/approval_policy_create_trigger.rb b/lib/monite/approval_policies/types/approval_policy_create_trigger.rb new file mode 100644 index 0000000..61f3ec4 --- /dev/null +++ b/lib/monite/approval_policies/types/approval_policy_create_trigger.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true +require "json" + +module Monite + module ApprovalPolicies +# A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + class ApprovalPolicyCreateTrigger + + +# Deserialize a JSON object to an instance of ApprovalPolicyCreateTrigger + # + # @param json_object [String] + # @return [Monite::ApprovalPolicies::ApprovalPolicyCreateTrigger] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/types/approval_policy_update_script_item.rb b/lib/monite/approval_policies/types/approval_policy_update_script_item.rb new file mode 100644 index 0000000..011487b --- /dev/null +++ b/lib/monite/approval_policies/types/approval_policy_update_script_item.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require "json" + +module Monite + module ApprovalPolicies + class ApprovalPolicyUpdateScriptItem + + +# Deserialize a JSON object to an instance of ApprovalPolicyUpdateScriptItem + # + # @param json_object [String] + # @return [Monite::ApprovalPolicies::ApprovalPolicyUpdateScriptItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_policies/types/approval_policy_update_trigger.rb b/lib/monite/approval_policies/types/approval_policy_update_trigger.rb new file mode 100644 index 0000000..8880013 --- /dev/null +++ b/lib/monite/approval_policies/types/approval_policy_update_trigger.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true +require "json" + +module Monite + module ApprovalPolicies +# A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + class ApprovalPolicyUpdateTrigger + + +# Deserialize a JSON object to an instance of ApprovalPolicyUpdateTrigger + # + # @param json_object [String] + # @return [Monite::ApprovalPolicies::ApprovalPolicyUpdateTrigger] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end + end +end \ No newline at end of file diff --git a/lib/monite/approval_requests/client.rb b/lib/monite/approval_requests/client.rb new file mode 100644 index 0000000..37c9572 --- /dev/null +++ b/lib/monite/approval_requests/client.rb @@ -0,0 +1,525 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/approval_request_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/approval_request_status" +require_relative "../types/object_type" +require_relative "../types/approval_request_resource_list" +require_relative "../types/approval_request_create_request" +require_relative "../types/approval_request_resource_with_metadata" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class ApprovalRequestsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ApprovalRequestsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ApprovalRequestCursorFields] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param object_id [String] + # @param object_id_in [String] + # @param status [Monite::ApprovalRequestStatus] + # @param status_in [Monite::ApprovalRequestStatus] + # @param user_id [String] + # @param role_id [String] + # @param object_type [Monite::ObjectType] + # @param object_type_in [Monite::ObjectType] + # @param created_by [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, object_id: nil, object_id_in: nil, status: nil, status_in: nil, user_id: nil, role_id: nil, object_type: nil, object_type_in: nil, created_by: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte, "object_id": object_id, "object_id__in": object_id_in, "status": status, "status__in": status_in, "user_id": user_id, "role_id": role_id, "object_type": object_type, "object_type__in": object_type_in, "created_by": created_by }.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)}/approval_requests" +end + Monite::ApprovalRequestResourceList.from_json(json_object: response.body) + end + # @param request [Monite::ApprovalRequestCreateByRoleRequest, Monite::ApprovalRequestCreateByUserRequest] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.create(request: { object_id: "object_id", object_type: ACCOUNT, required_approval_count: 1, role_ids: ["role_ids"] }) + def create(request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/approval_requests" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.get_by_id(approval_request_id: "approval_request_id") + def get_by_id(approval_request_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.approve_by_id(approval_request_id: "approval_request_id") + def approve_by_id(approval_request_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}/approve" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.cancel_by_id(approval_request_id: "approval_request_id") + def cancel_by_id(approval_request_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}/cancel" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.reject_by_id(approval_request_id: "approval_request_id") + def reject_by_id(approval_request_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}/reject" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + end + class AsyncApprovalRequestsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncApprovalRequestsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ApprovalRequestCursorFields] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param object_id [String] + # @param object_id_in [String] + # @param status [Monite::ApprovalRequestStatus] + # @param status_in [Monite::ApprovalRequestStatus] + # @param user_id [String] + # @param role_id [String] + # @param object_type [Monite::ObjectType] + # @param object_type_in [Monite::ObjectType] + # @param created_by [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, object_id: nil, object_id_in: nil, status: nil, status_in: nil, user_id: nil, role_id: nil, object_type: nil, object_type_in: nil, created_by: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte, "object_id": object_id, "object_id__in": object_id_in, "status": status, "status__in": status_in, "user_id": user_id, "role_id": role_id, "object_type": object_type, "object_type__in": object_type_in, "created_by": created_by }.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)}/approval_requests" +end + Monite::ApprovalRequestResourceList.from_json(json_object: response.body) + end + end + # @param request [Monite::ApprovalRequestCreateByRoleRequest, Monite::ApprovalRequestCreateByUserRequest] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.create(request: { object_id: "object_id", object_type: ACCOUNT, required_approval_count: 1, role_ids: ["role_ids"] }) + def create(request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/approval_requests" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.get_by_id(approval_request_id: "approval_request_id") + def get_by_id(approval_request_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.approve_by_id(approval_request_id: "approval_request_id") + def approve_by_id(approval_request_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}/approve" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.cancel_by_id(approval_request_id: "approval_request_id") + def cancel_by_id(approval_request_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}/cancel" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + end + # @param approval_request_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ApprovalRequestResourceWithMetadata] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.approval_requests.reject_by_id(approval_request_id: "approval_request_id") + def reject_by_id(approval_request_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/approval_requests/#{approval_request_id}/reject" +end + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/comments/client.rb b/lib/monite/comments/client.rb new file mode 100644 index 0000000..96a3ca5 --- /dev/null +++ b/lib/monite/comments/client.rb @@ -0,0 +1,454 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/object_type_available_comment" +require_relative "../types/order_enum" +require_relative "../types/comment_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/comment_resource_list" +require_relative "../types/comment_resource" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class CommentsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::CommentsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get comments + # + # @param object_type [Monite::OBJECT_TYPE_AVAILABLE_COMMENT] + # @param object_id [String] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::COMMENT_CURSOR_FIELDS] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.get(object_type: "payable", object_id: "object_id") + def get(object_type:, object_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "object_type": object_type, "object_id": object_id, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/comments" +end + Monite::CommentResourceList.from_json(json_object: response.body) + end +# Create new comment + # + # @param object_id [String] + # @param object_type [String] + # @param reply_to_entity_user_id [String] + # @param text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.create( +# object_id: "object_id", +# object_type: "object_type", +# text: "text" +# ) + def create(object_id:, object_type:, reply_to_entity_user_id: nil, text:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), object_id: object_id, object_type: object_type, reply_to_entity_user_id: reply_to_entity_user_id, text: text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/comments" +end + Monite::CommentResource.from_json(json_object: response.body) + end +# Get comment + # + # @param comment_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.get_by_id(comment_id: "comment_id") + def get_by_id(comment_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/comments/#{comment_id}" +end + Monite::CommentResource.from_json(json_object: response.body) + end +# Delete comment + # + # @param comment_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.delete_by_id(comment_id: "comment_id") + def delete_by_id(comment_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/comments/#{comment_id}" +end + end +# Update comment + # + # @param comment_id [String] + # @param reply_to_entity_user_id [String] + # @param text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.update_by_id(comment_id: "comment_id") + def update_by_id(comment_id:, reply_to_entity_user_id: nil, text: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), reply_to_entity_user_id: reply_to_entity_user_id, text: text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/comments/#{comment_id}" +end + Monite::CommentResource.from_json(json_object: response.body) + end + end + class AsyncCommentsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncCommentsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get comments + # + # @param object_type [Monite::OBJECT_TYPE_AVAILABLE_COMMENT] + # @param object_id [String] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::COMMENT_CURSOR_FIELDS] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.get(object_type: "payable", object_id: "object_id") + def get(object_type:, object_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "object_type": object_type, "object_id": object_id, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/comments" +end + Monite::CommentResourceList.from_json(json_object: response.body) + end + end +# Create new comment + # + # @param object_id [String] + # @param object_type [String] + # @param reply_to_entity_user_id [String] + # @param text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.create( +# object_id: "object_id", +# object_type: "object_type", +# text: "text" +# ) + def create(object_id:, object_type:, reply_to_entity_user_id: nil, text:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), object_id: object_id, object_type: object_type, reply_to_entity_user_id: reply_to_entity_user_id, text: text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/comments" +end + Monite::CommentResource.from_json(json_object: response.body) + end + end +# Get comment + # + # @param comment_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.get_by_id(comment_id: "comment_id") + def get_by_id(comment_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/comments/#{comment_id}" +end + Monite::CommentResource.from_json(json_object: response.body) + end + end +# Delete comment + # + # @param comment_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.delete_by_id(comment_id: "comment_id") + def delete_by_id(comment_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/comments/#{comment_id}" +end + end + end +# Update comment + # + # @param comment_id [String] + # @param reply_to_entity_user_id [String] + # @param text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CommentResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.comments.update_by_id(comment_id: "comment_id") + def update_by_id(comment_id:, reply_to_entity_user_id: nil, text: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), reply_to_entity_user_id: reply_to_entity_user_id, text: text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/comments/#{comment_id}" +end + Monite::CommentResource.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/counterparts/addresses/client.rb b/lib/monite/counterparts/addresses/client.rb new file mode 100644 index 0000000..8d19cea --- /dev/null +++ b/lib/monite/counterparts/addresses/client.rb @@ -0,0 +1,433 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/counterpart_address_resource_list" +require_relative "../../types/counterpart_address" +require_relative "../../types/counterpart_address_response_with_counterpart_id" +require_relative "../../types/allowed_countries" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Counterparts + class AddressesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::AddressesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/addresses" +end + Monite::CounterpartAddressResourceList.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param request [Hash] Request of type Monite::CounterpartAddress, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.create(counterpart_id: "counterpart_id", request: { city: "Berlin", country: AF, line_1: "Flughafenstrasse 52", postal_code: "10115" }) + def create(counterpart_id:, request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/addresses" +end + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: response.body) + end + # @param address_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.get_by_id(address_id: "address_id", counterpart_id: "counterpart_id") + def get_by_id(address_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{address_id}/addresses/#{counterpart_id}" +end + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: response.body) + end + # @param address_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.delete_by_id(address_id: "address_id", counterpart_id: "counterpart_id") + def delete_by_id(address_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{address_id}/addresses/#{counterpart_id}" +end + end + # @param address_id [String] + # @param counterpart_id [String] + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.update_by_id(address_id: "address_id", counterpart_id: "counterpart_id") + def update_by_id(address_id:, counterpart_id:, city: nil, country: nil, line_1: nil, line_2: nil, postal_code: nil, state: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), city: city, country: country, line1: line_1, line2: line_2, postal_code: postal_code, state: state }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{address_id}/addresses/#{counterpart_id}" +end + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: response.body) + end + end + class AsyncAddressesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::AsyncAddressesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/addresses" +end + Monite::CounterpartAddressResourceList.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param request [Hash] Request of type Monite::CounterpartAddress, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.create(counterpart_id: "counterpart_id", request: { city: "Berlin", country: AF, line_1: "Flughafenstrasse 52", postal_code: "10115" }) + def create(counterpart_id:, request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/addresses" +end + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: response.body) + end + end + # @param address_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.get_by_id(address_id: "address_id", counterpart_id: "counterpart_id") + def get_by_id(address_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{address_id}/addresses/#{counterpart_id}" +end + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: response.body) + end + end + # @param address_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.delete_by_id(address_id: "address_id", counterpart_id: "counterpart_id") + def delete_by_id(address_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{address_id}/addresses/#{counterpart_id}" +end + end + end + # @param address_id [String] + # @param counterpart_id [String] + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.addresses.update_by_id(address_id: "address_id", counterpart_id: "counterpart_id") + def update_by_id(address_id:, counterpart_id:, city: nil, country: nil, line_1: nil, line_2: nil, postal_code: nil, state: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), city: city, country: country, line1: line_1, line2: line_2, postal_code: postal_code, state: state }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{address_id}/addresses/#{counterpart_id}" +end + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/counterparts/bank_accounts/client.rb b/lib/monite/counterparts/bank_accounts/client.rb new file mode 100644 index 0000000..4c3d0ab --- /dev/null +++ b/lib/monite/counterparts/bank_accounts/client.rb @@ -0,0 +1,551 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/counterpart_bank_account_resource_list" +require_relative "../../types/allowed_countries" +require_relative "../../types/currency_enum" +require_relative "../../types/counterpart_bank_account_response" +require "json" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Counterparts + class BankAccountsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::BankAccountsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/bank_accounts" +end + Monite::CounterpartBankAccountResourceList.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required for US +# bank accounts to accept ACH payments. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param bic [String] The BIC/SWIFT code of the bank. + # @param country [Monite::AllowedCountries] + # @param currency [Monite::CurrencyEnum] + # @param iban [String] The IBAN of the bank account. + # @param is_default_for_currency [Boolean] + # @param name [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs. + # @param routing_number [String] The bank's routing transit number (RTN). Required for US bank accounts to accept +# ACH payments. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.create( +# counterpart_id: "counterpart_id", +# country: AF, +# currency: AED +# ) + def create(counterpart_id:, account_holder_name: nil, account_number: nil, bic: nil, country:, currency:, iban: nil, is_default_for_currency: nil, name: nil, partner_metadata: nil, routing_number: nil, sort_code: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, account_number: account_number, bic: bic, country: country, currency: currency, iban: iban, is_default_for_currency: is_default_for_currency, name: name, partner_metadata: partner_metadata, routing_number: routing_number, sort_code: sort_code }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/bank_accounts" +end + Monite::CounterpartBankAccountResponse.from_json(json_object: response.body) + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.get_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def get_by_id(bank_account_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}" +end + Monite::CounterpartBankAccountResponse.from_json(json_object: response.body) + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.delete_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def delete_by_id(bank_account_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}" +end + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required for US +# bank accounts to accept ACH payments. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param bic [String] The BIC/SWIFT code of the bank. + # @param country [Monite::AllowedCountries] + # @param currency [Monite::CurrencyEnum] + # @param iban [String] The IBAN of the bank account. + # @param name [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs. + # @param routing_number [String] The bank's routing transit number (RTN). Required for US bank accounts to accept +# ACH payments. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.update_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def update_by_id(bank_account_id:, counterpart_id:, account_holder_name: nil, account_number: nil, bic: nil, country: nil, currency: nil, iban: nil, name: nil, partner_metadata: nil, routing_number: nil, sort_code: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, account_number: account_number, bic: bic, country: country, currency: currency, iban: iban, name: name, partner_metadata: partner_metadata, routing_number: routing_number, sort_code: sort_code }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}" +end + Monite::CounterpartBankAccountResponse.from_json(json_object: response.body) + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Object] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.make_default_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def make_default_by_id(bank_account_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}/make_default" +end + parsed_json = JSON.parse(response.body) + parsed_json + end + end + class AsyncBankAccountsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::AsyncBankAccountsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/bank_accounts" +end + Monite::CounterpartBankAccountResourceList.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required for US +# bank accounts to accept ACH payments. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param bic [String] The BIC/SWIFT code of the bank. + # @param country [Monite::AllowedCountries] + # @param currency [Monite::CurrencyEnum] + # @param iban [String] The IBAN of the bank account. + # @param is_default_for_currency [Boolean] + # @param name [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs. + # @param routing_number [String] The bank's routing transit number (RTN). Required for US bank accounts to accept +# ACH payments. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.create( +# counterpart_id: "counterpart_id", +# country: AF, +# currency: AED +# ) + def create(counterpart_id:, account_holder_name: nil, account_number: nil, bic: nil, country:, currency:, iban: nil, is_default_for_currency: nil, name: nil, partner_metadata: nil, routing_number: nil, sort_code: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, account_number: account_number, bic: bic, country: country, currency: currency, iban: iban, is_default_for_currency: is_default_for_currency, name: name, partner_metadata: partner_metadata, routing_number: routing_number, sort_code: sort_code }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/bank_accounts" +end + Monite::CounterpartBankAccountResponse.from_json(json_object: response.body) + end + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.get_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def get_by_id(bank_account_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}" +end + Monite::CounterpartBankAccountResponse.from_json(json_object: response.body) + end + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.delete_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def delete_by_id(bank_account_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}" +end + end + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required for US +# bank accounts to accept ACH payments. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param bic [String] The BIC/SWIFT code of the bank. + # @param country [Monite::AllowedCountries] + # @param currency [Monite::CurrencyEnum] + # @param iban [String] The IBAN of the bank account. + # @param name [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs. + # @param routing_number [String] The bank's routing transit number (RTN). Required for US bank accounts to accept +# ACH payments. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.update_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def update_by_id(bank_account_id:, counterpart_id:, account_holder_name: nil, account_number: nil, bic: nil, country: nil, currency: nil, iban: nil, name: nil, partner_metadata: nil, routing_number: nil, sort_code: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, account_number: account_number, bic: bic, country: country, currency: currency, iban: iban, name: name, partner_metadata: partner_metadata, routing_number: routing_number, sort_code: sort_code }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}" +end + Monite::CounterpartBankAccountResponse.from_json(json_object: response.body) + end + end + # @param bank_account_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Object] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.bank_accounts.make_default_by_id(bank_account_id: "bank_account_id", counterpart_id: "counterpart_id") + def make_default_by_id(bank_account_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{bank_account_id}/bank_accounts/#{counterpart_id}/make_default" +end + parsed_json = JSON.parse(response.body) + parsed_json + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/counterparts/client.rb b/lib/monite/counterparts/client.rb new file mode 100644 index 0000000..b33a389 --- /dev/null +++ b/lib/monite/counterparts/client.rb @@ -0,0 +1,646 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "addresses/client" +require_relative "bank_accounts/client" +require_relative "contacts/client" +require_relative "vat_ids/client" +require_relative "../types/order_enum" +require_relative "../types/counterpart_cursor_fields" +require_relative "../types/counterpart_type" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/counterpart_pagination_response" +require_relative "../types/counterpart_create_payload" +require_relative "../types/counterpart_response" +require_relative "../types/counterpart_update_payload" +require_relative "../types/partner_metadata_response" +require_relative "../types/partner_metadata" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class CounterpartsClient + # @return [Monite::RequestClient] + attr_reader :request_client + # @return [Monite::Counterparts::AddressesClient] + attr_reader :addresses + # @return [Monite::Counterparts::BankAccountsClient] + attr_reader :bank_accounts + # @return [Monite::Counterparts::ContactsClient] + attr_reader :contacts + # @return [Monite::Counterparts::VatIdsClient] + attr_reader :vat_ids + + + # @param request_client [Monite::RequestClient] + # @return [Monite::CounterpartsClient] + def initialize(request_client:) + @request_client = request_client + @addresses = Monite::Counterparts::AddressesClient.new(request_client: request_client) + @bank_accounts = Monite::Counterparts::BankAccountsClient.new(request_client: request_client) + @contacts = Monite::Counterparts::ContactsClient.new(request_client: request_client) + @vat_ids = Monite::Counterparts::VatIdsClient.new(request_client: request_client) + end + # @param iban [String] The IBAN of the counterpart's bank account. + # @param sort_code [String] The bank's sort code. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param tax_id [String] The tax ID of the counterpart. + # @param vat_id [String] The VAT ID of the counterpart. + # @param id_in [String] A list of counterpart IDs to search through. + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::COUNTERPART_CURSOR_FIELDS] Allowed sort fields + # @param type [Monite::CounterpartType] + # @param counterpart_name [String] + # @param counterpart_name_iexact [String] + # @param counterpart_name_contains [String] + # @param counterpart_name_icontains [String] + # @param is_vendor [Boolean] + # @param is_customer [Boolean] + # @param email [String] + # @param email_contains [String] + # @param email_icontains [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param address_country [String] + # @param address_city [String] + # @param address_postal_code [String] + # @param address_state [String] + # @param address_line_1 [String] + # @param address_line_2 [String] + # @param tag_ids_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.get(sort_code: "123456") + def get(iban: nil, sort_code: nil, account_number: nil, tax_id: nil, vat_id: nil, id_in: nil, order: nil, limit: nil, pagination_token: nil, sort: nil, type: nil, counterpart_name: nil, counterpart_name_iexact: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, is_vendor: nil, is_customer: nil, email: nil, email_contains: nil, email_icontains: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, address_country: nil, address_city: nil, address_postal_code: nil, address_state: nil, address_line_1: nil, address_line_2: nil, tag_ids_in: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "iban": iban, "sort_code": sort_code, "account_number": account_number, "tax_id": tax_id, "vat_id": vat_id, "id__in": id_in, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "type": type, "counterpart_name": counterpart_name, "counterpart_name__iexact": counterpart_name_iexact, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "is_vendor": is_vendor, "is_customer": is_customer, "email": email, "email__contains": email_contains, "email__icontains": email_icontains, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "address.country": address_country, "address.city": address_city, "address.postal_code": address_postal_code, "address.state": address_state, "address.line1": address_line_1, "address.line2": address_line_2, "tag_ids__in": tag_ids_in }.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)}/counterparts" +end + Monite::CounterpartPaginationResponse.from_json(json_object: response.body) + end + # @param request [Monite::CounterpartCreatePayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartIndividualRootResponse, Monite::CounterpartOrganizationRootResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.create + def create(request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts" +end + Monite::CounterpartResponse.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartIndividualRootResponse, Monite::CounterpartOrganizationRootResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.get_by_id(counterpart_id: "counterpart_id") + def get_by_id(counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}" +end + Monite::CounterpartResponse.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.delete_by_id(counterpart_id: "counterpart_id") + def delete_by_id(counterpart_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}" +end + end + # @param counterpart_id [String] + # @param request [Monite::CounterpartIndividualRootUpdatePayload, Monite::CounterpartOrganizationRootUpdatePayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartIndividualRootResponse, Monite::CounterpartOrganizationRootResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.update_by_id(counterpart_id: "counterpart_id", request: { individual: { } }) + def update_by_id(counterpart_id:, request:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}" +end + Monite::CounterpartResponse.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.get_partner_metadata_by_id(counterpart_id: "counterpart_id") + def get_partner_metadata_by_id(counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param request [Hash] Request of type Monite::PartnerMetadata, as a Hash + # * :metadata (Hash{String => Object}) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.update_partner_metadata_by_id(counterpart_id: "counterpart_id", request: { metadata: { "key": "value" } }) + def update_partner_metadata_by_id(counterpart_id:, request:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end + end + class AsyncCounterpartsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + # @return [Monite::Counterparts::AddressesClient] + attr_reader :addresses + # @return [Monite::Counterparts::BankAccountsClient] + attr_reader :bank_accounts + # @return [Monite::Counterparts::ContactsClient] + attr_reader :contacts + # @return [Monite::Counterparts::VatIdsClient] + attr_reader :vat_ids + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncCounterpartsClient] + def initialize(request_client:) + @request_client = request_client + @addresses = Monite::Counterparts::AsyncAddressesClient.new(request_client: request_client) + @bank_accounts = Monite::Counterparts::AsyncBankAccountsClient.new(request_client: request_client) + @contacts = Monite::Counterparts::AsyncContactsClient.new(request_client: request_client) + @vat_ids = Monite::Counterparts::AsyncVatIdsClient.new(request_client: request_client) + end + # @param iban [String] The IBAN of the counterpart's bank account. + # @param sort_code [String] The bank's sort code. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param tax_id [String] The tax ID of the counterpart. + # @param vat_id [String] The VAT ID of the counterpart. + # @param id_in [String] A list of counterpart IDs to search through. + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::COUNTERPART_CURSOR_FIELDS] Allowed sort fields + # @param type [Monite::CounterpartType] + # @param counterpart_name [String] + # @param counterpart_name_iexact [String] + # @param counterpart_name_contains [String] + # @param counterpart_name_icontains [String] + # @param is_vendor [Boolean] + # @param is_customer [Boolean] + # @param email [String] + # @param email_contains [String] + # @param email_icontains [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param address_country [String] + # @param address_city [String] + # @param address_postal_code [String] + # @param address_state [String] + # @param address_line_1 [String] + # @param address_line_2 [String] + # @param tag_ids_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.get(sort_code: "123456") + def get(iban: nil, sort_code: nil, account_number: nil, tax_id: nil, vat_id: nil, id_in: nil, order: nil, limit: nil, pagination_token: nil, sort: nil, type: nil, counterpart_name: nil, counterpart_name_iexact: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, is_vendor: nil, is_customer: nil, email: nil, email_contains: nil, email_icontains: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, address_country: nil, address_city: nil, address_postal_code: nil, address_state: nil, address_line_1: nil, address_line_2: nil, tag_ids_in: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "iban": iban, "sort_code": sort_code, "account_number": account_number, "tax_id": tax_id, "vat_id": vat_id, "id__in": id_in, "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "type": type, "counterpart_name": counterpart_name, "counterpart_name__iexact": counterpart_name_iexact, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "is_vendor": is_vendor, "is_customer": is_customer, "email": email, "email__contains": email_contains, "email__icontains": email_icontains, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "address.country": address_country, "address.city": address_city, "address.postal_code": address_postal_code, "address.state": address_state, "address.line1": address_line_1, "address.line2": address_line_2, "tag_ids__in": tag_ids_in }.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)}/counterparts" +end + Monite::CounterpartPaginationResponse.from_json(json_object: response.body) + end + end + # @param request [Monite::CounterpartCreatePayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartIndividualRootResponse, Monite::CounterpartOrganizationRootResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.create + def create(request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts" +end + Monite::CounterpartResponse.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartIndividualRootResponse, Monite::CounterpartOrganizationRootResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.get_by_id(counterpart_id: "counterpart_id") + def get_by_id(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}" +end + Monite::CounterpartResponse.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.delete_by_id(counterpart_id: "counterpart_id") + def delete_by_id(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}" +end + end + end + # @param counterpart_id [String] + # @param request [Monite::CounterpartIndividualRootUpdatePayload, Monite::CounterpartOrganizationRootUpdatePayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartIndividualRootResponse, Monite::CounterpartOrganizationRootResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.update_by_id(counterpart_id: "counterpart_id", request: { individual: { } }) + def update_by_id(counterpart_id:, request:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}" +end + Monite::CounterpartResponse.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.get_partner_metadata_by_id(counterpart_id: "counterpart_id") + def get_partner_metadata_by_id(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param request [Hash] Request of type Monite::PartnerMetadata, as a Hash + # * :metadata (Hash{String => Object}) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.update_partner_metadata_by_id(counterpart_id: "counterpart_id", request: { metadata: { "key": "value" } }) + def update_partner_metadata_by_id(counterpart_id:, request:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/counterparts/contacts/client.rb b/lib/monite/counterparts/contacts/client.rb new file mode 100644 index 0000000..ec79708 --- /dev/null +++ b/lib/monite/counterparts/contacts/client.rb @@ -0,0 +1,539 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/counterpart_contacts_resource_list" +require_relative "../../types/counterpart_address" +require_relative "../../types/counterpart_contact_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Counterparts + class ContactsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::ContactsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactsResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/contacts" +end + Monite::CounterpartContactsResourceList.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param address [Hash] The address of a contact person.Request of type Monite::CounterpartAddress, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param email [String] The email address of a contact person. + # @param first_name [String] The first name of a contact person. + # @param last_name [String] The last name of a contact person. + # @param phone [String] The phone number of a contact person + # @param title [String] The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.create( +# counterpart_id: "counterpart_id", +# address: { city: "Berlin", country: AF, line_1: "Flughafenstrasse 52", postal_code: "10115" }, +# first_name: "Mary", +# last_name: "O'Brien" +# ) + def create(counterpart_id:, address:, email: nil, first_name:, last_name:, phone: nil, title: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, email: email, first_name: first_name, last_name: last_name, phone: phone, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/contacts" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.get_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def get_by_id(contact_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{contact_id}/contacts/#{counterpart_id}" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.delete_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def delete_by_id(contact_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{contact_id}/contacts/#{counterpart_id}" +end + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param address [Hash] The address of a contact person.Request of type Monite::CounterpartAddress, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param email [String] The email address of a contact person. + # @param first_name [String] The first name of a contact person. + # @param last_name [String] The last name of a contact person. + # @param phone [String] The phone number of a contact person + # @param title [String] The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.update_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def update_by_id(contact_id:, counterpart_id:, address: nil, email: nil, first_name: nil, last_name: nil, phone: nil, title: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, email: email, first_name: first_name, last_name: last_name, phone: phone, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{contact_id}/contacts/#{counterpart_id}" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.make_default_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def make_default_by_id(contact_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{contact_id}/contacts/#{counterpart_id}/make_default" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + end + class AsyncContactsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::AsyncContactsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactsResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/contacts" +end + Monite::CounterpartContactsResourceList.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param address [Hash] The address of a contact person.Request of type Monite::CounterpartAddress, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param email [String] The email address of a contact person. + # @param first_name [String] The first name of a contact person. + # @param last_name [String] The last name of a contact person. + # @param phone [String] The phone number of a contact person + # @param title [String] The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.create( +# counterpart_id: "counterpart_id", +# address: { city: "Berlin", country: AF, line_1: "Flughafenstrasse 52", postal_code: "10115" }, +# first_name: "Mary", +# last_name: "O'Brien" +# ) + def create(counterpart_id:, address:, email: nil, first_name:, last_name:, phone: nil, title: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, email: email, first_name: first_name, last_name: last_name, phone: phone, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/contacts" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.get_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def get_by_id(contact_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{contact_id}/contacts/#{counterpart_id}" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.delete_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def delete_by_id(contact_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{contact_id}/contacts/#{counterpart_id}" +end + end + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param address [Hash] The address of a contact person.Request of type Monite::CounterpartAddress, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param email [String] The email address of a contact person. + # @param first_name [String] The first name of a contact person. + # @param last_name [String] The last name of a contact person. + # @param phone [String] The phone number of a contact person + # @param title [String] The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.update_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def update_by_id(contact_id:, counterpart_id:, address: nil, email: nil, first_name: nil, last_name: nil, phone: nil, title: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, email: email, first_name: first_name, last_name: last_name, phone: phone, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{contact_id}/contacts/#{counterpart_id}" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + end + # @param contact_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartContactResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.contacts.make_default_by_id(contact_id: "contact_id", counterpart_id: "counterpart_id") + def make_default_by_id(contact_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{contact_id}/contacts/#{counterpart_id}/make_default" +end + Monite::CounterpartContactResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/counterparts/vat_ids/client.rb b/lib/monite/counterparts/vat_ids/client.rb new file mode 100644 index 0000000..c558ace --- /dev/null +++ b/lib/monite/counterparts/vat_ids/client.rb @@ -0,0 +1,417 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/counterpart_vat_id_resource_list" +require_relative "../../types/allowed_countries" +require_relative "../../types/vat_id_type_enum" +require_relative "../../types/counterpart_vat_id_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Counterparts + class VatIdsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::VatIdsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/vat_ids" +end + Monite::CounterpartVatIdResourceList.from_json(json_object: response.body) + end + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.create(counterpart_id: "counterpart_id", value: "123456789") + def create(counterpart_id:, country: nil, type: nil, value:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/vat_ids" +end + Monite::CounterpartVatIdResponse.from_json(json_object: response.body) + end + # @param vat_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.get_by_id(vat_id: "vat_id", counterpart_id: "counterpart_id") + def get_by_id(vat_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{vat_id}/vat_ids/#{counterpart_id}" +end + Monite::CounterpartVatIdResponse.from_json(json_object: response.body) + end + # @param vat_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.delete_by_id(vat_id: "vat_id", counterpart_id: "counterpart_id") + def delete_by_id(vat_id:, counterpart_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{vat_id}/vat_ids/#{counterpart_id}" +end + end + # @param vat_id [String] + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.update_by_id(vat_id: "vat_id", counterpart_id: "counterpart_id") + def update_by_id(vat_id:, counterpart_id:, country: nil, type: nil, value: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{vat_id}/vat_ids/#{counterpart_id}" +end + Monite::CounterpartVatIdResponse.from_json(json_object: response.body) + end + end + class AsyncVatIdsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Counterparts::AsyncVatIdsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.get(counterpart_id: "counterpart_id") + def get(counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{counterpart_id}/vat_ids" +end + Monite::CounterpartVatIdResourceList.from_json(json_object: response.body) + end + end + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.create(counterpart_id: "counterpart_id", value: "123456789") + def create(counterpart_id:, country: nil, type: nil, value:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{counterpart_id}/vat_ids" +end + Monite::CounterpartVatIdResponse.from_json(json_object: response.body) + end + end + # @param vat_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.get_by_id(vat_id: "vat_id", counterpart_id: "counterpart_id") + def get_by_id(vat_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{vat_id}/vat_ids/#{counterpart_id}" +end + Monite::CounterpartVatIdResponse.from_json(json_object: response.body) + end + end + # @param vat_id [String] + # @param counterpart_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.delete_by_id(vat_id: "vat_id", counterpart_id: "counterpart_id") + def delete_by_id(vat_id:, counterpart_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/counterparts/#{vat_id}/vat_ids/#{counterpart_id}" +end + end + end + # @param vat_id [String] + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CounterpartVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.counterparts.vat_ids.update_by_id(vat_id: "vat_id", counterpart_id: "counterpart_id") + def update_by_id(vat_id:, counterpart_id:, country: nil, type: nil, value: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/counterparts/#{vat_id}/vat_ids/#{counterpart_id}" +end + Monite::CounterpartVatIdResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/credit_notes/client.rb b/lib/monite/credit_notes/client.rb new file mode 100644 index 0000000..cdc3626 --- /dev/null +++ b/lib/monite/credit_notes/client.rb @@ -0,0 +1,1616 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/credit_note_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/credit_note_state_enum" +require_relative "../types/currency_enum" +require_relative "../types/credit_note_pagination_response" +require_relative "../types/credit_note_response" +require_relative "../../core/file_utilities" +require_relative "../types/credit_note_line_item_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/credit_note_line_item_pagination_response" +require_relative "../types/credit_note_line_item_create_request" +require_relative "../types/credit_note_line_item_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class CreditNotesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::CreditNotesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::CreditNoteCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param issued_at [String] + # @param issued_at_gt [String] + # @param issued_at_lt [String] + # @param issued_at_gte [String] + # @param issued_at_lte [String] + # @param document_id [String] + # @param document_id_iexact [String] + # @param document_id_contains [String] + # @param document_id_icontains [String] + # @param total_amount_gt [Integer] + # @param total_amount_lt [Integer] + # @param total_amount_gte [Integer] + # @param total_amount_lte [Integer] + # @param subtotal_gt [Integer] + # @param subtotal_lt [Integer] + # @param subtotal_gte [Integer] + # @param subtotal_lte [Integer] + # @param based_on [String] + # @param counterpart_id [String] + # @param created_by_entity_user_id [String] + # @param status [Monite::CreditNoteStateEnum] + # @param status_in [Monite::CreditNoteStateEnum] + # @param status_not_in [Monite::CreditNoteStateEnum] + # @param currency [Monite::CurrencyEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNotePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes + def get_payable_credit_notes(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, issued_at: nil, issued_at_gt: nil, issued_at_lt: nil, issued_at_gte: nil, issued_at_lte: nil, document_id: nil, document_id_iexact: nil, document_id_contains: nil, document_id_icontains: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, subtotal_gt: nil, subtotal_lt: nil, subtotal_gte: nil, subtotal_lte: nil, based_on: nil, counterpart_id: nil, created_by_entity_user_id: nil, status: nil, status_in: nil, status_not_in: nil, currency: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "issued_at": issued_at, "issued_at__gt": issued_at_gt, "issued_at__lt": issued_at_lt, "issued_at__gte": issued_at_gte, "issued_at__lte": issued_at_lte, "document_id": document_id, "document_id__iexact": document_id_iexact, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "subtotal__gt": subtotal_gt, "subtotal__lt": subtotal_lt, "subtotal__gte": subtotal_gte, "subtotal__lte": subtotal_lte, "based_on": based_on, "counterpart_id": counterpart_id, "created_by_entity_user_id": created_by_entity_user_id, "status": status, "status__in": status_in, "status__not_in": status_not_in, "currency": currency }.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)}/payable_credit_notes" +end + Monite::CreditNotePaginationResponse.from_json(json_object: response.body) + end + # @param based_on [String] ID of the payable this credit note is based on. The credit note will be linked +# to this payable + # @param based_on_document_id [String] The document ID of the original payable that this credit note refers to + # @param counterpart_address_id [String] The ID of the counterpart's address + # @param counterpart_bank_account_id [String] The ID of the counterpart's bank account + # @param counterpart_id [String] The ID of the counterpart (vendor/supplier) + # @param counterpart_vat_id_id [String] The ID of the counterpart's VAT registration + # @param currency [Monite::CurrencyEnum] The currency code of the credit note + # @param description [String] An arbitrary description of this credit note + # @param document_id [String] A unique credit note number assigned by the credit note issuer for tracking +# purposes + # @param issued_at [String] The date when the credit note was issued, in the YYYY-MM-DD format + # @param project_id [String] The ID of the project this credit note belongs to + # @param sender [String] The email address from which the credit note was received + # @param subtotal [Integer] The subtotal amount before taxes + # @param tag_ids [Array] List of tag IDs associated with this credit note + # @param tax [Integer] The tax percentage applied to the subtotal + # @param tax_amount [Integer] The calculated tax amount + # @param total_amount [Integer] The total amount including taxes + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes(document_id: "CN-2287", issued_at: "2024-01-15") + def post_payable_credit_notes(based_on: nil, based_on_document_id: nil, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, document_id:, issued_at:, project_id: nil, sender: nil, subtotal: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), based_on: based_on, based_on_document_id: based_on_document_id, counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, document_id: document_id, issued_at: issued_at, project_id: project_id, sender: sender, subtotal: subtotal, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end +# Upload an incoming credit note (payable) in PDF, PNG, JPEG, or TIFF format and +# scan its contents. The maximum file size is 10MB. + # + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_upload_from_file(file: my_file.txt) + def post_payable_credit_notes_upload_from_file(file:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/upload_from_file" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes_id(credit_note_id: "credit_note_id") + def get_payable_credit_notes_id(credit_note_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.delete_payable_credit_notes_id(credit_note_id: "credit_note_id") + def delete_payable_credit_notes_id(credit_note_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}" +end + end + # @param credit_note_id [String] + # @param based_on [String] ID of the payable this credit note is based on. The credit note will be linked +# to this payable + # @param based_on_document_id [String] The document ID of the original payable + # @param counterpart_address_id [String] ID of the counterpart's address + # @param counterpart_bank_account_id [String] ID of the counterpart's bank account + # @param counterpart_id [String] ID of the counterpart + # @param counterpart_vat_id_id [String] ID of the counterpart's VAT registration + # @param currency [Monite::CurrencyEnum] The currency code of the credit note + # @param description [String] An arbitrary description of this credit note + # @param document_id [String] A unique credit note number assigned by the credit note issuer for tracking +# purposes + # @param issued_at [String] The date when the credit note was issued, in the YYYY-MM-DD format + # @param project_id [String] The ID of the project this credit note belongs to + # @param sender [String] Email address of the sender + # @param subtotal [Integer] The subtotal amount before taxes + # @param tag_ids [Array] List of tag IDs associated with this credit note + # @param tax [Integer] The tax percentage applied to the subtotal + # @param tax_amount [Integer] The calculated tax amount + # @param total_amount [Integer] The total amount including taxes + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.patch_payable_credit_notes_id(credit_note_id: "credit_note_id") + def patch_payable_credit_notes_id(credit_note_id:, based_on: nil, based_on_document_id: nil, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, document_id: nil, issued_at: nil, project_id: nil, sender: nil, subtotal: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), based_on: based_on, based_on_document_id: based_on_document_id, counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, document_id: document_id, issued_at: issued_at, project_id: project_id, sender: sender, subtotal: subtotal, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end +# Approve the credit note for appliance. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_approve(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_approve(credit_note_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/approve" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end +# Cancel the credit note that was not confirmed during the review. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_cancel(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_cancel(credit_note_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/cancel" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end +# Request to cancel the OCR processing of the specified credit note. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_cancel_ocr(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_cancel_ocr(credit_note_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/cancel_ocr" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::CreditNoteLineItemCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param name [String] + # @param name_iexact [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param description [String] + # @param description_contains [String] + # @param description_icontains [String] + # @param total_gt [Integer] + # @param total_lt [Integer] + # @param total_gte [Integer] + # @param total_lte [Integer] + # @param subtotal_gt [Integer] + # @param subtotal_lt [Integer] + # @param subtotal_gte [Integer] + # @param subtotal_lte [Integer] + # @param unit_price_gt [Integer] + # @param unit_price_lt [Integer] + # @param unit_price_gte [Integer] + # @param unit_price_lte [Integer] + # @param quantity_gt [Float] + # @param quantity_lt [Float] + # @param quantity_gte [Float] + # @param quantity_lte [Float] + # @param tax_gt [Integer] + # @param tax_lt [Integer] + # @param tax_gte [Integer] + # @param tax_lte [Integer] + # @param tax_amount_gt [Integer] + # @param tax_amount_lt [Integer] + # @param tax_amount_gte [Integer] + # @param tax_amount_lte [Integer] + # @param created_by_user_id [String] + # @param unit [String] + # @param unit_iexact [String] + # @param source [String] + # @param source_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes_id_line_items(credit_note_id: "credit_note_id") + def get_payable_credit_notes_id_line_items(credit_note_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, name: nil, name_iexact: nil, name_contains: nil, name_icontains: nil, description: nil, description_contains: nil, description_icontains: nil, total_gt: nil, total_lt: nil, total_gte: nil, total_lte: nil, subtotal_gt: nil, subtotal_lt: nil, subtotal_gte: nil, subtotal_lte: nil, unit_price_gt: nil, unit_price_lt: nil, unit_price_gte: nil, unit_price_lte: nil, quantity_gt: nil, quantity_lt: nil, quantity_gte: nil, quantity_lte: nil, tax_gt: nil, tax_lt: nil, tax_gte: nil, tax_lte: nil, tax_amount_gt: nil, tax_amount_lt: nil, tax_amount_gte: nil, tax_amount_lte: nil, created_by_user_id: nil, unit: nil, unit_iexact: nil, source: nil, source_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "name": name, "name__iexact": name_iexact, "name__contains": name_contains, "name__icontains": name_icontains, "description": description, "description__contains": description_contains, "description__icontains": description_icontains, "total__gt": total_gt, "total__lt": total_lt, "total__gte": total_gte, "total__lte": total_lte, "subtotal__gt": subtotal_gt, "subtotal__lt": subtotal_lt, "subtotal__gte": subtotal_gte, "subtotal__lte": subtotal_lte, "unit_price__gt": unit_price_gt, "unit_price__lt": unit_price_lt, "unit_price__gte": unit_price_gte, "unit_price__lte": unit_price_lte, "quantity__gt": quantity_gt, "quantity__lt": quantity_lt, "quantity__gte": quantity_gte, "quantity__lte": quantity_lte, "tax__gt": tax_gt, "tax__lt": tax_lt, "tax__gte": tax_gte, "tax__lte": tax_lte, "tax_amount__gt": tax_amount_gt, "tax_amount__lt": tax_amount_lt, "tax_amount__gte": tax_amount_gte, "tax_amount__lte": tax_amount_lte, "created_by_user_id": created_by_user_id, "unit": unit, "unit__iexact": unit_iexact, "source": source, "source_id": source_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)}/payable_credit_notes/#{credit_note_id}/line_items" +end + Monite::CreditNoteLineItemPaginationResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param request [Hash] Request of type Monite::CreditNoteLineItemCreateRequest, as a Hash + # * :description (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_line_items(credit_note_id: "credit_note_id", request: { }) + def post_payable_credit_notes_id_line_items(credit_note_id:, request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}/line_items" +end + Monite::CreditNoteLineItemResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param data [Array] List of credit note line items to replace existing onesRequest of type Array, as a Hash + # * :description (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.put_payable_credit_notes_id_line_items(credit_note_id: "credit_note_id", data: [{ }]) + def put_payable_credit_notes_id_line_items(credit_note_id:, data:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), data: data }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}/line_items" +end + Monite::CreditNoteLineItemPaginationResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param line_item_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes_id_line_items_id(credit_note_id: "credit_note_id", line_item_id: "line_item_id") + def get_payable_credit_notes_id_line_items_id(credit_note_id:, line_item_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/line_items/#{line_item_id}" +end + Monite::CreditNoteLineItemResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param line_item_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.delete_payable_credit_notes_id_line_items_id(credit_note_id: "credit_note_id", line_item_id: "line_item_id") + def delete_payable_credit_notes_id_line_items_id(credit_note_id:, line_item_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/line_items/#{line_item_id}" +end + Monite::CreditNoteLineItemPaginationResponse.from_json(json_object: response.body) + end + # @param credit_note_id [String] + # @param line_item_id [String] + # @param description [String] Detailed description of the line item + # @param name [String] Name or title of the line item + # @param quantity [Float] Quantity of items + # @param tax [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param unit [String] Unit of measurement + # @param unit_price [Integer] Price per unit in smallest currency unit + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.patch_payable_credit_notes_id_line_items_id(credit_note_id: "credit_note_id", line_item_id: "line_item_id") + def patch_payable_credit_notes_id_line_items_id(credit_note_id:, line_item_id:, description: nil, name: nil, quantity: nil, tax: nil, unit: nil, unit_price: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name, quantity: quantity, tax: tax, unit: unit, unit_price: unit_price }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}/line_items/#{line_item_id}" +end + Monite::CreditNoteLineItemResponse.from_json(json_object: response.body) + end +# Decline the credit note when an approver finds any mismatch or discrepancies. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_reject(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_reject(credit_note_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/reject" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end +# Start the approval process once the uploaded credit note is validated. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_submit_for_approval(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_submit_for_approval(credit_note_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/submit_for_approval" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end + class AsyncCreditNotesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncCreditNotesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::CreditNoteCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param issued_at [String] + # @param issued_at_gt [String] + # @param issued_at_lt [String] + # @param issued_at_gte [String] + # @param issued_at_lte [String] + # @param document_id [String] + # @param document_id_iexact [String] + # @param document_id_contains [String] + # @param document_id_icontains [String] + # @param total_amount_gt [Integer] + # @param total_amount_lt [Integer] + # @param total_amount_gte [Integer] + # @param total_amount_lte [Integer] + # @param subtotal_gt [Integer] + # @param subtotal_lt [Integer] + # @param subtotal_gte [Integer] + # @param subtotal_lte [Integer] + # @param based_on [String] + # @param counterpart_id [String] + # @param created_by_entity_user_id [String] + # @param status [Monite::CreditNoteStateEnum] + # @param status_in [Monite::CreditNoteStateEnum] + # @param status_not_in [Monite::CreditNoteStateEnum] + # @param currency [Monite::CurrencyEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNotePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes + def get_payable_credit_notes(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, issued_at: nil, issued_at_gt: nil, issued_at_lt: nil, issued_at_gte: nil, issued_at_lte: nil, document_id: nil, document_id_iexact: nil, document_id_contains: nil, document_id_icontains: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, subtotal_gt: nil, subtotal_lt: nil, subtotal_gte: nil, subtotal_lte: nil, based_on: nil, counterpart_id: nil, created_by_entity_user_id: nil, status: nil, status_in: nil, status_not_in: nil, currency: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "issued_at": issued_at, "issued_at__gt": issued_at_gt, "issued_at__lt": issued_at_lt, "issued_at__gte": issued_at_gte, "issued_at__lte": issued_at_lte, "document_id": document_id, "document_id__iexact": document_id_iexact, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "subtotal__gt": subtotal_gt, "subtotal__lt": subtotal_lt, "subtotal__gte": subtotal_gte, "subtotal__lte": subtotal_lte, "based_on": based_on, "counterpart_id": counterpart_id, "created_by_entity_user_id": created_by_entity_user_id, "status": status, "status__in": status_in, "status__not_in": status_not_in, "currency": currency }.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)}/payable_credit_notes" +end + Monite::CreditNotePaginationResponse.from_json(json_object: response.body) + end + end + # @param based_on [String] ID of the payable this credit note is based on. The credit note will be linked +# to this payable + # @param based_on_document_id [String] The document ID of the original payable that this credit note refers to + # @param counterpart_address_id [String] The ID of the counterpart's address + # @param counterpart_bank_account_id [String] The ID of the counterpart's bank account + # @param counterpart_id [String] The ID of the counterpart (vendor/supplier) + # @param counterpart_vat_id_id [String] The ID of the counterpart's VAT registration + # @param currency [Monite::CurrencyEnum] The currency code of the credit note + # @param description [String] An arbitrary description of this credit note + # @param document_id [String] A unique credit note number assigned by the credit note issuer for tracking +# purposes + # @param issued_at [String] The date when the credit note was issued, in the YYYY-MM-DD format + # @param project_id [String] The ID of the project this credit note belongs to + # @param sender [String] The email address from which the credit note was received + # @param subtotal [Integer] The subtotal amount before taxes + # @param tag_ids [Array] List of tag IDs associated with this credit note + # @param tax [Integer] The tax percentage applied to the subtotal + # @param tax_amount [Integer] The calculated tax amount + # @param total_amount [Integer] The total amount including taxes + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes(document_id: "CN-2287", issued_at: "2024-01-15") + def post_payable_credit_notes(based_on: nil, based_on_document_id: nil, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, document_id:, issued_at:, project_id: nil, sender: nil, subtotal: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), based_on: based_on, based_on_document_id: based_on_document_id, counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, document_id: document_id, issued_at: issued_at, project_id: project_id, sender: sender, subtotal: subtotal, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end +# Upload an incoming credit note (payable) in PDF, PNG, JPEG, or TIFF format and +# scan its contents. The maximum file size is 10MB. + # + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_upload_from_file(file: my_file.txt) + def post_payable_credit_notes_upload_from_file(file:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/upload_from_file" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes_id(credit_note_id: "credit_note_id") + def get_payable_credit_notes_id(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.delete_payable_credit_notes_id(credit_note_id: "credit_note_id") + def delete_payable_credit_notes_id(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}" +end + end + end + # @param credit_note_id [String] + # @param based_on [String] ID of the payable this credit note is based on. The credit note will be linked +# to this payable + # @param based_on_document_id [String] The document ID of the original payable + # @param counterpart_address_id [String] ID of the counterpart's address + # @param counterpart_bank_account_id [String] ID of the counterpart's bank account + # @param counterpart_id [String] ID of the counterpart + # @param counterpart_vat_id_id [String] ID of the counterpart's VAT registration + # @param currency [Monite::CurrencyEnum] The currency code of the credit note + # @param description [String] An arbitrary description of this credit note + # @param document_id [String] A unique credit note number assigned by the credit note issuer for tracking +# purposes + # @param issued_at [String] The date when the credit note was issued, in the YYYY-MM-DD format + # @param project_id [String] The ID of the project this credit note belongs to + # @param sender [String] Email address of the sender + # @param subtotal [Integer] The subtotal amount before taxes + # @param tag_ids [Array] List of tag IDs associated with this credit note + # @param tax [Integer] The tax percentage applied to the subtotal + # @param tax_amount [Integer] The calculated tax amount + # @param total_amount [Integer] The total amount including taxes + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.patch_payable_credit_notes_id(credit_note_id: "credit_note_id") + def patch_payable_credit_notes_id(credit_note_id:, based_on: nil, based_on_document_id: nil, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, document_id: nil, issued_at: nil, project_id: nil, sender: nil, subtotal: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), based_on: based_on, based_on_document_id: based_on_document_id, counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, document_id: document_id, issued_at: issued_at, project_id: project_id, sender: sender, subtotal: subtotal, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end +# Approve the credit note for appliance. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_approve(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_approve(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/approve" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end +# Cancel the credit note that was not confirmed during the review. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_cancel(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_cancel(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/cancel" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end +# Request to cancel the OCR processing of the specified credit note. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_cancel_ocr(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_cancel_ocr(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/cancel_ocr" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::CreditNoteLineItemCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param name [String] + # @param name_iexact [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param description [String] + # @param description_contains [String] + # @param description_icontains [String] + # @param total_gt [Integer] + # @param total_lt [Integer] + # @param total_gte [Integer] + # @param total_lte [Integer] + # @param subtotal_gt [Integer] + # @param subtotal_lt [Integer] + # @param subtotal_gte [Integer] + # @param subtotal_lte [Integer] + # @param unit_price_gt [Integer] + # @param unit_price_lt [Integer] + # @param unit_price_gte [Integer] + # @param unit_price_lte [Integer] + # @param quantity_gt [Float] + # @param quantity_lt [Float] + # @param quantity_gte [Float] + # @param quantity_lte [Float] + # @param tax_gt [Integer] + # @param tax_lt [Integer] + # @param tax_gte [Integer] + # @param tax_lte [Integer] + # @param tax_amount_gt [Integer] + # @param tax_amount_lt [Integer] + # @param tax_amount_gte [Integer] + # @param tax_amount_lte [Integer] + # @param created_by_user_id [String] + # @param unit [String] + # @param unit_iexact [String] + # @param source [String] + # @param source_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes_id_line_items(credit_note_id: "credit_note_id") + def get_payable_credit_notes_id_line_items(credit_note_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, name: nil, name_iexact: nil, name_contains: nil, name_icontains: nil, description: nil, description_contains: nil, description_icontains: nil, total_gt: nil, total_lt: nil, total_gte: nil, total_lte: nil, subtotal_gt: nil, subtotal_lt: nil, subtotal_gte: nil, subtotal_lte: nil, unit_price_gt: nil, unit_price_lt: nil, unit_price_gte: nil, unit_price_lte: nil, quantity_gt: nil, quantity_lt: nil, quantity_gte: nil, quantity_lte: nil, tax_gt: nil, tax_lt: nil, tax_gte: nil, tax_lte: nil, tax_amount_gt: nil, tax_amount_lt: nil, tax_amount_gte: nil, tax_amount_lte: nil, created_by_user_id: nil, unit: nil, unit_iexact: nil, source: nil, source_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "name": name, "name__iexact": name_iexact, "name__contains": name_contains, "name__icontains": name_icontains, "description": description, "description__contains": description_contains, "description__icontains": description_icontains, "total__gt": total_gt, "total__lt": total_lt, "total__gte": total_gte, "total__lte": total_lte, "subtotal__gt": subtotal_gt, "subtotal__lt": subtotal_lt, "subtotal__gte": subtotal_gte, "subtotal__lte": subtotal_lte, "unit_price__gt": unit_price_gt, "unit_price__lt": unit_price_lt, "unit_price__gte": unit_price_gte, "unit_price__lte": unit_price_lte, "quantity__gt": quantity_gt, "quantity__lt": quantity_lt, "quantity__gte": quantity_gte, "quantity__lte": quantity_lte, "tax__gt": tax_gt, "tax__lt": tax_lt, "tax__gte": tax_gte, "tax__lte": tax_lte, "tax_amount__gt": tax_amount_gt, "tax_amount__lt": tax_amount_lt, "tax_amount__gte": tax_amount_gte, "tax_amount__lte": tax_amount_lte, "created_by_user_id": created_by_user_id, "unit": unit, "unit__iexact": unit_iexact, "source": source, "source_id": source_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)}/payable_credit_notes/#{credit_note_id}/line_items" +end + Monite::CreditNoteLineItemPaginationResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param request [Hash] Request of type Monite::CreditNoteLineItemCreateRequest, as a Hash + # * :description (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_line_items(credit_note_id: "credit_note_id", request: { }) + def post_payable_credit_notes_id_line_items(credit_note_id:, request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}/line_items" +end + Monite::CreditNoteLineItemResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param data [Array] List of credit note line items to replace existing onesRequest of type Array, as a Hash + # * :description (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.put_payable_credit_notes_id_line_items(credit_note_id: "credit_note_id", data: [{ }]) + def put_payable_credit_notes_id_line_items(credit_note_id:, data:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), data: data }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}/line_items" +end + Monite::CreditNoteLineItemPaginationResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param line_item_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.get_payable_credit_notes_id_line_items_id(credit_note_id: "credit_note_id", line_item_id: "line_item_id") + def get_payable_credit_notes_id_line_items_id(credit_note_id:, line_item_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/line_items/#{line_item_id}" +end + Monite::CreditNoteLineItemResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param line_item_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.delete_payable_credit_notes_id_line_items_id(credit_note_id: "credit_note_id", line_item_id: "line_item_id") + def delete_payable_credit_notes_id_line_items_id(credit_note_id:, line_item_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/line_items/#{line_item_id}" +end + Monite::CreditNoteLineItemPaginationResponse.from_json(json_object: response.body) + end + end + # @param credit_note_id [String] + # @param line_item_id [String] + # @param description [String] Detailed description of the line item + # @param name [String] Name or title of the line item + # @param quantity [Float] Quantity of items + # @param tax [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param unit [String] Unit of measurement + # @param unit_price [Integer] Price per unit in smallest currency unit + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteLineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.patch_payable_credit_notes_id_line_items_id(credit_note_id: "credit_note_id", line_item_id: "line_item_id") + def patch_payable_credit_notes_id_line_items_id(credit_note_id:, line_item_id:, description: nil, name: nil, quantity: nil, tax: nil, unit: nil, unit_price: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name, quantity: quantity, tax: tax, unit: unit, unit_price: unit_price }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_credit_notes/#{credit_note_id}/line_items/#{line_item_id}" +end + Monite::CreditNoteLineItemResponse.from_json(json_object: response.body) + end + end +# Decline the credit note when an approver finds any mismatch or discrepancies. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_reject(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_reject(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/reject" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end +# Start the approval process once the uploaded credit note is validated. + # + # @param credit_note_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreditNoteResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.credit_notes.post_payable_credit_notes_id_submit_for_approval(credit_note_id: "credit_note_id") + def post_payable_credit_notes_id_submit_for_approval(credit_note_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_credit_notes/#{credit_note_id}/submit_for_approval" +end + Monite::CreditNoteResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/data_exports/client.rb b/lib/monite/data_exports/client.rb new file mode 100644 index 0000000..86cbe89 --- /dev/null +++ b/lib/monite/data_exports/client.rb @@ -0,0 +1,384 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "extra_data/client" +require_relative "../types/order_enum" +require_relative "../types/data_export_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/all_document_export_response_schema" +require_relative "../types/export_format" +require_relative "../types/export_object_schema" +require_relative "../types/create_export_task_response_schema" +require_relative "../types/supported_format_schema" +require "json" +require_relative "../types/document_export_response_schema" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class DataExportsClient + # @return [Monite::RequestClient] + attr_reader :request_client + # @return [Monite::DataExports::ExtraDataClient] + attr_reader :extra_data + + + # @param request_client [Monite::RequestClient] + # @return [Monite::DataExportsClient] + def initialize(request_client:) + @request_client = request_client + @extra_data = Monite::DataExports::ExtraDataClient.new(request_client: request_client) + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::DATA_EXPORT_CURSOR_FIELDS] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param created_by_entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AllDocumentExportResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, created_by_entity_user_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "created_by_entity_user_id": created_by_entity_user_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)}/data_exports" +end + Monite::AllDocumentExportResponseSchema.from_json(json_object: response.body) + end +# Request the export of payable and receivable documents with the specified +# statuses. + # + # @param date_from [String] + # @param date_to [String] + # @param format [Monite::ExportFormat] + # @param objects [Array] Request of type Array, as a Hash + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreateExportTaskResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.create( +# date_from: "date_from", +# date_to: "date_to", +# format: CSV, +# objects: +# ) + def create(date_from:, date_to:, format:, objects:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), date_from: date_from, date_to: date_to, format: format, objects: objects }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/data_exports" +end + Monite::CreateExportTaskResponseSchema.from_json(json_object: response.body) + end + # @param request_options [Monite::RequestOptions] + # @return [Array] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.get_supported_formats + def get_supported_formats(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/supported_formats" +end + parsed_json = JSON.parse(response.body) + parsed_json&.map do | item | + item = item.to_json + Monite::SupportedFormatSchema.from_json(json_object: item) + end + end + # @param document_export_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::DocumentExportResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.get_by_id(document_export_id: "document_export_id") + def get_by_id(document_export_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/#{document_export_id}" +end + Monite::DocumentExportResponseSchema.from_json(json_object: response.body) + end + end + class AsyncDataExportsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + # @return [Monite::DataExports::ExtraDataClient] + attr_reader :extra_data + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncDataExportsClient] + def initialize(request_client:) + @request_client = request_client + @extra_data = Monite::DataExports::AsyncExtraDataClient.new(request_client: request_client) + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::DATA_EXPORT_CURSOR_FIELDS] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param created_by_entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::AllDocumentExportResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, created_by_entity_user_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "created_by_entity_user_id": created_by_entity_user_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)}/data_exports" +end + Monite::AllDocumentExportResponseSchema.from_json(json_object: response.body) + end + end +# Request the export of payable and receivable documents with the specified +# statuses. + # + # @param date_from [String] + # @param date_to [String] + # @param format [Monite::ExportFormat] + # @param objects [Array] Request of type Array, as a Hash + # @param request_options [Monite::RequestOptions] + # @return [Monite::CreateExportTaskResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.create( +# date_from: "date_from", +# date_to: "date_to", +# format: CSV, +# objects: +# ) + def create(date_from:, date_to:, format:, objects:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), date_from: date_from, date_to: date_to, format: format, objects: objects }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/data_exports" +end + Monite::CreateExportTaskResponseSchema.from_json(json_object: response.body) + end + end + # @param request_options [Monite::RequestOptions] + # @return [Array] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.get_supported_formats + def get_supported_formats(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/supported_formats" +end + parsed_json = JSON.parse(response.body) + parsed_json&.map do | item | + item = item.to_json + Monite::SupportedFormatSchema.from_json(json_object: item) + end + end + end + # @param document_export_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::DocumentExportResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.get_by_id(document_export_id: "document_export_id") + def get_by_id(document_export_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/#{document_export_id}" +end + Monite::DocumentExportResponseSchema.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/data_exports/extra_data/client.rb b/lib/monite/data_exports/extra_data/client.rb new file mode 100644 index 0000000..9b7c69a --- /dev/null +++ b/lib/monite/data_exports/extra_data/client.rb @@ -0,0 +1,452 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/order_enum" +require_relative "../../types/export_setting_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../../types/extra_data_resource_list" +require_relative "../../types/supported_field_names" +require_relative "../../types/extra_data_resource" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module DataExports + class ExtraDataClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::DataExports::ExtraDataClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ExportSettingCursorFields] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param object_id [String] + # @param field_name [String] + # @param field_value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, object_id: nil, field_name: nil, field_value: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte, "object_id": object_id, "field_name": field_name, "field_value": field_value }.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)}/data_exports/extra_data" +end + Monite::ExtraDataResourceList.from_json(json_object: response.body) + end + # @param field_name [Monite::SupportedFieldNames] + # @param field_value [String] + # @param object_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.create( +# field_name: DEFAULT_ACCOUNT_CODE, +# field_value: "field_value", +# object_id: "object_id" +# ) + def create(field_name:, field_value:, object_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), "object_type": "counterpart", field_name: field_name, field_value: field_value, object_id: object_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/data_exports/extra_data" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + # @param extra_data_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.get_by_id(extra_data_id: "extra_data_id") + def get_by_id(extra_data_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/extra_data/#{extra_data_id}" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + # @param extra_data_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.delete_by_id(extra_data_id: "extra_data_id") + def delete_by_id(extra_data_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/extra_data/#{extra_data_id}" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + # @param extra_data_id [String] + # @param field_name [Monite::SupportedFieldNames] + # @param field_value [String] + # @param object_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.update_by_id(extra_data_id: "extra_data_id") + def update_by_id(extra_data_id:, field_name: nil, field_value: nil, object_id: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), "object_type": "counterpart", field_name: field_name, field_value: field_value, object_id: object_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/data_exports/extra_data/#{extra_data_id}" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + end + class AsyncExtraDataClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::DataExports::AsyncExtraDataClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ExportSettingCursorFields] Allowed sort fields + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param object_id [String] + # @param field_name [String] + # @param field_value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, object_id: nil, field_name: nil, field_value: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte, "object_id": object_id, "field_name": field_name, "field_value": field_value }.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)}/data_exports/extra_data" +end + Monite::ExtraDataResourceList.from_json(json_object: response.body) + end + end + # @param field_name [Monite::SupportedFieldNames] + # @param field_value [String] + # @param object_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.create( +# field_name: DEFAULT_ACCOUNT_CODE, +# field_value: "field_value", +# object_id: "object_id" +# ) + def create(field_name:, field_value:, object_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), "object_type": "counterpart", field_name: field_name, field_value: field_value, object_id: object_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/data_exports/extra_data" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + end + # @param extra_data_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.get_by_id(extra_data_id: "extra_data_id") + def get_by_id(extra_data_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/extra_data/#{extra_data_id}" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + end + # @param extra_data_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.delete_by_id(extra_data_id: "extra_data_id") + def delete_by_id(extra_data_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/data_exports/extra_data/#{extra_data_id}" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + end + # @param extra_data_id [String] + # @param field_name [Monite::SupportedFieldNames] + # @param field_value [String] + # @param object_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ExtraDataResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.data_exports.extra_data.update_by_id(extra_data_id: "extra_data_id") + def update_by_id(extra_data_id:, field_name: nil, field_value: nil, object_id: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), "object_type": "counterpart", field_name: field_name, field_value: field_value, object_id: object_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/data_exports/extra_data/#{extra_data_id}" +end + Monite::ExtraDataResource.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/e_invoicing_connections/client.rb b/lib/monite/e_invoicing_connections/client.rb new file mode 100644 index 0000000..eddf516 --- /dev/null +++ b/lib/monite/e_invoicing_connections/client.rb @@ -0,0 +1,422 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/e_invoicing_retrieve_list_data" +require_relative "../types/einvoicing_address" +require_relative "../types/einvoicing_connection_response" +require_relative "../types/einvoice_schema_type_enum" +require_relative "../types/einvoicing_network_credentials_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class EInvoicingConnectionsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::EInvoicingConnectionsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::EInvoicingRetrieveListData] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.get_einvoicing_connections + def get_einvoicing_connections(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/einvoicing_connections" +end + Monite::EInvoicingRetrieveListData.from_json(json_object: response.body) + end + # @param address [Hash] Integration AddressRequest of type Monite::EinvoicingAddress, as a Hash + # * :address_line_1 (String) + # * :address_line_2 (String) + # * :city (String) + # * :country (Monite::AllowedEinvoicingCountryCodes) + # * :postal_code (String) + # * :state (String) + # @param entity_vat_id_id [String] Entity VAT ID identifier for the integration + # @param request_options [Monite::RequestOptions] + # @return [Monite::EinvoicingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.post_einvoicing_connections(address: { address_line_1: "address_line1", city: "city", country: DE, postal_code: "postal_code" }) + def post_einvoicing_connections(address:, entity_vat_id_id: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, entity_vat_id_id: entity_vat_id_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/einvoicing_connections" +end + Monite::EinvoicingConnectionResponse.from_json(json_object: response.body) + end + # @param einvoicing_connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EinvoicingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.get_einvoicing_connections_id(einvoicing_connection_id: "einvoicing_connection_id") + def get_einvoicing_connections_id(einvoicing_connection_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/einvoicing_connections/#{einvoicing_connection_id}" +end + Monite::EinvoicingConnectionResponse.from_json(json_object: response.body) + end + # @param einvoicing_connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.delete_einvoicing_connections_id(einvoicing_connection_id: "einvoicing_connection_id") + def delete_einvoicing_connections_id(einvoicing_connection_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/einvoicing_connections/#{einvoicing_connection_id}" +end + end + # @param einvoicing_connection_id [String] + # @param network_credentials_identifier [String] Network participant identifier + # @param network_credentials_schema [Monite::EinvoiceSchemaTypeEnum] Network scheme identifier + # @param request_options [Monite::RequestOptions] + # @return [Monite::EinvoicingNetworkCredentialsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.post_einvoicing_connections_id_network_credentials( +# einvoicing_connection_id: "einvoicing_connection_id", +# network_credentials_identifier: "12345678", +# network_credentials_schema: DE_VAT +# ) + def post_einvoicing_connections_id_network_credentials(einvoicing_connection_id:, network_credentials_identifier:, network_credentials_schema:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), network_credentials_identifier: network_credentials_identifier, network_credentials_schema: network_credentials_schema }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/einvoicing_connections/#{einvoicing_connection_id}/network_credentials" +end + Monite::EinvoicingNetworkCredentialsResponse.from_json(json_object: response.body) + end + end + class AsyncEInvoicingConnectionsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncEInvoicingConnectionsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::EInvoicingRetrieveListData] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.get_einvoicing_connections + def get_einvoicing_connections(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/einvoicing_connections" +end + Monite::EInvoicingRetrieveListData.from_json(json_object: response.body) + end + end + # @param address [Hash] Integration AddressRequest of type Monite::EinvoicingAddress, as a Hash + # * :address_line_1 (String) + # * :address_line_2 (String) + # * :city (String) + # * :country (Monite::AllowedEinvoicingCountryCodes) + # * :postal_code (String) + # * :state (String) + # @param entity_vat_id_id [String] Entity VAT ID identifier for the integration + # @param request_options [Monite::RequestOptions] + # @return [Monite::EinvoicingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.post_einvoicing_connections(address: { address_line_1: "address_line1", city: "city", country: DE, postal_code: "postal_code" }) + def post_einvoicing_connections(address:, entity_vat_id_id: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, entity_vat_id_id: entity_vat_id_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/einvoicing_connections" +end + Monite::EinvoicingConnectionResponse.from_json(json_object: response.body) + end + end + # @param einvoicing_connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EinvoicingConnectionResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.get_einvoicing_connections_id(einvoicing_connection_id: "einvoicing_connection_id") + def get_einvoicing_connections_id(einvoicing_connection_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/einvoicing_connections/#{einvoicing_connection_id}" +end + Monite::EinvoicingConnectionResponse.from_json(json_object: response.body) + end + end + # @param einvoicing_connection_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.delete_einvoicing_connections_id(einvoicing_connection_id: "einvoicing_connection_id") + def delete_einvoicing_connections_id(einvoicing_connection_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/einvoicing_connections/#{einvoicing_connection_id}" +end + end + end + # @param einvoicing_connection_id [String] + # @param network_credentials_identifier [String] Network participant identifier + # @param network_credentials_schema [Monite::EinvoiceSchemaTypeEnum] Network scheme identifier + # @param request_options [Monite::RequestOptions] + # @return [Monite::EinvoicingNetworkCredentialsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.e_invoicing_connections.post_einvoicing_connections_id_network_credentials( +# einvoicing_connection_id: "einvoicing_connection_id", +# network_credentials_identifier: "12345678", +# network_credentials_schema: DE_VAT +# ) + def post_einvoicing_connections_id_network_credentials(einvoicing_connection_id:, network_credentials_identifier:, network_credentials_schema:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), network_credentials_identifier: network_credentials_identifier, network_credentials_schema: network_credentials_schema }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/einvoicing_connections/#{einvoicing_connection_id}/network_credentials" +end + Monite::EinvoicingNetworkCredentialsResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entities/bank_accounts/client.rb b/lib/monite/entities/bank_accounts/client.rb new file mode 100644 index 0000000..6157ef7 --- /dev/null +++ b/lib/monite/entities/bank_accounts/client.rb @@ -0,0 +1,562 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/entity_bank_account_pagination_response" +require_relative "../../types/allowed_countries" +require_relative "../../types/currency_enum" +require_relative "../../types/entity_bank_account_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Entities + class BankAccountsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::BankAccountsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all bank accounts of this entity. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts" +end + Monite::EntityBankAccountPaginationResponse.from_json(json_object: response.body) + end +# Add a new bank account for the specified entity. +# The minimum required fields are `currency` and `country`. Other required fields +# depend on the currency: +# * EUR accounts require `iban`. +# * GBP accounts require `account_holder_name`, `account_number`, and `sort_code`. +# * USD accounts require `account_holder_name`, `account_number`, and +# `routing_number`. +# * Accounts in other currencies require one of: +# * `iban` +# * `account_number` and `sort_code` +# * `account_number` and `routing_number` + # + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required if the +# account currency is GBP or USD. + # @param account_number [String] The bank account number. Required if the account currency is GBP or USD. UK +# account numbers typically contain 8 digits. US bank account numbers contain 9 to +# 12 digits. + # @param bank_name [String] The bank name. + # @param bic [String] The SWIFT/BIC code of the bank. + # @param country [Monite::AllowedCountries] The country in which the bank account is registered, repsesented as a two-letter +# country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param currency [Monite::CurrencyEnum] The currency of the bank account, represented as a three-letter ISO [currency +# code](https://docs.monite.com/references/currencies). + # @param display_name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. + # @param iban [String] The IBAN of the bank account. Required if the account currency is EUR. + # @param is_default_for_currency [Boolean] If set to `true` or if this is the first bank account added for the given +# currency, this account becomes the default one for its currency. + # @param routing_number [String] The bank's routing transit number (RTN) or branch code. Required if the account +# currency is USD. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. Required if the account currency is GBP. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.create(country: AF, currency: AED) + def create(account_holder_name: nil, account_number: nil, bank_name: nil, bic: nil, country:, currency:, display_name: nil, iban: nil, is_default_for_currency: nil, routing_number: nil, sort_code: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, account_number: account_number, bank_name: bank_name, bic: bic, country: country, currency: currency, display_name: display_name, iban: iban, is_default_for_currency: is_default_for_currency, routing_number: routing_number, sort_code: sort_code }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/bank_accounts" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end +# Retrieve a bank account by its ID. + # + # @param bank_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.get_by_id(bank_account_id: "bank_account_id") + def get_by_id(bank_account_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts/#{bank_account_id}" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end +# Delete the bank account specified by its ID. + # + # @param bank_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.delete_by_id(bank_account_id: "bank_account_id") + def delete_by_id(bank_account_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts/#{bank_account_id}" +end + end +# Change the specified fields with the provided values. + # + # @param bank_account_id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. If the account +# currency is GBP or USD, the holder name cannot be changed to an empty string. + # @param display_name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.update_by_id(bank_account_id: "bank_account_id") + def update_by_id(bank_account_id:, account_holder_name: nil, display_name: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, display_name: display_name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/bank_accounts/#{bank_account_id}" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end +# Set a bank account as the default for this entity per currency. + # + # @param bank_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.make_default_by_id(bank_account_id: "bank_account_id") + def make_default_by_id(bank_account_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts/#{bank_account_id}/make_default" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end + end + class AsyncBankAccountsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::AsyncBankAccountsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all bank accounts of this entity. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts" +end + Monite::EntityBankAccountPaginationResponse.from_json(json_object: response.body) + end + end +# Add a new bank account for the specified entity. +# The minimum required fields are `currency` and `country`. Other required fields +# depend on the currency: +# * EUR accounts require `iban`. +# * GBP accounts require `account_holder_name`, `account_number`, and `sort_code`. +# * USD accounts require `account_holder_name`, `account_number`, and +# `routing_number`. +# * Accounts in other currencies require one of: +# * `iban` +# * `account_number` and `sort_code` +# * `account_number` and `routing_number` + # + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required if the +# account currency is GBP or USD. + # @param account_number [String] The bank account number. Required if the account currency is GBP or USD. UK +# account numbers typically contain 8 digits. US bank account numbers contain 9 to +# 12 digits. + # @param bank_name [String] The bank name. + # @param bic [String] The SWIFT/BIC code of the bank. + # @param country [Monite::AllowedCountries] The country in which the bank account is registered, repsesented as a two-letter +# country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param currency [Monite::CurrencyEnum] The currency of the bank account, represented as a three-letter ISO [currency +# code](https://docs.monite.com/references/currencies). + # @param display_name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. + # @param iban [String] The IBAN of the bank account. Required if the account currency is EUR. + # @param is_default_for_currency [Boolean] If set to `true` or if this is the first bank account added for the given +# currency, this account becomes the default one for its currency. + # @param routing_number [String] The bank's routing transit number (RTN) or branch code. Required if the account +# currency is USD. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. Required if the account currency is GBP. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.create(country: AF, currency: AED) + def create(account_holder_name: nil, account_number: nil, bank_name: nil, bic: nil, country:, currency:, display_name: nil, iban: nil, is_default_for_currency: nil, routing_number: nil, sort_code: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, account_number: account_number, bank_name: bank_name, bic: bic, country: country, currency: currency, display_name: display_name, iban: iban, is_default_for_currency: is_default_for_currency, routing_number: routing_number, sort_code: sort_code }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/bank_accounts" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end + end +# Retrieve a bank account by its ID. + # + # @param bank_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.get_by_id(bank_account_id: "bank_account_id") + def get_by_id(bank_account_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts/#{bank_account_id}" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end + end +# Delete the bank account specified by its ID. + # + # @param bank_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.delete_by_id(bank_account_id: "bank_account_id") + def delete_by_id(bank_account_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts/#{bank_account_id}" +end + end + end +# Change the specified fields with the provided values. + # + # @param bank_account_id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. If the account +# currency is GBP or USD, the holder name cannot be changed to an empty string. + # @param display_name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.update_by_id(bank_account_id: "bank_account_id") + def update_by_id(bank_account_id:, account_holder_name: nil, display_name: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), account_holder_name: account_holder_name, display_name: display_name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/bank_accounts/#{bank_account_id}" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end + end +# Set a bank account as the default for this entity per currency. + # + # @param bank_account_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityBankAccountResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.bank_accounts.make_default_by_id(bank_account_id: "bank_account_id") + def make_default_by_id(bank_account_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/bank_accounts/#{bank_account_id}/make_default" +end + Monite::EntityBankAccountResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entities/client.rb b/lib/monite/entities/client.rb new file mode 100644 index 0000000..cc096f8 --- /dev/null +++ b/lib/monite/entities/client.rb @@ -0,0 +1,1623 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "bank_accounts/client" +require_relative "onboarding_data/client" +require_relative "payment_methods/client" +require_relative "vat_ids/client" +require_relative "persons/client" +require_relative "../types/order_enum" +require_relative "../types/entity_cursor_fields" +require_relative "../types/entity_type_enum" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/entity_pagination_response" +require_relative "../types/entity_address_schema" +require_relative "../types/organization_schema" +require_relative "../types/individual_schema" +require_relative "../types/entity_response" +require_relative "../types/update_entity_request" +require_relative "../types/file_schema_3" +require_relative "../../core/file_utilities" +require_relative "../types/partner_metadata_response" +require_relative "../types/partner_metadata" +require_relative "../types/settings_response" +require_relative "../types/language_code_enum" +require_relative "../types/currency_settings_input" +require_relative "../types/reminders_settings" +require_relative "../types/vat_mode_enum" +require_relative "../types/payment_priority_enum" +require_relative "../types/receivable_edit_flow" +require_relative "../types/document_i_ds_settings_request" +require_relative "../types/ocr_auto_tagging_settings_request" +require_relative "../types/accounting_settings" +require_relative "../types/get_onboarding_requirements_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class EntitiesClient + # @return [Monite::RequestClient] + attr_reader :request_client + # @return [Monite::Entities::BankAccountsClient] + attr_reader :bank_accounts + # @return [Monite::Entities::OnboardingDataClient] + attr_reader :onboarding_data + # @return [Monite::Entities::PaymentMethodsClient] + attr_reader :payment_methods + # @return [Monite::Entities::VatIdsClient] + attr_reader :vat_ids + # @return [Monite::Entities::PersonsClient] + attr_reader :persons + + + # @param request_client [Monite::RequestClient] + # @return [Monite::EntitiesClient] + def initialize(request_client:) + @request_client = request_client + @bank_accounts = Monite::Entities::BankAccountsClient.new(request_client: request_client) + @onboarding_data = Monite::Entities::OnboardingDataClient.new(request_client: request_client) + @payment_methods = Monite::Entities::PaymentMethodsClient.new(request_client: request_client) + @vat_ids = Monite::Entities::VatIdsClient.new(request_client: request_client) + @persons = Monite::Entities::PersonsClient.new(request_client: request_client) + end +# Retrieve a list of all entities. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::EntityCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param type [Monite::EntityTypeEnum] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param id_in [String] + # @param id_not_in [String] + # @param email [String] + # @param email_in [String] + # @param email_not_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, type: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, id_in: nil, id_not_in: nil, email: nil, email_in: nil, email_not_in: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "type": type, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "id__in": id_in, "id__not_in": id_not_in, "email": email, "email__in": email_in, "email__not_in": email_not_in }.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)}/entities" +end + Monite::EntityPaginationResponse.from_json(json_object: response.body) + end +# Create a new entity from the specified values. + # + # @param address [Hash] An address description of the entityRequest of type Monite::EntityAddressSchema, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param email [String] An official email address of the entity + # @param phone [String] The contact phone number of the entity. Required for US organizations to use +# payments. + # @param website [String] A website of the entity + # @param organization [Hash] A set of meta data describing the organizationRequest of type Monite::OrganizationSchema, as a Hash + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # @param individual [Hash] A set of meta data describing the individualRequest of type Monite::IndividualSchema, as a Hash + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param type [Monite::EntityTypeEnum] A type for an entity + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.create( +# address: { city: "city", country: AF, line_1: "line1", postal_code: "postal_code" }, +# email: "email", +# type: INDIVIDUAL +# ) + def create(address:, email:, phone: nil, website: nil, organization: nil, individual: nil, tax_id: nil, type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, email: email, phone: phone, website: website, organization: organization, individual: individual, tax_id: tax_id, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Deprecated. Use `GET /entity_users/my_entity` instead. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_entities_me + def get_entities_me(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/me" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Deprecated. Use `PATCH /entity_users/my_entity` instead. + # + # @param request [Hash] Request of type Monite::UpdateEntityRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :email (String) + # * :phone (String) + # * :website (String) + # * :tax_id (String) + # * :organization (Hash) + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # * :individual (Hash) + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.patch_entities_me(request: { }) + def patch_entities_me(request:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/me" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Retrieve an entity by its ID. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def get_by_id(entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Change the specified fields with the provided values. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request [Hash] Request of type Monite::UpdateEntityRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :email (String) + # * :phone (String) + # * :website (String) + # * :tax_id (String) + # * :organization (Hash) + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # * :individual (Hash) + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.update_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", request: { }) + def update_by_id(entity_id:, request:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Activate an entity to allow it to perform any operations. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.post_entities_id_activate(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def post_entities_id_activate(entity_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/activate" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Deactivate an entity to stop it from performing any operations. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.post_entities_id_deactivate(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def post_entities_id_deactivate(entity_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/deactivate" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for +# example, in PDF documents created by this entity. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FileSchema3] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.upload_logo_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", file: my_file.txt) + def upload_logo_by_id(entity_id:, file:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/logo" +end + Monite::FileSchema3.from_json(json_object: response.body) + end + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.delete_logo_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def delete_logo_by_id(entity_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/logo" +end + end +# Retrieve a metadata object associated with this entity, usually in a JSON +# format. + # + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_partner_metadata_by_id(entity_id: "entity_id") + def get_partner_metadata_by_id(entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end +# Fully replace the current metadata object with the specified instance. + # + # @param entity_id [String] + # @param request [Hash] Request of type Monite::PartnerMetadata, as a Hash + # * :metadata (Hash{String => Object}) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.update_partner_metadata_by_id(entity_id: "entity_id", request: { metadata: { "key": "value" } }) + def update_partner_metadata_by_id(entity_id:, request:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end +# Retrieve all settings for this entity. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::SettingsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_settings_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def get_settings_by_id(entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/settings" +end + Monite::SettingsResponse.from_json(json_object: response.body) + end +# Change the specified fields with the provided values. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param language [Monite::LanguageCodeEnum] + # @param currency [Hash] Request of type Monite::CurrencySettingsInput, as a Hash + # * :default (Monite::CurrencyEnum) + # * :exchange_rates (Array) + # @param reminder [Hash] Request of type Monite::RemindersSettings, as a Hash + # * :enabled (Boolean) + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivables will already include VAT +# or not. + # @param payment_priority [Monite::PaymentPriorityEnum] Payment preferences for entity to automate calculating suggested payment date +# based on payment terms and entity preferences. + # @param allow_purchase_order_autolinking [Boolean] Automatically attempt to find a corresponding purchase order for all incoming +# payables. + # @param receivable_edit_flow [Monite::ReceivableEditFlow] + # @param document_ids [Hash] Request of type Monite::DocumentIDsSettingsRequest, as a Hash + # * :document_type_prefix (Hash) + # * :credit_note (String) + # * :invoice (String) + # * :purchase_order (String) + # * :quote (String) + # * :include_date (Boolean) + # * :min_digits (Integer) + # * :next_number (Hash) + # * :credit_note (Integer) + # * :invoice (Integer) + # * :purchase_order (Integer) + # * :quote (Integer) + # * :prefix (String) + # * :separator (Monite::DocumentIdSeparators) + # @param payables_ocr_auto_tagging [Array] Auto tagging settings for all incoming OCR payable documents.Request of type Array, as a Hash + # * :enabled (Boolean) + # * :keywords (Array) + # * :tag_id (String) + # @param quote_signature_required [Boolean] Sets the default behavior of whether a signature is required to accept quotes. + # @param generate_paid_invoice_pdf [Boolean] If enabled, the paid invoice's PDF will be in a new layout set by the user. + # @param accounting [Hash] Request of type Monite::AccountingSettings, as a Hash + # * :ledger_account_ids (Hash) + # * :payments (String) + # * :products (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::SettingsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.update_settings_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def update_settings_by_id(entity_id:, language: nil, currency: nil, reminder: nil, vat_mode: nil, payment_priority: nil, allow_purchase_order_autolinking: nil, receivable_edit_flow: nil, document_ids: nil, payables_ocr_auto_tagging: nil, quote_signature_required: nil, generate_paid_invoice_pdf: nil, accounting: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), language: language, currency: currency, reminder: reminder, vat_mode: vat_mode, payment_priority: payment_priority, allow_purchase_order_autolinking: allow_purchase_order_autolinking, receivable_edit_flow: receivable_edit_flow, document_ids: document_ids, payables_ocr_auto_tagging: payables_ocr_auto_tagging, quote_signature_required: quote_signature_required, generate_paid_invoice_pdf: generate_paid_invoice_pdf, accounting: accounting }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/settings" +end + Monite::SettingsResponse.from_json(json_object: response.body) + end +# Provide files for entity onboarding verification + # + # @param additional_verification_document_back [String] + # @param additional_verification_document_front [String] + # @param bank_account_ownership_verification [Array] + # @param company_license [Array] + # @param company_memorandum_of_association [Array] + # @param company_ministerial_decree [Array] + # @param company_registration_verification [Array] + # @param company_tax_id_verification [Array] + # @param proof_of_registration [Array] + # @param verification_document_back [String] + # @param verification_document_front [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.upload_onboarding_documents + def upload_onboarding_documents(additional_verification_document_back: nil, additional_verification_document_front: nil, bank_account_ownership_verification: nil, company_license: nil, company_memorandum_of_association: nil, company_ministerial_decree: nil, company_registration_verification: nil, company_tax_id_verification: nil, proof_of_registration: nil, verification_document_back: nil, verification_document_front: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), additional_verification_document_back: additional_verification_document_back, additional_verification_document_front: additional_verification_document_front, bank_account_ownership_verification: bank_account_ownership_verification, company_license: company_license, company_memorandum_of_association: company_memorandum_of_association, company_ministerial_decree: company_ministerial_decree, company_registration_verification: company_registration_verification, company_tax_id_verification: company_tax_id_verification, proof_of_registration: proof_of_registration, verification_document_back: verification_document_back, verification_document_front: verification_document_front }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/onboarding_documents" +end + end +# Get onboarding requirements for the entity + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::GetOnboardingRequirementsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_onboarding_requirements + def get_onboarding_requirements(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/onboarding_requirements" +end + Monite::GetOnboardingRequirementsResponse.from_json(json_object: response.body) + end + end + class AsyncEntitiesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + # @return [Monite::Entities::BankAccountsClient] + attr_reader :bank_accounts + # @return [Monite::Entities::OnboardingDataClient] + attr_reader :onboarding_data + # @return [Monite::Entities::PaymentMethodsClient] + attr_reader :payment_methods + # @return [Monite::Entities::VatIdsClient] + attr_reader :vat_ids + # @return [Monite::Entities::PersonsClient] + attr_reader :persons + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncEntitiesClient] + def initialize(request_client:) + @request_client = request_client + @bank_accounts = Monite::Entities::AsyncBankAccountsClient.new(request_client: request_client) + @onboarding_data = Monite::Entities::AsyncOnboardingDataClient.new(request_client: request_client) + @payment_methods = Monite::Entities::AsyncPaymentMethodsClient.new(request_client: request_client) + @vat_ids = Monite::Entities::AsyncVatIdsClient.new(request_client: request_client) + @persons = Monite::Entities::AsyncPersonsClient.new(request_client: request_client) + end +# Retrieve a list of all entities. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::EntityCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param type [Monite::EntityTypeEnum] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param id_in [String] + # @param id_not_in [String] + # @param email [String] + # @param email_in [String] + # @param email_not_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, type: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, id_in: nil, id_not_in: nil, email: nil, email_in: nil, email_not_in: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "type": type, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "id__in": id_in, "id__not_in": id_not_in, "email": email, "email__in": email_in, "email__not_in": email_not_in }.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)}/entities" +end + Monite::EntityPaginationResponse.from_json(json_object: response.body) + end + end +# Create a new entity from the specified values. + # + # @param address [Hash] An address description of the entityRequest of type Monite::EntityAddressSchema, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param email [String] An official email address of the entity + # @param phone [String] The contact phone number of the entity. Required for US organizations to use +# payments. + # @param website [String] A website of the entity + # @param organization [Hash] A set of meta data describing the organizationRequest of type Monite::OrganizationSchema, as a Hash + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # @param individual [Hash] A set of meta data describing the individualRequest of type Monite::IndividualSchema, as a Hash + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param type [Monite::EntityTypeEnum] A type for an entity + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.create( +# address: { city: "city", country: AF, line_1: "line1", postal_code: "postal_code" }, +# email: "email", +# type: INDIVIDUAL +# ) + def create(address:, email:, phone: nil, website: nil, organization: nil, individual: nil, tax_id: nil, type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, email: email, phone: phone, website: website, organization: organization, individual: individual, tax_id: tax_id, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Deprecated. Use `GET /entity_users/my_entity` instead. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_entities_me + def get_entities_me(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/me" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Deprecated. Use `PATCH /entity_users/my_entity` instead. + # + # @param request [Hash] Request of type Monite::UpdateEntityRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :email (String) + # * :phone (String) + # * :website (String) + # * :tax_id (String) + # * :organization (Hash) + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # * :individual (Hash) + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.patch_entities_me(request: { }) + def patch_entities_me(request:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/me" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Retrieve an entity by its ID. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def get_by_id(entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Change the specified fields with the provided values. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request [Hash] Request of type Monite::UpdateEntityRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :email (String) + # * :phone (String) + # * :website (String) + # * :tax_id (String) + # * :organization (Hash) + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # * :individual (Hash) + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.update_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", request: { }) + def update_by_id(entity_id:, request:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Activate an entity to allow it to perform any operations. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.post_entities_id_activate(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def post_entities_id_activate(entity_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/activate" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Deactivate an entity to stop it from performing any operations. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.post_entities_id_deactivate(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def post_entities_id_deactivate(entity_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/deactivate" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Entity logo can be PNG, JPG, or GIF, up to 10 MB in size. The logo is used, for +# example, in PDF documents created by this entity. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FileSchema3] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.upload_logo_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5", file: my_file.txt) + def upload_logo_by_id(entity_id:, file:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/logo" +end + Monite::FileSchema3.from_json(json_object: response.body) + end + end + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.delete_logo_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def delete_logo_by_id(entity_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/logo" +end + end + end +# Retrieve a metadata object associated with this entity, usually in a JSON +# format. + # + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_partner_metadata_by_id(entity_id: "entity_id") + def get_partner_metadata_by_id(entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end + end +# Fully replace the current metadata object with the specified instance. + # + # @param entity_id [String] + # @param request [Hash] Request of type Monite::PartnerMetadata, as a Hash + # * :metadata (Hash{String => Object}) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerMetadataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.update_partner_metadata_by_id(entity_id: "entity_id", request: { metadata: { "key": "value" } }) + def update_partner_metadata_by_id(entity_id:, request:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/partner_metadata" +end + Monite::PartnerMetadataResponse.from_json(json_object: response.body) + end + end +# Retrieve all settings for this entity. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param request_options [Monite::RequestOptions] + # @return [Monite::SettingsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_settings_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def get_settings_by_id(entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/settings" +end + Monite::SettingsResponse.from_json(json_object: response.body) + end + end +# Change the specified fields with the provided values. + # + # @param entity_id [String] A unique ID to specify the entity. + # @param language [Monite::LanguageCodeEnum] + # @param currency [Hash] Request of type Monite::CurrencySettingsInput, as a Hash + # * :default (Monite::CurrencyEnum) + # * :exchange_rates (Array) + # @param reminder [Hash] Request of type Monite::RemindersSettings, as a Hash + # * :enabled (Boolean) + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivables will already include VAT +# or not. + # @param payment_priority [Monite::PaymentPriorityEnum] Payment preferences for entity to automate calculating suggested payment date +# based on payment terms and entity preferences. + # @param allow_purchase_order_autolinking [Boolean] Automatically attempt to find a corresponding purchase order for all incoming +# payables. + # @param receivable_edit_flow [Monite::ReceivableEditFlow] + # @param document_ids [Hash] Request of type Monite::DocumentIDsSettingsRequest, as a Hash + # * :document_type_prefix (Hash) + # * :credit_note (String) + # * :invoice (String) + # * :purchase_order (String) + # * :quote (String) + # * :include_date (Boolean) + # * :min_digits (Integer) + # * :next_number (Hash) + # * :credit_note (Integer) + # * :invoice (Integer) + # * :purchase_order (Integer) + # * :quote (Integer) + # * :prefix (String) + # * :separator (Monite::DocumentIdSeparators) + # @param payables_ocr_auto_tagging [Array] Auto tagging settings for all incoming OCR payable documents.Request of type Array, as a Hash + # * :enabled (Boolean) + # * :keywords (Array) + # * :tag_id (String) + # @param quote_signature_required [Boolean] Sets the default behavior of whether a signature is required to accept quotes. + # @param generate_paid_invoice_pdf [Boolean] If enabled, the paid invoice's PDF will be in a new layout set by the user. + # @param accounting [Hash] Request of type Monite::AccountingSettings, as a Hash + # * :ledger_account_ids (Hash) + # * :payments (String) + # * :products (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::SettingsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.update_settings_by_id(entity_id: "ea837e28-509b-4b6a-a600-d54b6aa0b1f5") + def update_settings_by_id(entity_id:, language: nil, currency: nil, reminder: nil, vat_mode: nil, payment_priority: nil, allow_purchase_order_autolinking: nil, receivable_edit_flow: nil, document_ids: nil, payables_ocr_auto_tagging: nil, quote_signature_required: nil, generate_paid_invoice_pdf: nil, accounting: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), language: language, currency: currency, reminder: reminder, vat_mode: vat_mode, payment_priority: payment_priority, allow_purchase_order_autolinking: allow_purchase_order_autolinking, receivable_edit_flow: receivable_edit_flow, document_ids: document_ids, payables_ocr_auto_tagging: payables_ocr_auto_tagging, quote_signature_required: quote_signature_required, generate_paid_invoice_pdf: generate_paid_invoice_pdf, accounting: accounting }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/settings" +end + Monite::SettingsResponse.from_json(json_object: response.body) + end + end +# Provide files for entity onboarding verification + # + # @param additional_verification_document_back [String] + # @param additional_verification_document_front [String] + # @param bank_account_ownership_verification [Array] + # @param company_license [Array] + # @param company_memorandum_of_association [Array] + # @param company_ministerial_decree [Array] + # @param company_registration_verification [Array] + # @param company_tax_id_verification [Array] + # @param proof_of_registration [Array] + # @param verification_document_back [String] + # @param verification_document_front [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.upload_onboarding_documents + def upload_onboarding_documents(additional_verification_document_back: nil, additional_verification_document_front: nil, bank_account_ownership_verification: nil, company_license: nil, company_memorandum_of_association: nil, company_ministerial_decree: nil, company_registration_verification: nil, company_tax_id_verification: nil, proof_of_registration: nil, verification_document_back: nil, verification_document_front: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), additional_verification_document_back: additional_verification_document_back, additional_verification_document_front: additional_verification_document_front, bank_account_ownership_verification: bank_account_ownership_verification, company_license: company_license, company_memorandum_of_association: company_memorandum_of_association, company_ministerial_decree: company_ministerial_decree, company_registration_verification: company_registration_verification, company_tax_id_verification: company_tax_id_verification, proof_of_registration: proof_of_registration, verification_document_back: verification_document_back, verification_document_front: verification_document_front }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/onboarding_documents" +end + end + end +# Get onboarding requirements for the entity + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::GetOnboardingRequirementsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.get_onboarding_requirements + def get_onboarding_requirements(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/onboarding_requirements" +end + Monite::GetOnboardingRequirementsResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entities/onboarding_data/client.rb b/lib/monite/entities/onboarding_data/client.rb new file mode 100644 index 0000000..6b1ed05 --- /dev/null +++ b/lib/monite/entities/onboarding_data/client.rb @@ -0,0 +1,210 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/entity_onboarding_data_response" +require_relative "../../types/business_profile_input" +require_relative "../../types/ownership_declaration_input" +require_relative "../../types/terms_of_service_acceptance_input" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Entities + class OnboardingDataClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::OnboardingDataClient] + def initialize(request_client:) + @request_client = request_client + end + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityOnboardingDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.onboarding_data.get(entity_id: "entity_id") + def get(entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/onboarding_data" +end + Monite::EntityOnboardingDataResponse.from_json(json_object: response.body) + end + # @param entity_id [String] + # @param business_profile [Hash] Business information about the entity.Request of type Monite::BusinessProfileInput, as a Hash + # * :description_of_goods_or_services (String) + # * :estimated_monthly_revenue (Hash) + # * :amount (Integer) + # * :currency (Monite::CurrencyEnum) + # * :mcc (String) + # * :operating_countries (Array) + # * :url (String) + # @param ownership_declaration [Hash] Used to attest that the beneficial owner information provided is both current +# and correct.Request of type Monite::OwnershipDeclarationInput, as a Hash + # * :date (DateTime) + # * :ip (String) + # @param tos_acceptance [Hash] Details on the entity's acceptance of the service agreement.Request of type Monite::TermsOfServiceAcceptanceInput, as a Hash + # * :date (DateTime) + # * :ip (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityOnboardingDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.onboarding_data.update(entity_id: "entity_id") + def update(entity_id:, business_profile: nil, ownership_declaration: nil, tos_acceptance: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), business_profile: business_profile, ownership_declaration: ownership_declaration, tos_acceptance: tos_acceptance }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/onboarding_data" +end + Monite::EntityOnboardingDataResponse.from_json(json_object: response.body) + end + end + class AsyncOnboardingDataClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::AsyncOnboardingDataClient] + def initialize(request_client:) + @request_client = request_client + end + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityOnboardingDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.onboarding_data.get(entity_id: "entity_id") + def get(entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/onboarding_data" +end + Monite::EntityOnboardingDataResponse.from_json(json_object: response.body) + end + end + # @param entity_id [String] + # @param business_profile [Hash] Business information about the entity.Request of type Monite::BusinessProfileInput, as a Hash + # * :description_of_goods_or_services (String) + # * :estimated_monthly_revenue (Hash) + # * :amount (Integer) + # * :currency (Monite::CurrencyEnum) + # * :mcc (String) + # * :operating_countries (Array) + # * :url (String) + # @param ownership_declaration [Hash] Used to attest that the beneficial owner information provided is both current +# and correct.Request of type Monite::OwnershipDeclarationInput, as a Hash + # * :date (DateTime) + # * :ip (String) + # @param tos_acceptance [Hash] Details on the entity's acceptance of the service agreement.Request of type Monite::TermsOfServiceAcceptanceInput, as a Hash + # * :date (DateTime) + # * :ip (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityOnboardingDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.onboarding_data.update(entity_id: "entity_id") + def update(entity_id:, business_profile: nil, ownership_declaration: nil, tos_acceptance: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), business_profile: business_profile, ownership_declaration: ownership_declaration, tos_acceptance: tos_acceptance }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/onboarding_data" +end + Monite::EntityOnboardingDataResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entities/payment_methods/client.rb b/lib/monite/entities/payment_methods/client.rb new file mode 100644 index 0000000..763fbce --- /dev/null +++ b/lib/monite/entities/payment_methods/client.rb @@ -0,0 +1,192 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/onboarding_payment_methods_response" +require_relative "../../types/monite_all_payment_methods_types" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Entities + class PaymentMethodsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::PaymentMethodsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all enabled payment methods. + # + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::OnboardingPaymentMethodsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.payment_methods.get(entity_id: "entity_id") + def get(entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/payment_methods" +end + Monite::OnboardingPaymentMethodsResponse.from_json(json_object: response.body) + end +# Set which payment methods should be enabled. + # + # @param entity_id [String] + # @param payment_methods [Array] Deprecated. Use payment_methods_receive instead. + # @param payment_methods_receive [Array] Enable payment methods to receive money. + # @param payment_methods_send [Array] Enable payment methods to send money. + # @param request_options [Monite::RequestOptions] + # @return [Monite::OnboardingPaymentMethodsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.payment_methods.set(entity_id: "entity_id") + def set(entity_id:, payment_methods: nil, payment_methods_receive: nil, payment_methods_send: nil, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), payment_methods: payment_methods, payment_methods_receive: payment_methods_receive, payment_methods_send: payment_methods_send }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/payment_methods" +end + Monite::OnboardingPaymentMethodsResponse.from_json(json_object: response.body) + end + end + class AsyncPaymentMethodsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::AsyncPaymentMethodsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all enabled payment methods. + # + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::OnboardingPaymentMethodsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.payment_methods.get(entity_id: "entity_id") + def get(entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/payment_methods" +end + Monite::OnboardingPaymentMethodsResponse.from_json(json_object: response.body) + end + end +# Set which payment methods should be enabled. + # + # @param entity_id [String] + # @param payment_methods [Array] Deprecated. Use payment_methods_receive instead. + # @param payment_methods_receive [Array] Enable payment methods to receive money. + # @param payment_methods_send [Array] Enable payment methods to send money. + # @param request_options [Monite::RequestOptions] + # @return [Monite::OnboardingPaymentMethodsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.payment_methods.set(entity_id: "entity_id") + def set(entity_id:, payment_methods: nil, payment_methods_receive: nil, payment_methods_send: nil, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), payment_methods: payment_methods, payment_methods_receive: payment_methods_receive, payment_methods_send: payment_methods_send }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/payment_methods" +end + Monite::OnboardingPaymentMethodsResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entities/persons/client.rb b/lib/monite/entities/persons/client.rb new file mode 100644 index 0000000..30258c2 --- /dev/null +++ b/lib/monite/entities/persons/client.rb @@ -0,0 +1,585 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/persons_response" +require_relative "../../types/person_address_request" +require_relative "../../types/person_relationship_request" +require_relative "../../types/allowed_countries" +require_relative "../../types/person_response" +require_relative "../../types/optional_person_address_request" +require_relative "../../types/optional_person_relationship" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Entities + class PersonsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::PersonsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/persons" +end + Monite::PersonsResponse.from_json(json_object: response.body) + end + # @param address [Hash] The person's addressRequest of type Monite::PersonAddressRequest, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param date_of_birth [String] The person's date of birth + # @param first_name [String] The person's first name + # @param last_name [String] The person's last name + # @param email [String] The person's email address + # @param phone [String] The person's phone number + # @param relationship [Hash] Describes the person's relationship to the entityRequest of type Monite::PersonRelationshipRequest, as a Hash + # * :director (Boolean) + # * :executive (Boolean) + # * :owner (Boolean) + # * :percent_ownership (Float) + # * :representative (Boolean) + # * :title (String) + # @param id_number [String] The person's ID number, as appropriate for their country + # @param ssn_last_4 [String] The last four digits of the person's Social Security number + # @param citizenship [Monite::AllowedCountries] Required for persons of US entities. The country of the person's citizenship, as +# a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple +# citizenship, specify any. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.create( +# first_name: "first_name", +# last_name: "last_name", +# email: "email", +# relationship: { } +# ) + def create(address: nil, date_of_birth: nil, first_name:, last_name:, email:, phone: nil, relationship:, id_number: nil, ssn_last_4: nil, citizenship: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, date_of_birth: date_of_birth, first_name: first_name, last_name: last_name, email: email, phone: phone, relationship: relationship, id_number: id_number, ssn_last_4: ssn_last_4, citizenship: citizenship }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/persons" +end + Monite::PersonResponse.from_json(json_object: response.body) + end + # @param person_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.get_by_id(person_id: "person_id") + def get_by_id(person_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/persons/#{person_id}" +end + Monite::PersonResponse.from_json(json_object: response.body) + end + # @param person_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.delete_by_id(person_id: "person_id") + def delete_by_id(person_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/persons/#{person_id}" +end + end + # @param person_id [String] + # @param address [Hash] The person's addressRequest of type Monite::OptionalPersonAddressRequest, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param date_of_birth [String] The person's date of birth + # @param first_name [String] The person's first name + # @param last_name [String] The person's last name + # @param email [String] The person's email address + # @param phone [String] The person's phone number + # @param relationship [Hash] Describes the person's relationship to the entityRequest of type Monite::OptionalPersonRelationship, as a Hash + # * :director (Boolean) + # * :executive (Boolean) + # * :owner (Boolean) + # * :percent_ownership (Float) + # * :representative (Boolean) + # * :title (String) + # @param id_number [String] The person's ID number, as appropriate for their country + # @param ssn_last_4 [String] The last four digits of the person's Social Security number + # @param citizenship [Monite::AllowedCountries] Required for persons of US entities. The country of the person's citizenship, as +# a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple +# citizenship, specify any. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.update_by_id(person_id: "person_id") + def update_by_id(person_id:, address: nil, date_of_birth: nil, first_name: nil, last_name: nil, email: nil, phone: nil, relationship: nil, id_number: nil, ssn_last_4: nil, citizenship: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, date_of_birth: date_of_birth, first_name: first_name, last_name: last_name, email: email, phone: phone, relationship: relationship, id_number: id_number, ssn_last_4: ssn_last_4, citizenship: citizenship }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/persons/#{person_id}" +end + Monite::PersonResponse.from_json(json_object: response.body) + end +# Provide files for person onboarding verification + # + # @param person_id [String] + # @param additional_verification_document_back [String] + # @param additional_verification_document_front [String] + # @param verification_document_back [String] + # @param verification_document_front [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.upload_onboarding_documents(person_id: "person_id") + def upload_onboarding_documents(person_id:, additional_verification_document_back: nil, additional_verification_document_front: nil, verification_document_back: nil, verification_document_front: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), additional_verification_document_back: additional_verification_document_back, additional_verification_document_front: additional_verification_document_front, verification_document_back: verification_document_back, verification_document_front: verification_document_front }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/persons/#{person_id}/onboarding_documents" +end + end + end + class AsyncPersonsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::AsyncPersonsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/persons" +end + Monite::PersonsResponse.from_json(json_object: response.body) + end + end + # @param address [Hash] The person's addressRequest of type Monite::PersonAddressRequest, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param date_of_birth [String] The person's date of birth + # @param first_name [String] The person's first name + # @param last_name [String] The person's last name + # @param email [String] The person's email address + # @param phone [String] The person's phone number + # @param relationship [Hash] Describes the person's relationship to the entityRequest of type Monite::PersonRelationshipRequest, as a Hash + # * :director (Boolean) + # * :executive (Boolean) + # * :owner (Boolean) + # * :percent_ownership (Float) + # * :representative (Boolean) + # * :title (String) + # @param id_number [String] The person's ID number, as appropriate for their country + # @param ssn_last_4 [String] The last four digits of the person's Social Security number + # @param citizenship [Monite::AllowedCountries] Required for persons of US entities. The country of the person's citizenship, as +# a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple +# citizenship, specify any. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.create( +# first_name: "first_name", +# last_name: "last_name", +# email: "email", +# relationship: { } +# ) + def create(address: nil, date_of_birth: nil, first_name:, last_name:, email:, phone: nil, relationship:, id_number: nil, ssn_last_4: nil, citizenship: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, date_of_birth: date_of_birth, first_name: first_name, last_name: last_name, email: email, phone: phone, relationship: relationship, id_number: id_number, ssn_last_4: ssn_last_4, citizenship: citizenship }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/persons" +end + Monite::PersonResponse.from_json(json_object: response.body) + end + end + # @param person_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.get_by_id(person_id: "person_id") + def get_by_id(person_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/persons/#{person_id}" +end + Monite::PersonResponse.from_json(json_object: response.body) + end + end + # @param person_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.delete_by_id(person_id: "person_id") + def delete_by_id(person_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/persons/#{person_id}" +end + end + end + # @param person_id [String] + # @param address [Hash] The person's addressRequest of type Monite::OptionalPersonAddressRequest, as a Hash + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # @param date_of_birth [String] The person's date of birth + # @param first_name [String] The person's first name + # @param last_name [String] The person's last name + # @param email [String] The person's email address + # @param phone [String] The person's phone number + # @param relationship [Hash] Describes the person's relationship to the entityRequest of type Monite::OptionalPersonRelationship, as a Hash + # * :director (Boolean) + # * :executive (Boolean) + # * :owner (Boolean) + # * :percent_ownership (Float) + # * :representative (Boolean) + # * :title (String) + # @param id_number [String] The person's ID number, as appropriate for their country + # @param ssn_last_4 [String] The last four digits of the person's Social Security number + # @param citizenship [Monite::AllowedCountries] Required for persons of US entities. The country of the person's citizenship, as +# a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple +# citizenship, specify any. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PersonResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.update_by_id(person_id: "person_id") + def update_by_id(person_id:, address: nil, date_of_birth: nil, first_name: nil, last_name: nil, email: nil, phone: nil, relationship: nil, id_number: nil, ssn_last_4: nil, citizenship: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), address: address, date_of_birth: date_of_birth, first_name: first_name, last_name: last_name, email: email, phone: phone, relationship: relationship, id_number: id_number, ssn_last_4: ssn_last_4, citizenship: citizenship }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/persons/#{person_id}" +end + Monite::PersonResponse.from_json(json_object: response.body) + end + end +# Provide files for person onboarding verification + # + # @param person_id [String] + # @param additional_verification_document_back [String] + # @param additional_verification_document_front [String] + # @param verification_document_back [String] + # @param verification_document_front [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.persons.upload_onboarding_documents(person_id: "person_id") + def upload_onboarding_documents(person_id:, additional_verification_document_back: nil, additional_verification_document_front: nil, verification_document_back: nil, verification_document_front: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), additional_verification_document_back: additional_verification_document_back, additional_verification_document_front: additional_verification_document_front, verification_document_back: verification_document_back, verification_document_front: verification_document_front }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/persons/#{person_id}/onboarding_documents" +end + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entities/vat_ids/client.rb b/lib/monite/entities/vat_ids/client.rb new file mode 100644 index 0000000..b0f7853 --- /dev/null +++ b/lib/monite/entities/vat_ids/client.rb @@ -0,0 +1,425 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/entity_vat_id_resource_list" +require_relative "../../types/allowed_countries" +require_relative "../../types/vat_id_type_enum" +require_relative "../../types/entity_vat_id_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Entities + class VatIdsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::VatIdsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.get(entity_id: "entity_id") + def get(entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/vat_ids" +end + Monite::EntityVatIdResourceList.from_json(json_object: response.body) + end + # @param entity_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.create( +# entity_id: "entity_id", +# country: AF, +# value: "123456789" +# ) + def create(entity_id:, country:, type: nil, value:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/vat_ids" +end + Monite::EntityVatIdResponse.from_json(json_object: response.body) + end + # @param id [String] + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.get_by_id(id: "id", entity_id: "entity_id") + def get_by_id(id:, entity_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{id}/vat_ids/#{entity_id}" +end + Monite::EntityVatIdResponse.from_json(json_object: response.body) + end + # @param id [String] + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.delete_by_id(id: "id", entity_id: "entity_id") + def delete_by_id(id:, entity_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{id}/vat_ids/#{entity_id}" +end + end + # @param id [String] + # @param entity_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.update_by_id(id: "id", entity_id: "entity_id") + def update_by_id(id:, entity_id:, country: nil, type: nil, value: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{id}/vat_ids/#{entity_id}" +end + Monite::EntityVatIdResponse.from_json(json_object: response.body) + end + end + class AsyncVatIdsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Entities::AsyncVatIdsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResourceList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.get(entity_id: "entity_id") + def get(entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{entity_id}/vat_ids" +end + Monite::EntityVatIdResourceList.from_json(json_object: response.body) + end + end + # @param entity_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.create( +# entity_id: "entity_id", +# country: AF, +# value: "123456789" +# ) + def create(entity_id:, country:, type: nil, value:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{entity_id}/vat_ids" +end + Monite::EntityVatIdResponse.from_json(json_object: response.body) + end + end + # @param id [String] + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.get_by_id(id: "id", entity_id: "entity_id") + def get_by_id(id:, entity_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{id}/vat_ids/#{entity_id}" +end + Monite::EntityVatIdResponse.from_json(json_object: response.body) + end + end + # @param id [String] + # @param entity_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.delete_by_id(id: "id", entity_id: "entity_id") + def delete_by_id(id:, entity_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entities/#{id}/vat_ids/#{entity_id}" +end + end + end + # @param id [String] + # @param entity_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityVatIdResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entities.vat_ids.update_by_id(id: "id", entity_id: "entity_id") + def update_by_id(id:, entity_id:, country: nil, type: nil, value: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), country: country, type: type, value: value }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entities/#{id}/vat_ids/#{entity_id}" +end + Monite::EntityVatIdResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/entity_users/client.rb b/lib/monite/entity_users/client.rb new file mode 100644 index 0000000..0188b3a --- /dev/null +++ b/lib/monite/entity_users/client.rb @@ -0,0 +1,925 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/entity_user_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/entity_user_pagination_response" +require_relative "../types/entity_user_response" +require_relative "../types/entity_response" +require_relative "../types/update_entity_request" +require_relative "../types/role_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class EntityUsersClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::EntityUsersClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve a list of all entity users. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::ENTITY_USER_CURSOR_FIELDS] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param id_in [String] + # @param id_not_in [String] + # @param role_id [String] + # @param role_id_in [String] + # @param login [String] + # @param status [String] + # @param first_name [String] + # @param name_istartswith [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, id_not_in: nil, role_id: nil, role_id_in: nil, login: nil, status: nil, first_name: nil, name_istartswith: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "id__not_in": id_not_in, "role_id": role_id, "role_id__in": role_id_in, "login": login, "status": status, "first_name": first_name, "name__istartswith": name_istartswith, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/entity_users" +end + Monite::EntityUserPaginationResponse.from_json(json_object: response.body) + end +# Create a new entity user from the specified values. + # + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param login [String] + # @param phone [String] An entity user phone number in the international format + # @param role_id [String] UUID of the role assigned to this entity user + # @param title [String] Title + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.create(first_name: "Casey", login: "login") + def create(email: nil, first_name:, last_name: nil, login:, phone: nil, role_id: nil, title: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), email: email, first_name: first_name, last_name: last_name, login: login, phone: phone, role_id: role_id, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end +# Retrieve an entity user by its ID. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_current + def get_current(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/me" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end +# Change the specified fields with provided values. + # + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param phone [String] An entity user phone number in the international format + # @param title [String] Title + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.update_current + def update_current(email: nil, first_name: nil, last_name: nil, phone: nil, title: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), email: email, first_name: first_name, last_name: last_name, phone: phone, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users/me" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end +# Retrieves information of an entity, which this entity user belongs to. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_current_entity + def get_current_entity(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/my_entity" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Update information of an entity, which this entity user belongs to. + # + # @param request [Hash] Request of type Monite::UpdateEntityRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :email (String) + # * :phone (String) + # * :website (String) + # * :tax_id (String) + # * :organization (Hash) + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # * :individual (Hash) + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.update_current_entity(request: { }) + def update_current_entity(request:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users/my_entity" +end + Monite::EntityResponse.from_json(json_object: response.body) + end +# Retrieves information of a role assigned to this entity user. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_current_role + def get_current_role(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/my_role" +end + Monite::RoleResponse.from_json(json_object: response.body) + end +# Retrieve an entity user by its ID. + # + # @param entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_by_id(entity_user_id: "entity_user_id") + def get_by_id(entity_user_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/#{entity_user_id}" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + # @param entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.delete_by_id(entity_user_id: "entity_user_id") + def delete_by_id(entity_user_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/#{entity_user_id}" +end + end +# Change the specified fields with provided values. + # + # @param entity_user_id [String] + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param login [String] Login + # @param phone [String] An entity user phone number in the international format + # @param role_id [String] UUID of the role assigned to this entity user + # @param title [String] Title + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.update_by_id(entity_user_id: "entity_user_id") + def update_by_id(entity_user_id:, email: nil, first_name: nil, last_name: nil, login: nil, phone: nil, role_id: nil, title: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), email: email, first_name: first_name, last_name: last_name, login: login, phone: phone, role_id: role_id, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users/#{entity_user_id}" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + end + class AsyncEntityUsersClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncEntityUsersClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve a list of all entity users. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::ENTITY_USER_CURSOR_FIELDS] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param id_in [String] + # @param id_not_in [String] + # @param role_id [String] + # @param role_id_in [String] + # @param login [String] + # @param status [String] + # @param first_name [String] + # @param name_istartswith [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, id_not_in: nil, role_id: nil, role_id_in: nil, login: nil, status: nil, first_name: nil, name_istartswith: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "id__not_in": id_not_in, "role_id": role_id, "role_id__in": role_id_in, "login": login, "status": status, "first_name": first_name, "name__istartswith": name_istartswith, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/entity_users" +end + Monite::EntityUserPaginationResponse.from_json(json_object: response.body) + end + end +# Create a new entity user from the specified values. + # + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param login [String] + # @param phone [String] An entity user phone number in the international format + # @param role_id [String] UUID of the role assigned to this entity user + # @param title [String] Title + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.create(first_name: "Casey", login: "login") + def create(email: nil, first_name:, last_name: nil, login:, phone: nil, role_id: nil, title: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), email: email, first_name: first_name, last_name: last_name, login: login, phone: phone, role_id: role_id, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + end +# Retrieve an entity user by its ID. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_current + def get_current(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/me" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + end +# Change the specified fields with provided values. + # + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param phone [String] An entity user phone number in the international format + # @param title [String] Title + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.update_current + def update_current(email: nil, first_name: nil, last_name: nil, phone: nil, title: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), email: email, first_name: first_name, last_name: last_name, phone: phone, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users/me" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + end +# Retrieves information of an entity, which this entity user belongs to. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_current_entity + def get_current_entity(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/my_entity" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Update information of an entity, which this entity user belongs to. + # + # @param request [Hash] Request of type Monite::UpdateEntityRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :email (String) + # * :phone (String) + # * :website (String) + # * :tax_id (String) + # * :organization (Hash) + # * :business_structure (Monite::EntityBusinessStructure) + # * :directors_provided (Boolean) + # * :executives_provided (Boolean) + # * :legal_entity_id (String) + # * :legal_name (String) + # * :owners_provided (Boolean) + # * :representative_provided (Boolean) + # * :individual (Hash) + # * :date_of_birth (String) + # * :first_name (String) + # * :id_number (String) + # * :last_name (String) + # * :ssn_last_4 (String) + # * :title (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.update_current_entity(request: { }) + def update_current_entity(request:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users/my_entity" +end + Monite::EntityResponse.from_json(json_object: response.body) + end + end +# Retrieves information of a role assigned to this entity user. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_current_role + def get_current_role(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/my_role" +end + Monite::RoleResponse.from_json(json_object: response.body) + end + end +# Retrieve an entity user by its ID. + # + # @param entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.get_by_id(entity_user_id: "entity_user_id") + def get_by_id(entity_user_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/#{entity_user_id}" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + end + # @param entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.delete_by_id(entity_user_id: "entity_user_id") + def delete_by_id(entity_user_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/entity_users/#{entity_user_id}" +end + end + end +# Change the specified fields with provided values. + # + # @param entity_user_id [String] + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param login [String] Login + # @param phone [String] An entity user phone number in the international format + # @param role_id [String] UUID of the role assigned to this entity user + # @param title [String] Title + # @param request_options [Monite::RequestOptions] + # @return [Monite::EntityUserResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.entity_users.update_by_id(entity_user_id: "entity_user_id") + def update_by_id(entity_user_id:, email: nil, first_name: nil, last_name: nil, login: nil, phone: nil, role_id: nil, title: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), email: email, first_name: first_name, last_name: last_name, login: login, phone: phone, role_id: role_id, title: title }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/entity_users/#{entity_user_id}" +end + Monite::EntityUserResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/events/client.rb b/lib/monite/events/client.rb new file mode 100644 index 0000000..e81b159 --- /dev/null +++ b/lib/monite/events/client.rb @@ -0,0 +1,239 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/event_cursor_fields" +require_relative "../types/webhook_object_type" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/event_pagination_resource" +require_relative "../types/event_resource" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class EventsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::EventsClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns all webhook events that were triggered for the specified entity based on +# your enabled webhook subscriptions. These are the same events that were sent to +# your configured webhook listener endpoints, aggregated into a single list. +# Results can be filtered by the related object type or time period. +# You can use this to get the missed events for the time periods when your webhook +# listener was temporarily unavailable. +# We guarantee access to event data only from the last three months. Earlier +# events may be unavailable. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::EventCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param object_type [Monite::WebhookObjectType] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EventPaginationResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.events.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, object_type: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_type": object_type, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/events" +end + Monite::EventPaginationResource.from_json(json_object: response.body) + end +# Get a webhook event by its ID. The data is the same as you might have previously +# received in a webhook sent by Monite to your server. + # + # @param event_id [String] ID of the webhook event. This is the `id` value you might have received in a +# webhook or retrieved from `GET /events`. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EventResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.events.get_by_id(event_id: "event_id") + def get_by_id(event_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/events/#{event_id}" +end + Monite::EventResource.from_json(json_object: response.body) + end + end + class AsyncEventsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncEventsClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns all webhook events that were triggered for the specified entity based on +# your enabled webhook subscriptions. These are the same events that were sent to +# your configured webhook listener endpoints, aggregated into a single list. +# Results can be filtered by the related object type or time period. +# You can use this to get the missed events for the time periods when your webhook +# listener was temporarily unavailable. +# We guarantee access to event data only from the last three months. Earlier +# events may be unavailable. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::EventCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param object_type [Monite::WebhookObjectType] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::EventPaginationResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.events.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, object_type: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_type": object_type, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/events" +end + Monite::EventPaginationResource.from_json(json_object: response.body) + end + end +# Get a webhook event by its ID. The data is the same as you might have previously +# received in a webhook sent by Monite to your server. + # + # @param event_id [String] ID of the webhook event. This is the `id` value you might have received in a +# webhook or retrieved from `GET /events`. + # @param request_options [Monite::RequestOptions] + # @return [Monite::EventResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.events.get_by_id(event_id: "event_id") + def get_by_id(event_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/events/#{event_id}" +end + Monite::EventResource.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/files/client.rb b/lib/monite/files/client.rb new file mode 100644 index 0000000..6c32555 --- /dev/null +++ b/lib/monite/files/client.rb @@ -0,0 +1,324 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/files_response" +require_relative "../types/allowed_file_types" +require_relative "../types/file_response" +require_relative "../../core/file_utilities" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class FilesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::FilesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param id_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FilesResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.get + def get(id_in: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "id__in": id_in }.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)}/files" +end + Monite::FilesResponse.from_json(json_object: response.body) + end + # @param file [String, IO] + # @param file_type [Monite::AllowedFileTypes] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FileResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.upload(file: my_file.txt) + def upload(file:, file_type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file), file_type: file_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/files" +end + Monite::FileResponse.from_json(json_object: response.body) + end + # @param file_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FileResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.get_by_id(file_id: "file_id") + def get_by_id(file_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/files/#{file_id}" +end + Monite::FileResponse.from_json(json_object: response.body) + end + # @param file_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.delete(file_id: "file_id") + def delete(file_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/files/#{file_id}" +end + end + end + class AsyncFilesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncFilesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param id_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FilesResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.get + def get(id_in: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "id__in": id_in }.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)}/files" +end + Monite::FilesResponse.from_json(json_object: response.body) + end + end + # @param file [String, IO] + # @param file_type [Monite::AllowedFileTypes] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FileResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.upload(file: my_file.txt) + def upload(file:, file_type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file), file_type: file_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/files" +end + Monite::FileResponse.from_json(json_object: response.body) + end + end + # @param file_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::FileResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.get_by_id(file_id: "file_id") + def get_by_id(file_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/files/#{file_id}" +end + Monite::FileResponse.from_json(json_object: response.body) + end + end + # @param file_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.files.delete(file_id: "file_id") + def delete(file_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/files/#{file_id}" +end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/financing/client.rb b/lib/monite/financing/client.rb new file mode 100644 index 0000000..819f2a4 --- /dev/null +++ b/lib/monite/financing/client.rb @@ -0,0 +1,417 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/financing_invoice_cursor_fields" +require_relative "../types/wc_invoice_status" +require_relative "../types/financing_invoice_type" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/financing_invoice_list_response" +require_relative "../types/financing_push_invoices_request_invoice" +require_relative "../types/financing_push_invoices_response" +require_relative "../types/financing_offers_response" +require_relative "../types/financing_token_response" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class FinancingClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::FinancingClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of invoices requested for financing + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::FinancingInvoiceCursorFields] Allowed sort fields + # @param invoice_id [String] ID of a payable or receivable invoice. + # @param invoice_id_in [String] List of invoice IDs. + # @param status [Monite::WcInvoiceStatus] Status of the invoice. + # @param status_in [Monite::WcInvoiceStatus] List of invoice statuses. + # @param type [Monite::FinancingInvoiceType] Type of the invoice. payable or receivable. + # @param type_in [Monite::FinancingInvoiceType] List of invoice types. + # @param document_id [String] Document ID of the invoice. + # @param document_id_in [String] List of document IDs. + # @param issue_date_gt [DateTime] Issue date greater than. + # @param issue_date_lt [DateTime] Issue date less than. + # @param issue_date_gte [DateTime] Issue date greater than or equal. + # @param issue_date_lte [DateTime] Issue date less than or equal. + # @param due_date_gt [DateTime] Due date greater than. + # @param due_date_lt [DateTime] Due date less than. + # @param due_date_gte [DateTime] Due date greater than or equal. + # @param due_date_lte [DateTime] Due date less than or equal. + # @param created_at_gt [DateTime] Created date greater than. + # @param created_at_lt [DateTime] Created date less than. + # @param created_at_gte [DateTime] Created date greater than or equal. + # @param created_at_lte [DateTime] Created date less than or equal. + # @param total_amount [Integer] Total amount of the invoice in minor units. + # @param total_amount_gt [Integer] Total amount greater than. + # @param total_amount_lt [Integer] Total amount less than. + # @param total_amount_gte [Integer] Total amount greater than or equal. + # @param total_amount_lte [Integer] Total amount less than or equal. + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingInvoiceListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.get_financing_invoices + def get_financing_invoices(order: nil, limit: nil, pagination_token: nil, sort: nil, invoice_id: nil, invoice_id_in: nil, status: nil, status_in: nil, type: nil, type_in: nil, document_id: nil, document_id_in: nil, issue_date_gt: nil, issue_date_lt: nil, issue_date_gte: nil, issue_date_lte: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "invoice_id": invoice_id, "invoice_id__in": invoice_id_in, "status": status, "status__in": status_in, "type": type, "type__in": type_in, "document_id": document_id, "document_id__in": document_id_in, "issue_date__gt": issue_date_gt, "issue_date__lt": issue_date_lt, "issue_date__gte": issue_date_gte, "issue_date__lte": issue_date_lte, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte }.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)}/financing_invoices" +end + Monite::FinancingInvoiceListResponse.from_json(json_object: response.body) + end +# Returns a session token and a connect token to open Kanmon SDK for confirming +# invoice details. + # + # @param invoices [Array] A list of invoices to request financing for.Request of type Array, as a Hash + # * :id (String) + # * :type (Monite::FinancingInvoiceType) + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingPushInvoicesResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.post_financing_invoices(invoices: [{ id: "id", type: PAYABLE }]) + def post_financing_invoices(invoices:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), invoices: invoices }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/financing_invoices" +end + Monite::FinancingPushInvoicesResponse.from_json(json_object: response.body) + end +# Returns a list of financing offers and the business's onboarding status + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingOffersResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.get_financing_offers + def get_financing_offers(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/financing_offers" +end + Monite::FinancingOffersResponse.from_json(json_object: response.body) + end +# Returns a token for Kanmon SDK. Creates a business and user on Kanmon if not +# already exist. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingTokenResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.post_financing_tokens + def post_financing_tokens(request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/financing_tokens" +end + Monite::FinancingTokenResponse.from_json(json_object: response.body) + end + end + class AsyncFinancingClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncFinancingClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of invoices requested for financing + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::FinancingInvoiceCursorFields] Allowed sort fields + # @param invoice_id [String] ID of a payable or receivable invoice. + # @param invoice_id_in [String] List of invoice IDs. + # @param status [Monite::WcInvoiceStatus] Status of the invoice. + # @param status_in [Monite::WcInvoiceStatus] List of invoice statuses. + # @param type [Monite::FinancingInvoiceType] Type of the invoice. payable or receivable. + # @param type_in [Monite::FinancingInvoiceType] List of invoice types. + # @param document_id [String] Document ID of the invoice. + # @param document_id_in [String] List of document IDs. + # @param issue_date_gt [DateTime] Issue date greater than. + # @param issue_date_lt [DateTime] Issue date less than. + # @param issue_date_gte [DateTime] Issue date greater than or equal. + # @param issue_date_lte [DateTime] Issue date less than or equal. + # @param due_date_gt [DateTime] Due date greater than. + # @param due_date_lt [DateTime] Due date less than. + # @param due_date_gte [DateTime] Due date greater than or equal. + # @param due_date_lte [DateTime] Due date less than or equal. + # @param created_at_gt [DateTime] Created date greater than. + # @param created_at_lt [DateTime] Created date less than. + # @param created_at_gte [DateTime] Created date greater than or equal. + # @param created_at_lte [DateTime] Created date less than or equal. + # @param total_amount [Integer] Total amount of the invoice in minor units. + # @param total_amount_gt [Integer] Total amount greater than. + # @param total_amount_lt [Integer] Total amount less than. + # @param total_amount_gte [Integer] Total amount greater than or equal. + # @param total_amount_lte [Integer] Total amount less than or equal. + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingInvoiceListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.get_financing_invoices + def get_financing_invoices(order: nil, limit: nil, pagination_token: nil, sort: nil, invoice_id: nil, invoice_id_in: nil, status: nil, status_in: nil, type: nil, type_in: nil, document_id: nil, document_id_in: nil, issue_date_gt: nil, issue_date_lt: nil, issue_date_gte: nil, issue_date_lte: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "invoice_id": invoice_id, "invoice_id__in": invoice_id_in, "status": status, "status__in": status_in, "type": type, "type__in": type_in, "document_id": document_id, "document_id__in": document_id_in, "issue_date__gt": issue_date_gt, "issue_date__lt": issue_date_lt, "issue_date__gte": issue_date_gte, "issue_date__lte": issue_date_lte, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte }.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)}/financing_invoices" +end + Monite::FinancingInvoiceListResponse.from_json(json_object: response.body) + end + end +# Returns a session token and a connect token to open Kanmon SDK for confirming +# invoice details. + # + # @param invoices [Array] A list of invoices to request financing for.Request of type Array, as a Hash + # * :id (String) + # * :type (Monite::FinancingInvoiceType) + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingPushInvoicesResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.post_financing_invoices(invoices: [{ id: "id", type: PAYABLE }]) + def post_financing_invoices(invoices:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), invoices: invoices }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/financing_invoices" +end + Monite::FinancingPushInvoicesResponse.from_json(json_object: response.body) + end + end +# Returns a list of financing offers and the business's onboarding status + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingOffersResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.get_financing_offers + def get_financing_offers(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/financing_offers" +end + Monite::FinancingOffersResponse.from_json(json_object: response.body) + end + end +# Returns a token for Kanmon SDK. Creates a business and user on Kanmon if not +# already exist. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::FinancingTokenResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.financing.post_financing_tokens + def post_financing_tokens(request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/financing_tokens" +end + Monite::FinancingTokenResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/mail_templates/client.rb b/lib/monite/mail_templates/client.rb new file mode 100644 index 0000000..dadf846 --- /dev/null +++ b/lib/monite/mail_templates/client.rb @@ -0,0 +1,714 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/custom_templates_cursor_fields" +require_relative "../types/document_object_type_request_enum" +require_relative "../types/custom_templates_pagination_response" +require_relative "../types/language_code_enum" +require_relative "../types/custom_template_data_schema" +require_relative "../types/preview_template_response" +require_relative "../types/system_templates" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class MailTemplatesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::MailTemplatesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all custom templates + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::CustomTemplatesCursorFields] Allowed sort fields + # @param type [Monite::DocumentObjectTypeRequestEnum] + # @param type_in [Monite::DocumentObjectTypeRequestEnum] + # @param type_not_in [Monite::DocumentObjectTypeRequestEnum] + # @param is_default [Boolean] + # @param name [String] + # @param name_iexact [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplatesPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, type: nil, type_in: nil, type_not_in: nil, is_default: nil, name: nil, name_iexact: nil, name_contains: nil, name_icontains: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "type": type, "type__in": type_in, "type__not_in": type_not_in, "is_default": is_default, "name": name, "name__iexact": name_iexact, "name__contains": name_contains, "name__icontains": name_icontains }.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)}/mail_templates" +end + Monite::CustomTemplatesPaginationResponse.from_json(json_object: response.body) + end +# Create custom template + # + # @param body_template [String] Jinja2 compatible string with email body + # @param is_default [Boolean] Is default template + # @param language [Monite::LanguageCodeEnum] Lowercase ISO code of language + # @param name [String] Custom template name + # @param subject_template [String] Jinja2 compatible string with email subject + # @param type [Monite::DocumentObjectTypeRequestEnum] Document type of content + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.create( +# body_template: "body_template", +# name: "name", +# subject_template: "subject_template", +# type: RECEIVABLES_QUOTE +# ) + def create(body_template:, is_default: nil, language: nil, name:, subject_template:, type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_template: body_template, is_default: is_default, language: language, name: name, subject_template: subject_template, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mail_templates" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end +# Preview rendered template + # + # @param body [String] Body text of the template + # @param document_type [Monite::DocumentObjectTypeRequestEnum] Document type of content + # @param language_code [Monite::LanguageCodeEnum] Lowercase ISO code of language + # @param subject [String] Subject text of the template + # @param request_options [Monite::RequestOptions] + # @return [Monite::PreviewTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.preview( +# body: "body", +# document_type: RECEIVABLES_QUOTE, +# language_code: AB, +# subject: "subject" +# ) + def preview(body:, document_type:, language_code:, subject:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body: body, document_type: document_type, language_code: language_code, subject: subject }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mail_templates/preview" +end + Monite::PreviewTemplateResponse.from_json(json_object: response.body) + end +# Get all system templates + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::SystemTemplates] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.get_system + def get_system(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/system" +end + Monite::SystemTemplates.from_json(json_object: response.body) + end +# Get custom template by ID + # + # @param template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.get_by_id(template_id: "template_id") + def get_by_id(template_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/#{template_id}" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end +# Delete custom template bt ID + # + # @param template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.delete_by_id(template_id: "template_id") + def delete_by_id(template_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/#{template_id}" +end + end +# Update custom template by ID + # + # @param template_id [String] + # @param body_template [String] Jinja2 compatible string with email body + # @param language [Monite::LanguageCodeEnum] Lowercase ISO code of language + # @param name [String] Custom template name + # @param subject_template [String] Jinja2 compatible string with email subject + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.update_by_id(template_id: "template_id") + def update_by_id(template_id:, body_template: nil, language: nil, name: nil, subject_template: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_template: body_template, language: language, name: name, subject_template: subject_template }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mail_templates/#{template_id}" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end +# Make template default + # + # @param template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.make_default_by_id(template_id: "template_id") + def make_default_by_id(template_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/#{template_id}/make_default" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end + end + class AsyncMailTemplatesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncMailTemplatesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all custom templates + # + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::CustomTemplatesCursorFields] Allowed sort fields + # @param type [Monite::DocumentObjectTypeRequestEnum] + # @param type_in [Monite::DocumentObjectTypeRequestEnum] + # @param type_not_in [Monite::DocumentObjectTypeRequestEnum] + # @param is_default [Boolean] + # @param name [String] + # @param name_iexact [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplatesPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, type: nil, type_in: nil, type_not_in: nil, is_default: nil, name: nil, name_iexact: nil, name_contains: nil, name_icontains: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "type": type, "type__in": type_in, "type__not_in": type_not_in, "is_default": is_default, "name": name, "name__iexact": name_iexact, "name__contains": name_contains, "name__icontains": name_icontains }.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)}/mail_templates" +end + Monite::CustomTemplatesPaginationResponse.from_json(json_object: response.body) + end + end +# Create custom template + # + # @param body_template [String] Jinja2 compatible string with email body + # @param is_default [Boolean] Is default template + # @param language [Monite::LanguageCodeEnum] Lowercase ISO code of language + # @param name [String] Custom template name + # @param subject_template [String] Jinja2 compatible string with email subject + # @param type [Monite::DocumentObjectTypeRequestEnum] Document type of content + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.create( +# body_template: "body_template", +# name: "name", +# subject_template: "subject_template", +# type: RECEIVABLES_QUOTE +# ) + def create(body_template:, is_default: nil, language: nil, name:, subject_template:, type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_template: body_template, is_default: is_default, language: language, name: name, subject_template: subject_template, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mail_templates" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end + end +# Preview rendered template + # + # @param body [String] Body text of the template + # @param document_type [Monite::DocumentObjectTypeRequestEnum] Document type of content + # @param language_code [Monite::LanguageCodeEnum] Lowercase ISO code of language + # @param subject [String] Subject text of the template + # @param request_options [Monite::RequestOptions] + # @return [Monite::PreviewTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.preview( +# body: "body", +# document_type: RECEIVABLES_QUOTE, +# language_code: AB, +# subject: "subject" +# ) + def preview(body:, document_type:, language_code:, subject:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body: body, document_type: document_type, language_code: language_code, subject: subject }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mail_templates/preview" +end + Monite::PreviewTemplateResponse.from_json(json_object: response.body) + end + end +# Get all system templates + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::SystemTemplates] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.get_system + def get_system(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/system" +end + Monite::SystemTemplates.from_json(json_object: response.body) + end + end +# Get custom template by ID + # + # @param template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.get_by_id(template_id: "template_id") + def get_by_id(template_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/#{template_id}" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end + end +# Delete custom template bt ID + # + # @param template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.delete_by_id(template_id: "template_id") + def delete_by_id(template_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/#{template_id}" +end + end + end +# Update custom template by ID + # + # @param template_id [String] + # @param body_template [String] Jinja2 compatible string with email body + # @param language [Monite::LanguageCodeEnum] Lowercase ISO code of language + # @param name [String] Custom template name + # @param subject_template [String] Jinja2 compatible string with email subject + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.update_by_id(template_id: "template_id") + def update_by_id(template_id:, body_template: nil, language: nil, name: nil, subject_template: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_template: body_template, language: language, name: name, subject_template: subject_template }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mail_templates/#{template_id}" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end + end +# Make template default + # + # @param template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::CustomTemplateDataSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mail_templates.make_default_by_id(template_id: "template_id") + def make_default_by_id(template_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mail_templates/#{template_id}/make_default" +end + Monite::CustomTemplateDataSchema.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/mailbox_domains/client.rb b/lib/monite/mailbox_domains/client.rb new file mode 100644 index 0000000..2360f2f --- /dev/null +++ b/lib/monite/mailbox_domains/client.rb @@ -0,0 +1,343 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/domain_list_response" +require_relative "../types/domain_response" +require_relative "../types/verify_response" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class MailboxDomainsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::MailboxDomainsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all domains owned by partner_id + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::DomainListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailbox_domains" +end + Monite::DomainListResponse.from_json(json_object: response.body) + end +# Create domain for the partner_id + # + # @param domain [String] The domain name, such as `mail.mycompany.com`. Can contain only alphanumeric +# characters (A..Z a..z 0..9), dots (.), and hyphens (-). Each segment of the +# domain name must start and end with either a letter or a digit. + # @param request_options [Monite::RequestOptions] + # @return [Monite::DomainResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.create(domain: "domain") + def create(domain:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), domain: domain }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mailbox_domains" +end + Monite::DomainResponse.from_json(json_object: response.body) + end +# Delete domain for the partner_id + # + # @param domain_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.delete_by_id(domain_id: "domain_id") + def delete_by_id(domain_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailbox_domains/#{domain_id}" +end + end +# Verify domain for the partner_id + # + # @param domain_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::VerifyResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.verify_by_id(domain_id: "domain_id") + def verify_by_id(domain_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailbox_domains/#{domain_id}/verify" +end + Monite::VerifyResponse.from_json(json_object: response.body) + end + end + class AsyncMailboxDomainsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncMailboxDomainsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all domains owned by partner_id + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::DomainListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailbox_domains" +end + Monite::DomainListResponse.from_json(json_object: response.body) + end + end +# Create domain for the partner_id + # + # @param domain [String] The domain name, such as `mail.mycompany.com`. Can contain only alphanumeric +# characters (A..Z a..z 0..9), dots (.), and hyphens (-). Each segment of the +# domain name must start and end with either a letter or a digit. + # @param request_options [Monite::RequestOptions] + # @return [Monite::DomainResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.create(domain: "domain") + def create(domain:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), domain: domain }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mailbox_domains" +end + Monite::DomainResponse.from_json(json_object: response.body) + end + end +# Delete domain for the partner_id + # + # @param domain_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.delete_by_id(domain_id: "domain_id") + def delete_by_id(domain_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailbox_domains/#{domain_id}" +end + end + end +# Verify domain for the partner_id + # + # @param domain_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::VerifyResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailbox_domains.verify_by_id(domain_id: "domain_id") + def verify_by_id(domain_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailbox_domains/#{domain_id}/verify" +end + Monite::VerifyResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/mailboxes/client.rb b/lib/monite/mailboxes/client.rb new file mode 100644 index 0000000..1a91d75 --- /dev/null +++ b/lib/monite/mailboxes/client.rb @@ -0,0 +1,347 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/mailbox_data_response" +require_relative "../types/mailbox_object_type_enum" +require_relative "../types/mailbox_response" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class MailboxesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::MailboxesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all mailboxes owned by Entity + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::MailboxDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailboxes" +end + Monite::MailboxDataResponse.from_json(json_object: response.body) + end +# Create a new mailbox + # + # @param mailbox_domain_id [String] + # @param mailbox_name [String] + # @param related_object_type [Monite::MAILBOX_OBJECT_TYPE_ENUM] Related object type: payable and so on + # @param request_options [Monite::RequestOptions] + # @return [Monite::MailboxResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.create( +# mailbox_domain_id: "mailbox_domain_id", +# mailbox_name: "mailbox_name", +# related_object_type: "payable" +# ) + def create(mailbox_domain_id:, mailbox_name:, related_object_type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), mailbox_domain_id: mailbox_domain_id, mailbox_name: mailbox_name, related_object_type: related_object_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mailboxes" +end + Monite::MailboxResponse.from_json(json_object: response.body) + end +# Get all mailboxes owned by Entity + # + # @param entity_ids [Array] + # @param request_options [Monite::RequestOptions] + # @return [Monite::MailboxDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.search(entity_ids: ["entity_ids"]) + def search(entity_ids:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), entity_ids: entity_ids }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mailboxes/search" +end + Monite::MailboxDataResponse.from_json(json_object: response.body) + end +# Delete mailbox + # + # @param mailbox_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.delete_by_id(mailbox_id: "mailbox_id") + def delete_by_id(mailbox_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailboxes/#{mailbox_id}" +end + end + end + class AsyncMailboxesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncMailboxesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all mailboxes owned by Entity + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::MailboxDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailboxes" +end + Monite::MailboxDataResponse.from_json(json_object: response.body) + end + end +# Create a new mailbox + # + # @param mailbox_domain_id [String] + # @param mailbox_name [String] + # @param related_object_type [Monite::MAILBOX_OBJECT_TYPE_ENUM] Related object type: payable and so on + # @param request_options [Monite::RequestOptions] + # @return [Monite::MailboxResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.create( +# mailbox_domain_id: "mailbox_domain_id", +# mailbox_name: "mailbox_name", +# related_object_type: "payable" +# ) + def create(mailbox_domain_id:, mailbox_name:, related_object_type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), mailbox_domain_id: mailbox_domain_id, mailbox_name: mailbox_name, related_object_type: related_object_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mailboxes" +end + Monite::MailboxResponse.from_json(json_object: response.body) + end + end +# Get all mailboxes owned by Entity + # + # @param entity_ids [Array] + # @param request_options [Monite::RequestOptions] + # @return [Monite::MailboxDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.search(entity_ids: ["entity_ids"]) + def search(entity_ids:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), entity_ids: entity_ids }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/mailboxes/search" +end + Monite::MailboxDataResponse.from_json(json_object: response.body) + end + end +# Delete mailbox + # + # @param mailbox_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.mailboxes.delete_by_id(mailbox_id: "mailbox_id") + def delete_by_id(mailbox_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/mailboxes/#{mailbox_id}" +end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/measure_units/client.rb b/lib/monite/measure_units/client.rb new file mode 100644 index 0000000..a05090f --- /dev/null +++ b/lib/monite/measure_units/client.rb @@ -0,0 +1,402 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/unit_list_response" +require_relative "../types/unit_request" +require_relative "../types/unit_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class MeasureUnitsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::MeasureUnitsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/measure_units" +end + Monite::UnitListResponse.from_json(json_object: response.body) + end + # @param request [Hash] Request of type Monite::UnitRequest, as a Hash + # * :description (String) + # * :name (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.create(request: { name: "name" }) + def create(request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/measure_units" +end + Monite::UnitResponse.from_json(json_object: response.body) + end + # @param unit_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.get_by_id(unit_id: "unit_id") + def get_by_id(unit_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/measure_units/#{unit_id}" +end + Monite::UnitResponse.from_json(json_object: response.body) + end + # @param unit_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.delete_by_id(unit_id: "unit_id") + def delete_by_id(unit_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/measure_units/#{unit_id}" +end + end + # @param unit_id [String] + # @param description [String] + # @param name [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.update_by_id(unit_id: "unit_id") + def update_by_id(unit_id:, description: nil, name: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/measure_units/#{unit_id}" +end + Monite::UnitResponse.from_json(json_object: response.body) + end + end + class AsyncMeasureUnitsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncMeasureUnitsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/measure_units" +end + Monite::UnitListResponse.from_json(json_object: response.body) + end + end + # @param request [Hash] Request of type Monite::UnitRequest, as a Hash + # * :description (String) + # * :name (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.create(request: { name: "name" }) + def create(request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/measure_units" +end + Monite::UnitResponse.from_json(json_object: response.body) + end + end + # @param unit_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.get_by_id(unit_id: "unit_id") + def get_by_id(unit_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/measure_units/#{unit_id}" +end + Monite::UnitResponse.from_json(json_object: response.body) + end + end + # @param unit_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.delete_by_id(unit_id: "unit_id") + def delete_by_id(unit_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/measure_units/#{unit_id}" +end + end + end + # @param unit_id [String] + # @param description [String] + # @param name [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::UnitResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.measure_units.update_by_id(unit_id: "unit_id") + def update_by_id(unit_id:, description: nil, name: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/measure_units/#{unit_id}" +end + Monite::UnitResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/overdue_reminders/client.rb b/lib/monite/overdue_reminders/client.rb new file mode 100644 index 0000000..4afbd5d --- /dev/null +++ b/lib/monite/overdue_reminders/client.rb @@ -0,0 +1,429 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/all_overdue_reminders_response" +require_relative "../types/recipients" +require_relative "../types/overdue_reminder_term" +require_relative "../types/overdue_reminder_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class OverdueRemindersClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::OverdueRemindersClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::AllOverdueRemindersResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/overdue_reminders" +end + Monite::AllOverdueRemindersResponse.from_json(json_object: response.body) + end + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param terms [Array] Overdue reminder terms to send for paymentRequest of type Array, as a Hash + # * :body (String) + # * :days_after (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::OverdueReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.create(name: "name") + def create(name:, recipients: nil, terms: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, terms: terms }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/overdue_reminders" +end + Monite::OverdueReminderResponse.from_json(json_object: response.body) + end + # @param overdue_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::OverdueReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.get_by_id(overdue_reminder_id: "overdue_reminder_id") + def get_by_id(overdue_reminder_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/overdue_reminders/#{overdue_reminder_id}" +end + Monite::OverdueReminderResponse.from_json(json_object: response.body) + end + # @param overdue_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.delete_by_id(overdue_reminder_id: "overdue_reminder_id") + def delete_by_id(overdue_reminder_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/overdue_reminders/#{overdue_reminder_id}" +end + end + # @param overdue_reminder_id [String] + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param terms [Array] Overdue reminder terms to send for paymentRequest of type Array, as a Hash + # * :body (String) + # * :days_after (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::OverdueReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.update_by_id(overdue_reminder_id: "overdue_reminder_id") + def update_by_id(overdue_reminder_id:, name: nil, recipients: nil, terms: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, terms: terms }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/overdue_reminders/#{overdue_reminder_id}" +end + Monite::OverdueReminderResponse.from_json(json_object: response.body) + end + end + class AsyncOverdueRemindersClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncOverdueRemindersClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::AllOverdueRemindersResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/overdue_reminders" +end + Monite::AllOverdueRemindersResponse.from_json(json_object: response.body) + end + end + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param terms [Array] Overdue reminder terms to send for paymentRequest of type Array, as a Hash + # * :body (String) + # * :days_after (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::OverdueReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.create(name: "name") + def create(name:, recipients: nil, terms: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, terms: terms }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/overdue_reminders" +end + Monite::OverdueReminderResponse.from_json(json_object: response.body) + end + end + # @param overdue_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::OverdueReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.get_by_id(overdue_reminder_id: "overdue_reminder_id") + def get_by_id(overdue_reminder_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/overdue_reminders/#{overdue_reminder_id}" +end + Monite::OverdueReminderResponse.from_json(json_object: response.body) + end + end + # @param overdue_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.delete_by_id(overdue_reminder_id: "overdue_reminder_id") + def delete_by_id(overdue_reminder_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/overdue_reminders/#{overdue_reminder_id}" +end + end + end + # @param overdue_reminder_id [String] + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param terms [Array] Overdue reminder terms to send for paymentRequest of type Array, as a Hash + # * :body (String) + # * :days_after (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::OverdueReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.overdue_reminders.update_by_id(overdue_reminder_id: "overdue_reminder_id") + def update_by_id(overdue_reminder_id:, name: nil, recipients: nil, terms: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, terms: terms }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/overdue_reminders/#{overdue_reminder_id}" +end + Monite::OverdueReminderResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/partner_settings/client.rb b/lib/monite/partner_settings/client.rb new file mode 100644 index 0000000..cb181db --- /dev/null +++ b/lib/monite/partner_settings/client.rb @@ -0,0 +1,272 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/partner_project_settings_payload_output" +require_relative "../types/currency_settings_input" +require_relative "../types/payable_settings" +require_relative "../types/receivable_settings" +require_relative "../types/mail_settings" +require_relative "../types/unit" +require_relative "../types/payments_settings_input" +require_relative "../types/api_version" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PartnerSettingsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PartnerSettingsClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve all settings for this partner. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerProjectSettingsPayloadOutput] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.partner_settings.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/settings" +end + Monite::PartnerProjectSettingsPayloadOutput.from_json(json_object: response.body) + end +# Change the specified fields with the provided values. + # + # @param currency [Hash] Custom currency exchange rates.Request of type Monite::CurrencySettingsInput, as a Hash + # * :default (Monite::CurrencyEnum) + # * :exchange_rates (Array) + # @param payable [Hash] Settings for the payables module.Request of type Monite::PayableSettings, as a Hash + # * :allow_cancel_duplicates_automatically (Boolean) + # * :allow_counterpart_autocreation (Boolean) + # * :allow_counterpart_autolinking (Boolean) + # * :allow_credit_note_autolinking (Boolean) + # * :approve_page_url (String) + # * :default_state (String) + # * :enable_line_items (Boolean) + # * :skip_approval_for_paid_invoice (Boolean) + # @param receivable [Hash] Settings for the receivables module.Request of type Monite::ReceivableSettings, as a Hash + # * :create_without_personal_info (Boolean) + # * :deduction_title (String) + # @param mail [Hash] Settings for email and mailboxes.Request of type Monite::MailSettings, as a Hash + # * :attach_documents_as_pdf (Boolean) + # * :from_email_username (String) + # * :from_name (String) + # @param commercial_conditions [Array] Commercial conditions for receivables. + # @param units [Array] Measurement units.Request of type Array, as a Hash + # * :designation (String) + # * :name (String) + # @param website [String] + # @param default_role [Hash{String => Object}] A default role to provision upon new entity creation. + # @param payments [Hash] Settings for the payments module.Request of type Monite::PaymentsSettingsInput, as a Hash + # * :payment_page_domain (String) + # * :payment_page_theme (Hash) + # * :background_color (String) + # * :border_radius (String) + # * :button (Hash) + # * :primary_color (String) + # * :primary_hover_color (String) + # * :secondary_color (String) + # * :secondary_hover_color (String) + # * :card (Hash) + # * :background_color (String) + # * :font_color (String) + # * :font_family (String) + # * :font_link_href (String) + # * :logo_src (String) + # * :support_email (String) + # @param api_version [Monite::ApiVersion] Default API version for partner. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerProjectSettingsPayloadOutput] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.partner_settings.update + def update(currency: nil, payable: nil, receivable: nil, mail: nil, commercial_conditions: nil, units: nil, website: nil, default_role: nil, payments: nil, api_version: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), currency: currency, payable: payable, receivable: receivable, mail: mail, commercial_conditions: commercial_conditions, units: units, website: website, default_role: default_role, payments: payments, api_version: api_version }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/settings" +end + Monite::PartnerProjectSettingsPayloadOutput.from_json(json_object: response.body) + end + end + class AsyncPartnerSettingsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPartnerSettingsClient] + def initialize(request_client:) + @request_client = request_client + end +# Retrieve all settings for this partner. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerProjectSettingsPayloadOutput] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.partner_settings.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/settings" +end + Monite::PartnerProjectSettingsPayloadOutput.from_json(json_object: response.body) + end + end +# Change the specified fields with the provided values. + # + # @param currency [Hash] Custom currency exchange rates.Request of type Monite::CurrencySettingsInput, as a Hash + # * :default (Monite::CurrencyEnum) + # * :exchange_rates (Array) + # @param payable [Hash] Settings for the payables module.Request of type Monite::PayableSettings, as a Hash + # * :allow_cancel_duplicates_automatically (Boolean) + # * :allow_counterpart_autocreation (Boolean) + # * :allow_counterpart_autolinking (Boolean) + # * :allow_credit_note_autolinking (Boolean) + # * :approve_page_url (String) + # * :default_state (String) + # * :enable_line_items (Boolean) + # * :skip_approval_for_paid_invoice (Boolean) + # @param receivable [Hash] Settings for the receivables module.Request of type Monite::ReceivableSettings, as a Hash + # * :create_without_personal_info (Boolean) + # * :deduction_title (String) + # @param mail [Hash] Settings for email and mailboxes.Request of type Monite::MailSettings, as a Hash + # * :attach_documents_as_pdf (Boolean) + # * :from_email_username (String) + # * :from_name (String) + # @param commercial_conditions [Array] Commercial conditions for receivables. + # @param units [Array] Measurement units.Request of type Array, as a Hash + # * :designation (String) + # * :name (String) + # @param website [String] + # @param default_role [Hash{String => Object}] A default role to provision upon new entity creation. + # @param payments [Hash] Settings for the payments module.Request of type Monite::PaymentsSettingsInput, as a Hash + # * :payment_page_domain (String) + # * :payment_page_theme (Hash) + # * :background_color (String) + # * :border_radius (String) + # * :button (Hash) + # * :primary_color (String) + # * :primary_hover_color (String) + # * :secondary_color (String) + # * :secondary_hover_color (String) + # * :card (Hash) + # * :background_color (String) + # * :font_color (String) + # * :font_family (String) + # * :font_link_href (String) + # * :logo_src (String) + # * :support_email (String) + # @param api_version [Monite::ApiVersion] Default API version for partner. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PartnerProjectSettingsPayloadOutput] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.partner_settings.update + def update(currency: nil, payable: nil, receivable: nil, mail: nil, commercial_conditions: nil, units: nil, website: nil, default_role: nil, payments: nil, api_version: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), currency: currency, payable: payable, receivable: receivable, mail: mail, commercial_conditions: commercial_conditions, units: units, website: website, default_role: default_role, payments: payments, api_version: api_version }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/settings" +end + Monite::PartnerProjectSettingsPayloadOutput.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payables/client.rb b/lib/monite/payables/client.rb new file mode 100644 index 0000000..30d5a74 --- /dev/null +++ b/lib/monite/payables/client.rb @@ -0,0 +1,2439 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "line_items/client" +require_relative "../types/order_enum" +require_relative "../types/payable_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/payable_state_enum" +require_relative "../types/currency_enum" +require_relative "../types/source_of_payable_data_enum" +require_relative "../types/ocr_status_enum" +require_relative "../types/payable_pagination_response" +require_relative "../types/payable_payment_terms_create_payload" +require_relative "../types/suggested_payment_term" +require_relative "../types/payable_response_schema" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/payable_aggregated_data_response" +require_relative "../../core/file_utilities" +require_relative "../types/payable_validations_resource" +require_relative "../types/payables_fields_allowed_for_validate" +require_relative "../types/payable_templates_variables_object_list" +require_relative "../types/counterpart_raw_data_update_request" +require_relative "../types/payable_validation_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PayablesClient + # @return [Monite::RequestClient] + attr_reader :request_client + # @return [Monite::Payables::LineItemsClient] + attr_reader :line_items + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PayablesClient] + def initialize(request_client:) + @request_client = request_client + @line_items = Monite::Payables::LineItemsClient.new(request_client: request_client) + end +# Lists all payables from the connected entity. +# If you already have the data of the payable (amount in [minor units]( +# https://docs.monite.com/references/currencies#minor-units), currency, vendor +# information, and other details) +# stored somewhere as individual attributes, you can create a payable with these +# attributes by calling [POST +# /payables](https://docs.monite.com/api/payables/post-payables) and providing the +# [base64-encoded]( +# https://en.wikipedia.org/wiki/Base64) contents of the original invoice file in +# the field `base64_encoded_file`. +# A payable is a financial document given by an entity`s supplier itemizing the +# purchase of a good or a service and +# demanding payment. +# The `file_name` field is optional. If omitted, it defaults to +# “default_file_name”. If the settings are configured +# to automatically set `suggested_payment_term`, this object can be omitted from +# the request body. +# The `id` generated for this payable can be used in other API calls to update the +# data of this payable or trigger [ +# status +# nsitions](https://docs.monite.com/accounts-payable/approvals/manual-transition), +# for example. essential data +# fields to move from `draft` to `new` +# Related guide: [Create a payable from +# ://docs.monite.com/accounts-payable/payables/collect#create-a-payable-from-data) +# See also: +# [Automatic calculation of due +# .monite.com/accounts-payable/payables/collect#automatic-calculation-of-due-date) +# [Suggested payment +# ttps://docs.monite.com/accounts-payable/payables/collect#suggested-payment-date) +# [Attach +# file](https://docs.monite.com/accounts-payable/payables/collect#attach-file) +# [Collect payables by +# ttps://docs.monite.com/accounts-payable/payables/collect#send-payables-by-email) +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::PayableCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] Return only payables created in Monite after the specified date and time. The +# value must be in the ISO 8601 format YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]. + # @param created_at_lt [DateTime] Return only payables created in Monite before the specified date and time. + # @param created_at_gte [DateTime] Return only payables created in Monite on or after the specified date and time. + # @param created_at_lte [DateTime] Return only payables created in Monite before or on the specified date and time. + # @param status [Monite::PayableStateEnum] Return only payables that have the specified +# [status](https://docs.monite.com/accounts-payable/payables/index). +# To query multiple statuses at once, use the `status__in` parameter instead. + # @param status_in [Monite::PayableStateEnum] Return only payables that have the specified +# [statuses](https://docs.monite.com/accounts-payable/payables/index). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=new` + # @param id_in [String] Return only payables with specified IDs. Valid but nonexistent IDs do not raise +# errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param total_amount [Integer] Return only payables with the exact specified total amount. The amount must be +# specified in the minor units of currency. For example, $12.5 is represented as +# 1250. + # @param total_amount_gt [Integer] Return only payables whose total amount (in minor units) exceeds the specified +# value. + # @param total_amount_lt [Integer] Return only payables whose total amount (in minor units) is less than the +# specified value. + # @param total_amount_gte [Integer] Return only payables whose total amount (in minor units) is greater than or +# equal to the specified value. + # @param total_amount_lte [Integer] Return only payables whose total amount (in minor units) is less than or equal +# to the specified value. + # @param amount [Integer] Return only payables with the specified amount. + # @param amount_gt [Integer] Return only payables whose amount (in minor units) exceeds the specified value. + # @param amount_lt [Integer] Return only payables whose amount (in minor units) is less than the specified +# value. + # @param amount_gte [Integer] Return only payables whose amount (in minor units) is greater than or equal to +# the specified value. + # @param amount_lte [Integer] Return only payables whose amount (in minor units) is less than or equal to the +# specified value. + # @param currency [Monite::CurrencyEnum] Return only payables that use the specified currency. + # @param counterpart_name [String] Return only payables received from counterparts with the specified name (exact +# match, case-sensitive). +# For counterparts of `type = individual`, the full name is formatted as +# `first_name last_name`. + # @param counterpart_name_contains [String] Return only payables received from counterparts whose name contains the +# specified string (case-sensitive). + # @param counterpart_name_icontains [String] Return only payables received from counterparts whose name contains the +# specified string (case-insensitive). + # @param search_text [String] Apply the `icontains` condition to search for the specified text in the +# `document_id` and `counterpart_name` fields in the payables. + # @param due_date [String] Return payables that are due on the specified date (YYYY-MM-DD) + # @param due_date_gt [String] Return payables that are due after the specified date (exclusive, YYYY-MM-DD). + # @param due_date_lt [String] Return payables that are due before the specified date (exclusive, YYYY-MM-DD). + # @param due_date_gte [String] Return payables that are due on or after the specified date (YYYY-MM-DD). + # @param due_date_lte [String] Return payables that are due before or on the specified date (YYYY-MM-DD). + # @param document_id [String] Return a payable with the exact specified document number (case-sensitive). +# The `document_id` is the user-facing document number such as INV-00042, not to +# be confused with Monite resource IDs (`id`). + # @param document_id_contains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-sensitive). + # @param document_id_icontains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-insensitive). + # @param was_created_by_user_id [String] Return only payables created in Monite by the entity user with the specified ID. + # @param counterpart_id [String] Return only payables received from the counterpart with the specified ID. +# Counterparts that have been deleted but have associated payables will still +# return results here because the payables contain a frozen copy of the +# counterpart data. +# If the specified counterpart ID does not exist and never existed, no results are +# returned. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Return only payables coming from the specified source. + # @param ocr_status [Monite::OcrStatusEnum] Return only payables with specific OCR statuses. + # @param line_item_id [String] Search for a payable by the identifier of the line item associated with it. + # @param purchase_order_id [String] Search for a payable by the identifier of the purchase order associated with it. + # @param project_id [String] Return only payables assigned to the project with the specified ID. +# Valid but nonexistent project IDs do not raise errors but return no results. + # @param tag_ids [String] Return only payables whose `tags` include at least one of the tags with the +# specified IDs. Valid but nonexistent tag IDs do not raise errors but produce no +# results. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayablePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, status: nil, status_in: nil, id_in: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, amount: nil, amount_gt: nil, amount_lt: nil, amount_gte: nil, amount_lte: nil, currency: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, search_text: nil, due_date: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, was_created_by_user_id: nil, counterpart_id: nil, source_of_payable_data: nil, ocr_status: nil, line_item_id: nil, purchase_order_id: nil, project_id: nil, tag_ids: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "status": status, "status__in": status_in, "id__in": id_in, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "amount": amount, "amount__gt": amount_gt, "amount__lt": amount_lt, "amount__gte": amount_gte, "amount__lte": amount_lte, "currency": currency, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "search_text": search_text, "due_date": due_date, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "was_created_by_user_id": was_created_by_user_id, "counterpart_id": counterpart_id, "source_of_payable_data": source_of_payable_data, "ocr_status": ocr_status, "line_item_id": line_item_id, "purchase_order_id": purchase_order_id, "project_id": project_id, "tag_ids": tag_ids }.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)}/payables" +end + Monite::PayablePaginationResponse.from_json(json_object: response.body) + end +# Add a new payable by providing the amount, currency, vendor name, and other +# details. +# You can provide the base64_encoded contents of the original invoice file in the +# field `base64_encoded_file`. +# You can use this endpoint to bypass the Monite OCR service and provide the data +# directly +# (for example, if you already have the data in place). +# A newly created payable has the the `draft` +# [status](https://docs.monite.com/accounts-payable/payables/index). + # + # @param base_64_encoded_file [String] Base64-encoded contents of the original issued payable. The file is provided for +# reference purposes as the original source of the data. +# Any file formats are allowed. The most common formats are PDF, PNG, JPEG, TIFF. + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service + # @param counterpart_bank_account_id [String] The ID of counterpart bank account object stored in counterparts service + # @param counterpart_id [String] The ID of the counterpart object that represents the vendor or supplier. + # @param counterpart_vat_id_id [String] The ID of counterpart VAT ID object stored in counterparts service + # @param currency [Monite::CurrencyEnum] The [currency code](https://docs.monite.com/references/currencies) of the +# currency used in the payable. + # @param description [String] An arbitrary description of this payable. + # @param discount [Integer] The value of the additional discount that will be applied to the total amount. +# in [minor units](https://docs.monite.com/references/currencies#minor-units). For +# example, $12.50 is represented as 1250. + # @param document_id [String] A unique invoice number assigned by the invoice issuer for payment tracking +# purposes. + # @param due_date [String] The date by which the payable must be paid, in the YYYY-MM-DD format. If the +# payable specifies payment terms with early payment discounts, this is the final +# payment date. + # @param file_name [String] The original file name. + # @param issued_at [String] The date when the payable was issued, in the YYYY-MM-DD format. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_terms [Hash] The number of days to pay with potential discount for options shorter than +# due_dateRequest of type Monite::PayablePaymentTermsCreatePayload, as a Hash + # * :description (String) + # * :name (String) + # * :term_1 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_2 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_final (Hash) + # * :number_of_days (Integer) + # @param project_id [String] The ID of a project + # @param purchase_order_id [String] The identifier of the purchase order to which this payable belongs. + # @param sender [String] The email address from which the invoice was sent to the entity. + # @param subtotal [Integer] The subtotal amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param suggested_payment_term [Hash] The suggested date and corresponding discount in which payable could be paid. +# The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) +# - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on +# the payment terms and may even be equal to the due date with discount 0.Request of type Monite::SuggestedPaymentTerm, as a Hash + # * :date (String) + # * :discount (Integer) + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this payable. Tags can +# be used to trigger a specific approval policy for this payable. + # @param tax [Integer] Registered tax percentage applied for a service price in minor units, e.g. 200 +# means 2%. 1050 means 10.5%. + # @param tax_amount [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total_amount [Integer] The total amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.create + def create(base_64_encoded_file: nil, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, discount: nil, document_id: nil, due_date: nil, file_name: nil, issued_at: nil, partner_metadata: nil, payment_terms: nil, project_id: nil, purchase_order_id: nil, sender: nil, subtotal: nil, suggested_payment_term: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), base64_encoded_file: base_64_encoded_file, counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, discount: discount, document_id: document_id, due_date: due_date, file_name: file_name, issued_at: issued_at, partner_metadata: partner_metadata, payment_terms: payment_terms, project_id: project_id, purchase_order_id: purchase_order_id, sender: sender, subtotal: subtotal, suggested_payment_term: suggested_payment_term, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Retrieve aggregated statistics for payables, including total amount and count, +# both overall and by status. +# For more flexible configuration and retrieval of other data types, use `GET +# /analytics/payables`. + # + # @param created_at_gt [DateTime] Return only payables created in Monite after the specified date and time. The +# value must be in the ISO 8601 format YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]. + # @param created_at_lt [DateTime] Return only payables created in Monite before the specified date and time. + # @param created_at_gte [DateTime] Return only payables created in Monite on or after the specified date and time. + # @param created_at_lte [DateTime] Return only payables created in Monite before or on the specified date and time. + # @param status [Monite::PayableStateEnum] Return only payables that have the specified +# [status](https://docs.monite.com/accounts-payable/payables/index). +# To query multiple statuses at once, use the `status__in` parameter instead. + # @param status_in [Monite::PayableStateEnum] Return only payables that have the specified +# [statuses](https://docs.monite.com/accounts-payable/payables/index). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=new` + # @param id_in [String] Return only payables with specified IDs. Valid but nonexistent IDs do not raise +# errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param total_amount [Integer] Return only payables with the exact specified total amount. The amount must be +# specified in the minor units of currency. For example, $12.5 is represented as +# 1250. + # @param total_amount_gt [Integer] Return only payables whose total amount (in minor units) exceeds the specified +# value. + # @param total_amount_lt [Integer] Return only payables whose total amount (in minor units) is less than the +# specified value. + # @param total_amount_gte [Integer] Return only payables whose total amount (in minor units) is greater than or +# equal to the specified value. + # @param total_amount_lte [Integer] Return only payables whose total amount (in minor units) is less than or equal +# to the specified value. + # @param amount [Integer] Return only payables with the specified amount. + # @param amount_gt [Integer] Return only payables whose amount (in minor units) exceeds the specified value. + # @param amount_lt [Integer] Return only payables whose amount (in minor units) is less than the specified +# value. + # @param amount_gte [Integer] Return only payables whose amount (in minor units) is greater than or equal to +# the specified value. + # @param amount_lte [Integer] Return only payables whose amount (in minor units) is less than or equal to the +# specified value. + # @param currency [Monite::CurrencyEnum] Return only payables that use the specified currency. + # @param counterpart_name [String] Return only payables received from counterparts with the specified name (exact +# match, case-sensitive). +# For counterparts of `type = individual`, the full name is formatted as +# `first_name last_name`. + # @param counterpart_name_contains [String] Return only payables received from counterparts whose name contains the +# specified string (case-sensitive). + # @param counterpart_name_icontains [String] Return only payables received from counterparts whose name contains the +# specified string (case-insensitive). + # @param search_text [String] Apply the `icontains` condition to search for the specified text in the +# `document_id` and `counterpart_name` fields in the payables. + # @param due_date [String] Return payables that are due on the specified date (YYYY-MM-DD) + # @param due_date_gt [String] Return payables that are due after the specified date (exclusive, YYYY-MM-DD). + # @param due_date_lt [String] Return payables that are due before the specified date (exclusive, YYYY-MM-DD). + # @param due_date_gte [String] Return payables that are due on or after the specified date (YYYY-MM-DD). + # @param due_date_lte [String] Return payables that are due before or on the specified date (YYYY-MM-DD). + # @param document_id [String] Return a payable with the exact specified document number (case-sensitive). +# The `document_id` is the user-facing document number such as INV-00042, not to +# be confused with Monite resource IDs (`id`). + # @param document_id_contains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-sensitive). + # @param document_id_icontains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-insensitive). + # @param was_created_by_user_id [String] Return only payables created in Monite by the entity user with the specified ID. + # @param counterpart_id [String] Return only payables received from the counterpart with the specified ID. +# Counterparts that have been deleted but have associated payables will still +# return results here because the payables contain a frozen copy of the +# counterpart data. +# If the specified counterpart ID does not exist and never existed, no results are +# returned. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Return only payables coming from the specified source. + # @param ocr_status [Monite::OcrStatusEnum] Return only payables with specific OCR statuses. + # @param line_item_id [String] Search for a payable by the identifier of the line item associated with it. + # @param purchase_order_id [String] Search for a payable by the identifier of the purchase order associated with it. + # @param project_id [String] Return only payables assigned to the project with the specified ID. +# Valid but nonexistent project IDs do not raise errors but return no results. + # @param tag_ids [String] Return only payables whose `tags` include at least one of the tags with the +# specified IDs. Valid but nonexistent tag IDs do not raise errors but produce no +# results. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableAggregatedDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_analytics + def get_analytics(created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, status: nil, status_in: nil, id_in: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, amount: nil, amount_gt: nil, amount_lt: nil, amount_gte: nil, amount_lte: nil, currency: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, search_text: nil, due_date: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, was_created_by_user_id: nil, counterpart_id: nil, source_of_payable_data: nil, ocr_status: nil, line_item_id: nil, purchase_order_id: nil, project_id: nil, tag_ids: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "status": status, "status__in": status_in, "id__in": id_in, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "amount": amount, "amount__gt": amount_gt, "amount__lt": amount_lt, "amount__gte": amount_gte, "amount__lte": amount_lte, "currency": currency, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "search_text": search_text, "due_date": due_date, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "was_created_by_user_id": was_created_by_user_id, "counterpart_id": counterpart_id, "source_of_payable_data": source_of_payable_data, "ocr_status": ocr_status, "line_item_id": line_item_id, "purchase_order_id": purchase_order_id, "project_id": project_id, "tag_ids": tag_ids }.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)}/payables/analytics" +end + Monite::PayableAggregatedDataResponse.from_json(json_object: response.body) + end +# Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan +# its contents. The maximum file size is 10MB. + # + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.upload_from_file(file: my_file.txt) + def upload_from_file(file:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/upload_from_file" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Get payable validations. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationsResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_validations + def get_validations(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/validations" +end + Monite::PayableValidationsResource.from_json(json_object: response.body) + end +# Update payable validations. + # + # @param required_fields [Array] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationsResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.update_validations(required_fields: [CURRENCY]) + def update_validations(required_fields:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), required_fields: required_fields }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/validations" +end + Monite::PayableValidationsResource.from_json(json_object: response.body) + end +# Reset payable validations to default ones. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationsResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.reset_validations + def reset_validations(request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/validations/reset" +end + Monite::PayableValidationsResource.from_json(json_object: response.body) + end +# Get a list of placeholders allowed to insert into an email template for +# customization + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableTemplatesVariablesObjectList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_variables + def get_variables(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/variables" +end + Monite::PayableTemplatesVariablesObjectList.from_json(json_object: response.body) + end +# Retrieves information about a specific payable with the given ID. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_by_id(payable_id: "payable_id") + def get_by_id(payable_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Deletes a specific payable. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.delete_by_id(payable_id: "payable_id") + def delete_by_id(payable_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}" +end + end +# Updates the information about a specific payable. + # + # @param payable_id [String] + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service + # @param counterpart_bank_account_id [String] The ID of counterpart bank account object stored in counterparts service + # @param counterpart_id [String] The ID of the counterpart object that represents the vendor or supplier. + # @param counterpart_raw_data [Hash] Allows to fix some data in counterpart recognised fields to correct them in +# order to make autolinking happen.Request of type Monite::CounterpartRawDataUpdateRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :bank_account (Hash) + # * :account_holder_name (String) + # * :account_number (String) + # * :bic (String) + # * :iban (String) + # * :sort_code (String) + # * :email (String) + # * :name (String) + # * :phone (String) + # * :tax_id (String) + # * :vat_id (Hash) + # * :country (Monite::AllowedCountries) + # * :type (String) + # * :value (String) + # @param counterpart_vat_id_id [String] The ID of counterpart VAT ID object stored in counterparts service + # @param currency [Monite::CurrencyEnum] The [currency code](https://docs.monite.com/references/currencies) of the +# currency used in the payable. + # @param description [String] An arbitrary description of this payable. + # @param discount [Integer] The value of the additional discount that will be applied to the total amount. +# in [minor units](https://docs.monite.com/references/currencies#minor-units). For +# example, $12.50 is represented as 1250. + # @param document_id [String] A unique invoice number assigned by the invoice issuer for payment tracking +# purposes. + # @param due_date [String] The date by which the payable must be paid, in the YYYY-MM-DD format. If the +# payable specifies payment terms with early payment discounts, this is the final +# payment date. + # @param issued_at [String] The date when the payable was issued, in the YYYY-MM-DD format. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_terms [Hash] The number of days to pay with potential discount for options shorter than +# due_dateRequest of type Monite::PayablePaymentTermsCreatePayload, as a Hash + # * :description (String) + # * :name (String) + # * :term_1 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_2 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_final (Hash) + # * :number_of_days (Integer) + # @param project_id [String] The project ID of the payable. + # @param purchase_order_id [String] The identifier of the purchase order to which this payable belongs. + # @param sender [String] The email address from which the invoice was sent to the entity. + # @param subtotal [Integer] The subtotal amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param suggested_payment_term [Hash] The suggested date and corresponding discount in which payable could be paid. +# The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) +# - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on +# the payment terms and may even be equal to the due date with discount 0.Request of type Monite::SuggestedPaymentTerm, as a Hash + # * :date (String) + # * :discount (Integer) + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this payable. Tags can +# be used to trigger a specific approval policy for this payable. + # @param tax [Integer] Registered tax percentage applied for a service price in minor units, e.g. 200 +# means 2%, 1050 means 10.5%. + # @param tax_amount [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total_amount [Integer] The total amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.update_by_id(payable_id: "payable_id") + def update_by_id(payable_id:, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_raw_data: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, discount: nil, document_id: nil, due_date: nil, issued_at: nil, partner_metadata: nil, payment_terms: nil, project_id: nil, purchase_order_id: nil, sender: nil, subtotal: nil, suggested_payment_term: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_raw_data: counterpart_raw_data, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, discount: discount, document_id: document_id, due_date: due_date, issued_at: issued_at, partner_metadata: partner_metadata, payment_terms: payment_terms, project_id: project_id, purchase_order_id: purchase_order_id, sender: sender, subtotal: subtotal, suggested_payment_term: suggested_payment_term, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Confirms that the payable is ready to be paid. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.approve_payment_by_id(payable_id: "payable_id") + def approve_payment_by_id(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/approve_payment_operation" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Attach file to payable without existing attachment. + # + # @param payable_id [String] + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.attach_file_by_id(payable_id: "payable_id", file: my_file.txt) + def attach_file_by_id(payable_id:, file:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/attach_file" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Cancels the payable that was not confirmed during the review. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.cancel_by_id(payable_id: "payable_id") + def cancel_by_id(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/cancel" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Request to cancel the OCR processing of the specified payable. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.post_payables_id_cancel_ocr(payable_id: "payable_id") + def post_payables_id_cancel_ocr(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/cancel_ocr" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Mark a payable as paid. +# Payables can be paid using the payment channels offered by Monite or through +# external payment channels. In the latter +# case, the invoice is not automatically marked as paid in the system and needs +# to be converted to the paid status +# manually. +# Optionally, it is possible to pass the `comment` field in the request body, to +# describe how and when the invoice was +# paid. +# Notes: +# - To use this endpoint with an entity user token, this entity user must have a +# role that includes the `pay` permission +# for payables. +# - The `amount_to_pay` field is automatically calculated based on the +# `amount_due` less the percentage described +# in the `payment_terms.discount` value. +# Related guide: [Mark a payable as +# tps://docs.monite.com/accounts-payable/approvals/manual-transition#mark-as-paid) +# See also: +# [Payables lifecycle](https://docs.monite.com/accounts-payable/payables/index) +# [Payables status +# ttps://docs.monite.com/accounts-payable/payables/collect#suggested-payment-date) + # + # @param payable_id [String] + # @param comment [String] An arbitrary comment that describes how and when this payable was paid. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.mark_as_paid_by_id(payable_id: "payable_id") + def mark_as_paid_by_id(payable_id:, comment: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/mark_as_paid" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Mark a payable as partially paid. +# If the payable is partially paid, its status is moved to `partially_paid`. The +# value of the `amount_paid` field must be +# the sum of all payments made, not only the last one. +# Notes: +# - This endpoint can be used for payables in the `waiting_to_be_paid` status. +# - The `amount_paid` must be greater than 0 and less than the total payable +# amount specified by the `amount` field. +# - You can use this endpoint multiple times for the same payable to reflect +# multiple partial payments, always setting the +# sum of all payments made. +# - To use this endpoint with an entity user token, this entity user must have a +# role that includes the `pay` +# permission for payables. +# - The `amount_to_pay` field is automatically calculated based on the +# `amount_due` less the percentage described +# in the `payment_terms.discount` value. +# Related guide: [Mark a payable as partially +# .monite.com/accounts-payable/approvals/manual-transition#mark-as-partially-paid) +# See also: +# [Payables lifecycle](https://docs.monite.com/accounts-payable/payables/index) +# [Payables status +# ttps://docs.monite.com/accounts-payable/payables/collect#suggested-payment-date) +# [Mark a payable as +# tps://docs.monite.com/accounts-payable/approvals/manual-transition#mark-as-paid) + # + # @param payable_id [String] + # @param amount_paid [Integer] How much was paid on the invoice (in minor units). + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.mark_as_partially_paid_by_id(payable_id: "payable_id", amount_paid: 1) + def mark_as_partially_paid_by_id(payable_id:, amount_paid:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount_paid: amount_paid }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/mark_as_partially_paid" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Declines the payable when an approver finds any mismatch or discrepancies. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.reject_by_id(payable_id: "payable_id") + def reject_by_id(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/reject" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Reset payable state from rejected to new. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.reopen_by_id(payable_id: "payable_id") + def reopen_by_id(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/reopen" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Starts the approval process once the uploaded payable is validated. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.submit_for_approval_by_id(payable_id: "payable_id") + def submit_for_approval_by_id(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/submit_for_approval" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end +# Check the invoice for compliance with the requirements for movement from draft +# to new status. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.validate_by_id(payable_id: "payable_id") + def validate_by_id(payable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/validate" +end + Monite::PayableValidationResponse.from_json(json_object: response.body) + end + end + class AsyncPayablesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + # @return [Monite::Payables::LineItemsClient] + attr_reader :line_items + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPayablesClient] + def initialize(request_client:) + @request_client = request_client + @line_items = Monite::Payables::AsyncLineItemsClient.new(request_client: request_client) + end +# Lists all payables from the connected entity. +# If you already have the data of the payable (amount in [minor units]( +# https://docs.monite.com/references/currencies#minor-units), currency, vendor +# information, and other details) +# stored somewhere as individual attributes, you can create a payable with these +# attributes by calling [POST +# /payables](https://docs.monite.com/api/payables/post-payables) and providing the +# [base64-encoded]( +# https://en.wikipedia.org/wiki/Base64) contents of the original invoice file in +# the field `base64_encoded_file`. +# A payable is a financial document given by an entity`s supplier itemizing the +# purchase of a good or a service and +# demanding payment. +# The `file_name` field is optional. If omitted, it defaults to +# “default_file_name”. If the settings are configured +# to automatically set `suggested_payment_term`, this object can be omitted from +# the request body. +# The `id` generated for this payable can be used in other API calls to update the +# data of this payable or trigger [ +# status +# nsitions](https://docs.monite.com/accounts-payable/approvals/manual-transition), +# for example. essential data +# fields to move from `draft` to `new` +# Related guide: [Create a payable from +# ://docs.monite.com/accounts-payable/payables/collect#create-a-payable-from-data) +# See also: +# [Automatic calculation of due +# .monite.com/accounts-payable/payables/collect#automatic-calculation-of-due-date) +# [Suggested payment +# ttps://docs.monite.com/accounts-payable/payables/collect#suggested-payment-date) +# [Attach +# file](https://docs.monite.com/accounts-payable/payables/collect#attach-file) +# [Collect payables by +# ttps://docs.monite.com/accounts-payable/payables/collect#send-payables-by-email) +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::PayableCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] Return only payables created in Monite after the specified date and time. The +# value must be in the ISO 8601 format YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]. + # @param created_at_lt [DateTime] Return only payables created in Monite before the specified date and time. + # @param created_at_gte [DateTime] Return only payables created in Monite on or after the specified date and time. + # @param created_at_lte [DateTime] Return only payables created in Monite before or on the specified date and time. + # @param status [Monite::PayableStateEnum] Return only payables that have the specified +# [status](https://docs.monite.com/accounts-payable/payables/index). +# To query multiple statuses at once, use the `status__in` parameter instead. + # @param status_in [Monite::PayableStateEnum] Return only payables that have the specified +# [statuses](https://docs.monite.com/accounts-payable/payables/index). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=new` + # @param id_in [String] Return only payables with specified IDs. Valid but nonexistent IDs do not raise +# errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param total_amount [Integer] Return only payables with the exact specified total amount. The amount must be +# specified in the minor units of currency. For example, $12.5 is represented as +# 1250. + # @param total_amount_gt [Integer] Return only payables whose total amount (in minor units) exceeds the specified +# value. + # @param total_amount_lt [Integer] Return only payables whose total amount (in minor units) is less than the +# specified value. + # @param total_amount_gte [Integer] Return only payables whose total amount (in minor units) is greater than or +# equal to the specified value. + # @param total_amount_lte [Integer] Return only payables whose total amount (in minor units) is less than or equal +# to the specified value. + # @param amount [Integer] Return only payables with the specified amount. + # @param amount_gt [Integer] Return only payables whose amount (in minor units) exceeds the specified value. + # @param amount_lt [Integer] Return only payables whose amount (in minor units) is less than the specified +# value. + # @param amount_gte [Integer] Return only payables whose amount (in minor units) is greater than or equal to +# the specified value. + # @param amount_lte [Integer] Return only payables whose amount (in minor units) is less than or equal to the +# specified value. + # @param currency [Monite::CurrencyEnum] Return only payables that use the specified currency. + # @param counterpart_name [String] Return only payables received from counterparts with the specified name (exact +# match, case-sensitive). +# For counterparts of `type = individual`, the full name is formatted as +# `first_name last_name`. + # @param counterpart_name_contains [String] Return only payables received from counterparts whose name contains the +# specified string (case-sensitive). + # @param counterpart_name_icontains [String] Return only payables received from counterparts whose name contains the +# specified string (case-insensitive). + # @param search_text [String] Apply the `icontains` condition to search for the specified text in the +# `document_id` and `counterpart_name` fields in the payables. + # @param due_date [String] Return payables that are due on the specified date (YYYY-MM-DD) + # @param due_date_gt [String] Return payables that are due after the specified date (exclusive, YYYY-MM-DD). + # @param due_date_lt [String] Return payables that are due before the specified date (exclusive, YYYY-MM-DD). + # @param due_date_gte [String] Return payables that are due on or after the specified date (YYYY-MM-DD). + # @param due_date_lte [String] Return payables that are due before or on the specified date (YYYY-MM-DD). + # @param document_id [String] Return a payable with the exact specified document number (case-sensitive). +# The `document_id` is the user-facing document number such as INV-00042, not to +# be confused with Monite resource IDs (`id`). + # @param document_id_contains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-sensitive). + # @param document_id_icontains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-insensitive). + # @param was_created_by_user_id [String] Return only payables created in Monite by the entity user with the specified ID. + # @param counterpart_id [String] Return only payables received from the counterpart with the specified ID. +# Counterparts that have been deleted but have associated payables will still +# return results here because the payables contain a frozen copy of the +# counterpart data. +# If the specified counterpart ID does not exist and never existed, no results are +# returned. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Return only payables coming from the specified source. + # @param ocr_status [Monite::OcrStatusEnum] Return only payables with specific OCR statuses. + # @param line_item_id [String] Search for a payable by the identifier of the line item associated with it. + # @param purchase_order_id [String] Search for a payable by the identifier of the purchase order associated with it. + # @param project_id [String] Return only payables assigned to the project with the specified ID. +# Valid but nonexistent project IDs do not raise errors but return no results. + # @param tag_ids [String] Return only payables whose `tags` include at least one of the tags with the +# specified IDs. Valid but nonexistent tag IDs do not raise errors but produce no +# results. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayablePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, status: nil, status_in: nil, id_in: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, amount: nil, amount_gt: nil, amount_lt: nil, amount_gte: nil, amount_lte: nil, currency: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, search_text: nil, due_date: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, was_created_by_user_id: nil, counterpart_id: nil, source_of_payable_data: nil, ocr_status: nil, line_item_id: nil, purchase_order_id: nil, project_id: nil, tag_ids: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "status": status, "status__in": status_in, "id__in": id_in, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "amount": amount, "amount__gt": amount_gt, "amount__lt": amount_lt, "amount__gte": amount_gte, "amount__lte": amount_lte, "currency": currency, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "search_text": search_text, "due_date": due_date, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "was_created_by_user_id": was_created_by_user_id, "counterpart_id": counterpart_id, "source_of_payable_data": source_of_payable_data, "ocr_status": ocr_status, "line_item_id": line_item_id, "purchase_order_id": purchase_order_id, "project_id": project_id, "tag_ids": tag_ids }.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)}/payables" +end + Monite::PayablePaginationResponse.from_json(json_object: response.body) + end + end +# Add a new payable by providing the amount, currency, vendor name, and other +# details. +# You can provide the base64_encoded contents of the original invoice file in the +# field `base64_encoded_file`. +# You can use this endpoint to bypass the Monite OCR service and provide the data +# directly +# (for example, if you already have the data in place). +# A newly created payable has the the `draft` +# [status](https://docs.monite.com/accounts-payable/payables/index). + # + # @param base_64_encoded_file [String] Base64-encoded contents of the original issued payable. The file is provided for +# reference purposes as the original source of the data. +# Any file formats are allowed. The most common formats are PDF, PNG, JPEG, TIFF. + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service + # @param counterpart_bank_account_id [String] The ID of counterpart bank account object stored in counterparts service + # @param counterpart_id [String] The ID of the counterpart object that represents the vendor or supplier. + # @param counterpart_vat_id_id [String] The ID of counterpart VAT ID object stored in counterparts service + # @param currency [Monite::CurrencyEnum] The [currency code](https://docs.monite.com/references/currencies) of the +# currency used in the payable. + # @param description [String] An arbitrary description of this payable. + # @param discount [Integer] The value of the additional discount that will be applied to the total amount. +# in [minor units](https://docs.monite.com/references/currencies#minor-units). For +# example, $12.50 is represented as 1250. + # @param document_id [String] A unique invoice number assigned by the invoice issuer for payment tracking +# purposes. + # @param due_date [String] The date by which the payable must be paid, in the YYYY-MM-DD format. If the +# payable specifies payment terms with early payment discounts, this is the final +# payment date. + # @param file_name [String] The original file name. + # @param issued_at [String] The date when the payable was issued, in the YYYY-MM-DD format. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_terms [Hash] The number of days to pay with potential discount for options shorter than +# due_dateRequest of type Monite::PayablePaymentTermsCreatePayload, as a Hash + # * :description (String) + # * :name (String) + # * :term_1 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_2 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_final (Hash) + # * :number_of_days (Integer) + # @param project_id [String] The ID of a project + # @param purchase_order_id [String] The identifier of the purchase order to which this payable belongs. + # @param sender [String] The email address from which the invoice was sent to the entity. + # @param subtotal [Integer] The subtotal amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param suggested_payment_term [Hash] The suggested date and corresponding discount in which payable could be paid. +# The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) +# - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on +# the payment terms and may even be equal to the due date with discount 0.Request of type Monite::SuggestedPaymentTerm, as a Hash + # * :date (String) + # * :discount (Integer) + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this payable. Tags can +# be used to trigger a specific approval policy for this payable. + # @param tax [Integer] Registered tax percentage applied for a service price in minor units, e.g. 200 +# means 2%. 1050 means 10.5%. + # @param tax_amount [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total_amount [Integer] The total amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.create + def create(base_64_encoded_file: nil, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, discount: nil, document_id: nil, due_date: nil, file_name: nil, issued_at: nil, partner_metadata: nil, payment_terms: nil, project_id: nil, purchase_order_id: nil, sender: nil, subtotal: nil, suggested_payment_term: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), base64_encoded_file: base_64_encoded_file, counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, discount: discount, document_id: document_id, due_date: due_date, file_name: file_name, issued_at: issued_at, partner_metadata: partner_metadata, payment_terms: payment_terms, project_id: project_id, purchase_order_id: purchase_order_id, sender: sender, subtotal: subtotal, suggested_payment_term: suggested_payment_term, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Retrieve aggregated statistics for payables, including total amount and count, +# both overall and by status. +# For more flexible configuration and retrieval of other data types, use `GET +# /analytics/payables`. + # + # @param created_at_gt [DateTime] Return only payables created in Monite after the specified date and time. The +# value must be in the ISO 8601 format YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]. + # @param created_at_lt [DateTime] Return only payables created in Monite before the specified date and time. + # @param created_at_gte [DateTime] Return only payables created in Monite on or after the specified date and time. + # @param created_at_lte [DateTime] Return only payables created in Monite before or on the specified date and time. + # @param status [Monite::PayableStateEnum] Return only payables that have the specified +# [status](https://docs.monite.com/accounts-payable/payables/index). +# To query multiple statuses at once, use the `status__in` parameter instead. + # @param status_in [Monite::PayableStateEnum] Return only payables that have the specified +# [statuses](https://docs.monite.com/accounts-payable/payables/index). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=new` + # @param id_in [String] Return only payables with specified IDs. Valid but nonexistent IDs do not raise +# errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param total_amount [Integer] Return only payables with the exact specified total amount. The amount must be +# specified in the minor units of currency. For example, $12.5 is represented as +# 1250. + # @param total_amount_gt [Integer] Return only payables whose total amount (in minor units) exceeds the specified +# value. + # @param total_amount_lt [Integer] Return only payables whose total amount (in minor units) is less than the +# specified value. + # @param total_amount_gte [Integer] Return only payables whose total amount (in minor units) is greater than or +# equal to the specified value. + # @param total_amount_lte [Integer] Return only payables whose total amount (in minor units) is less than or equal +# to the specified value. + # @param amount [Integer] Return only payables with the specified amount. + # @param amount_gt [Integer] Return only payables whose amount (in minor units) exceeds the specified value. + # @param amount_lt [Integer] Return only payables whose amount (in minor units) is less than the specified +# value. + # @param amount_gte [Integer] Return only payables whose amount (in minor units) is greater than or equal to +# the specified value. + # @param amount_lte [Integer] Return only payables whose amount (in minor units) is less than or equal to the +# specified value. + # @param currency [Monite::CurrencyEnum] Return only payables that use the specified currency. + # @param counterpart_name [String] Return only payables received from counterparts with the specified name (exact +# match, case-sensitive). +# For counterparts of `type = individual`, the full name is formatted as +# `first_name last_name`. + # @param counterpart_name_contains [String] Return only payables received from counterparts whose name contains the +# specified string (case-sensitive). + # @param counterpart_name_icontains [String] Return only payables received from counterparts whose name contains the +# specified string (case-insensitive). + # @param search_text [String] Apply the `icontains` condition to search for the specified text in the +# `document_id` and `counterpart_name` fields in the payables. + # @param due_date [String] Return payables that are due on the specified date (YYYY-MM-DD) + # @param due_date_gt [String] Return payables that are due after the specified date (exclusive, YYYY-MM-DD). + # @param due_date_lt [String] Return payables that are due before the specified date (exclusive, YYYY-MM-DD). + # @param due_date_gte [String] Return payables that are due on or after the specified date (YYYY-MM-DD). + # @param due_date_lte [String] Return payables that are due before or on the specified date (YYYY-MM-DD). + # @param document_id [String] Return a payable with the exact specified document number (case-sensitive). +# The `document_id` is the user-facing document number such as INV-00042, not to +# be confused with Monite resource IDs (`id`). + # @param document_id_contains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-sensitive). + # @param document_id_icontains [String] Return only payables whose document number (`document_id`) contains the +# specified string (case-insensitive). + # @param was_created_by_user_id [String] Return only payables created in Monite by the entity user with the specified ID. + # @param counterpart_id [String] Return only payables received from the counterpart with the specified ID. +# Counterparts that have been deleted but have associated payables will still +# return results here because the payables contain a frozen copy of the +# counterpart data. +# If the specified counterpart ID does not exist and never existed, no results are +# returned. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Return only payables coming from the specified source. + # @param ocr_status [Monite::OcrStatusEnum] Return only payables with specific OCR statuses. + # @param line_item_id [String] Search for a payable by the identifier of the line item associated with it. + # @param purchase_order_id [String] Search for a payable by the identifier of the purchase order associated with it. + # @param project_id [String] Return only payables assigned to the project with the specified ID. +# Valid but nonexistent project IDs do not raise errors but return no results. + # @param tag_ids [String] Return only payables whose `tags` include at least one of the tags with the +# specified IDs. Valid but nonexistent tag IDs do not raise errors but produce no +# results. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableAggregatedDataResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_analytics + def get_analytics(created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, status: nil, status_in: nil, id_in: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, amount: nil, amount_gt: nil, amount_lt: nil, amount_gte: nil, amount_lte: nil, currency: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, search_text: nil, due_date: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, was_created_by_user_id: nil, counterpart_id: nil, source_of_payable_data: nil, ocr_status: nil, line_item_id: nil, purchase_order_id: nil, project_id: nil, tag_ids: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "status": status, "status__in": status_in, "id__in": id_in, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "amount": amount, "amount__gt": amount_gt, "amount__lt": amount_lt, "amount__gte": amount_gte, "amount__lte": amount_lte, "currency": currency, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "search_text": search_text, "due_date": due_date, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "was_created_by_user_id": was_created_by_user_id, "counterpart_id": counterpart_id, "source_of_payable_data": source_of_payable_data, "ocr_status": ocr_status, "line_item_id": line_item_id, "purchase_order_id": purchase_order_id, "project_id": project_id, "tag_ids": tag_ids }.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)}/payables/analytics" +end + Monite::PayableAggregatedDataResponse.from_json(json_object: response.body) + end + end +# Upload an incoming invoice (payable) in PDF, PNG, JPEG, or TIFF format and scan +# its contents. The maximum file size is 10MB. + # + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.upload_from_file(file: my_file.txt) + def upload_from_file(file:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/upload_from_file" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Get payable validations. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationsResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_validations + def get_validations(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/validations" +end + Monite::PayableValidationsResource.from_json(json_object: response.body) + end + end +# Update payable validations. + # + # @param required_fields [Array] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationsResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.update_validations(required_fields: [CURRENCY]) + def update_validations(required_fields:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), required_fields: required_fields }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/validations" +end + Monite::PayableValidationsResource.from_json(json_object: response.body) + end + end +# Reset payable validations to default ones. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationsResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.reset_validations + def reset_validations(request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/validations/reset" +end + Monite::PayableValidationsResource.from_json(json_object: response.body) + end + end +# Get a list of placeholders allowed to insert into an email template for +# customization + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableTemplatesVariablesObjectList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_variables + def get_variables(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/variables" +end + Monite::PayableTemplatesVariablesObjectList.from_json(json_object: response.body) + end + end +# Retrieves information about a specific payable with the given ID. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.get_by_id(payable_id: "payable_id") + def get_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Deletes a specific payable. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.delete_by_id(payable_id: "payable_id") + def delete_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}" +end + end + end +# Updates the information about a specific payable. + # + # @param payable_id [String] + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service + # @param counterpart_bank_account_id [String] The ID of counterpart bank account object stored in counterparts service + # @param counterpart_id [String] The ID of the counterpart object that represents the vendor or supplier. + # @param counterpart_raw_data [Hash] Allows to fix some data in counterpart recognised fields to correct them in +# order to make autolinking happen.Request of type Monite::CounterpartRawDataUpdateRequest, as a Hash + # * :address (Hash) + # * :city (String) + # * :country (Monite::AllowedCountries) + # * :line_1 (String) + # * :line_2 (String) + # * :postal_code (String) + # * :state (String) + # * :bank_account (Hash) + # * :account_holder_name (String) + # * :account_number (String) + # * :bic (String) + # * :iban (String) + # * :sort_code (String) + # * :email (String) + # * :name (String) + # * :phone (String) + # * :tax_id (String) + # * :vat_id (Hash) + # * :country (Monite::AllowedCountries) + # * :type (String) + # * :value (String) + # @param counterpart_vat_id_id [String] The ID of counterpart VAT ID object stored in counterparts service + # @param currency [Monite::CurrencyEnum] The [currency code](https://docs.monite.com/references/currencies) of the +# currency used in the payable. + # @param description [String] An arbitrary description of this payable. + # @param discount [Integer] The value of the additional discount that will be applied to the total amount. +# in [minor units](https://docs.monite.com/references/currencies#minor-units). For +# example, $12.50 is represented as 1250. + # @param document_id [String] A unique invoice number assigned by the invoice issuer for payment tracking +# purposes. + # @param due_date [String] The date by which the payable must be paid, in the YYYY-MM-DD format. If the +# payable specifies payment terms with early payment discounts, this is the final +# payment date. + # @param issued_at [String] The date when the payable was issued, in the YYYY-MM-DD format. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_terms [Hash] The number of days to pay with potential discount for options shorter than +# due_dateRequest of type Monite::PayablePaymentTermsCreatePayload, as a Hash + # * :description (String) + # * :name (String) + # * :term_1 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_2 (Hash) + # * :discount (Integer) + # * :number_of_days (Integer) + # * :term_final (Hash) + # * :number_of_days (Integer) + # @param project_id [String] The project ID of the payable. + # @param purchase_order_id [String] The identifier of the purchase order to which this payable belongs. + # @param sender [String] The email address from which the invoice was sent to the entity. + # @param subtotal [Integer] The subtotal amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param suggested_payment_term [Hash] The suggested date and corresponding discount in which payable could be paid. +# The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) +# - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on +# the payment terms and may even be equal to the due date with discount 0.Request of type Monite::SuggestedPaymentTerm, as a Hash + # * :date (String) + # * :discount (Integer) + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this payable. Tags can +# be used to trigger a specific approval policy for this payable. + # @param tax [Integer] Registered tax percentage applied for a service price in minor units, e.g. 200 +# means 2%, 1050 means 10.5%. + # @param tax_amount [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total_amount [Integer] The total amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.update_by_id(payable_id: "payable_id") + def update_by_id(payable_id:, counterpart_address_id: nil, counterpart_bank_account_id: nil, counterpart_id: nil, counterpart_raw_data: nil, counterpart_vat_id_id: nil, currency: nil, description: nil, discount: nil, document_id: nil, due_date: nil, issued_at: nil, partner_metadata: nil, payment_terms: nil, project_id: nil, purchase_order_id: nil, sender: nil, subtotal: nil, suggested_payment_term: nil, tag_ids: nil, tax: nil, tax_amount: nil, total_amount: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), counterpart_address_id: counterpart_address_id, counterpart_bank_account_id: counterpart_bank_account_id, counterpart_id: counterpart_id, counterpart_raw_data: counterpart_raw_data, counterpart_vat_id_id: counterpart_vat_id_id, currency: currency, description: description, discount: discount, document_id: document_id, due_date: due_date, issued_at: issued_at, partner_metadata: partner_metadata, payment_terms: payment_terms, project_id: project_id, purchase_order_id: purchase_order_id, sender: sender, subtotal: subtotal, suggested_payment_term: suggested_payment_term, tag_ids: tag_ids, tax: tax, tax_amount: tax_amount, total_amount: total_amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Confirms that the payable is ready to be paid. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.approve_payment_by_id(payable_id: "payable_id") + def approve_payment_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/approve_payment_operation" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Attach file to payable without existing attachment. + # + # @param payable_id [String] + # @param file [String, IO] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.attach_file_by_id(payable_id: "payable_id", file: my_file.txt) + def attach_file_by_id(payable_id:, file:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), file: Monite::FileUtilities.as_faraday_multipart(file_like: file) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/attach_file" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Cancels the payable that was not confirmed during the review. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.cancel_by_id(payable_id: "payable_id") + def cancel_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/cancel" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Request to cancel the OCR processing of the specified payable. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.post_payables_id_cancel_ocr(payable_id: "payable_id") + def post_payables_id_cancel_ocr(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/cancel_ocr" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Mark a payable as paid. +# Payables can be paid using the payment channels offered by Monite or through +# external payment channels. In the latter +# case, the invoice is not automatically marked as paid in the system and needs +# to be converted to the paid status +# manually. +# Optionally, it is possible to pass the `comment` field in the request body, to +# describe how and when the invoice was +# paid. +# Notes: +# - To use this endpoint with an entity user token, this entity user must have a +# role that includes the `pay` permission +# for payables. +# - The `amount_to_pay` field is automatically calculated based on the +# `amount_due` less the percentage described +# in the `payment_terms.discount` value. +# Related guide: [Mark a payable as +# tps://docs.monite.com/accounts-payable/approvals/manual-transition#mark-as-paid) +# See also: +# [Payables lifecycle](https://docs.monite.com/accounts-payable/payables/index) +# [Payables status +# ttps://docs.monite.com/accounts-payable/payables/collect#suggested-payment-date) + # + # @param payable_id [String] + # @param comment [String] An arbitrary comment that describes how and when this payable was paid. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.mark_as_paid_by_id(payable_id: "payable_id") + def mark_as_paid_by_id(payable_id:, comment: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/mark_as_paid" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Mark a payable as partially paid. +# If the payable is partially paid, its status is moved to `partially_paid`. The +# value of the `amount_paid` field must be +# the sum of all payments made, not only the last one. +# Notes: +# - This endpoint can be used for payables in the `waiting_to_be_paid` status. +# - The `amount_paid` must be greater than 0 and less than the total payable +# amount specified by the `amount` field. +# - You can use this endpoint multiple times for the same payable to reflect +# multiple partial payments, always setting the +# sum of all payments made. +# - To use this endpoint with an entity user token, this entity user must have a +# role that includes the `pay` +# permission for payables. +# - The `amount_to_pay` field is automatically calculated based on the +# `amount_due` less the percentage described +# in the `payment_terms.discount` value. +# Related guide: [Mark a payable as partially +# .monite.com/accounts-payable/approvals/manual-transition#mark-as-partially-paid) +# See also: +# [Payables lifecycle](https://docs.monite.com/accounts-payable/payables/index) +# [Payables status +# ttps://docs.monite.com/accounts-payable/payables/collect#suggested-payment-date) +# [Mark a payable as +# tps://docs.monite.com/accounts-payable/approvals/manual-transition#mark-as-paid) + # + # @param payable_id [String] + # @param amount_paid [Integer] How much was paid on the invoice (in minor units). + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.mark_as_partially_paid_by_id(payable_id: "payable_id", amount_paid: 1) + def mark_as_partially_paid_by_id(payable_id:, amount_paid:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount_paid: amount_paid }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/mark_as_partially_paid" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Declines the payable when an approver finds any mismatch or discrepancies. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.reject_by_id(payable_id: "payable_id") + def reject_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/reject" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Reset payable state from rejected to new. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.reopen_by_id(payable_id: "payable_id") + def reopen_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/reopen" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Starts the approval process once the uploaded payable is validated. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.submit_for_approval_by_id(payable_id: "payable_id") + def submit_for_approval_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/submit_for_approval" +end + Monite::PayableResponseSchema.from_json(json_object: response.body) + end + end +# Check the invoice for compliance with the requirements for movement from draft +# to new status. + # + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PayableValidationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.validate_by_id(payable_id: "payable_id") + def validate_by_id(payable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{payable_id}/validate" +end + Monite::PayableValidationResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payables/line_items/client.rb b/lib/monite/payables/line_items/client.rb new file mode 100644 index 0000000..98e5124 --- /dev/null +++ b/lib/monite/payables/line_items/client.rb @@ -0,0 +1,673 @@ +# frozen_string_literal: true +require_relative "../../../requests" +require_relative "../../types/order_enum" +require_relative "../../types/line_item_cursor_fields" +require_relative "../../types/line_item_pagination_response" +require_relative "../../types/line_item_request" +require_relative "../../types/line_item_response" +require_relative "../../types/line_item_internal_request" +require_relative "../../types/line_items_replace_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../../requests" + +module Monite + module Payables + class LineItemsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Payables::LineItemsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get a list of all line items related to a specific payable. +# Related guide: [List all payable line +# onite.com/accounts-payable/payables/line-items#list-all-line-items-of-a-payable) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param payable_id [String] + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::LineItemCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param was_created_by_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.get(payable_id: "payable_id") + def get(payable_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, was_created_by_user_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "was_created_by_user_id": was_created_by_user_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)}/payables/#{payable_id}/line_items" +end + Monite::LineItemPaginationResponse.from_json(json_object: response.body) + end +# Add a new line item to a specific payable. +# The `subtotal` and `total` fields of line items are automatically calculated +# based on the `unit_price`, +# `quantity`, and `tax` fields, therefore, are read-only and appear only in the +# response schema. The field +# `ledger_account_id` is required **only** for account integration, otherwise, +# it is optional. +# Related guide: [Add line items to a +# ocs.monite.com/accounts-payable/payables/line-items#add-line-items-to-a-payable) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param payable_id [String] + # @param request [Hash] Request of type Monite::LineItemRequest, as a Hash + # * :accounting_tax_rate_id (String) + # * :description (String) + # * :ledger_account_id (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.create(payable_id: "payable_id", request: { }) + def create(payable_id:, request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/line_items" +end + Monite::LineItemResponse.from_json(json_object: response.body) + end +# Replaces the information of all line items of a specific payable. +# Related guide: [Replace all line +# s://docs.monite.com/accounts-payable/payables/line-items#replace-all-line-items) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param payable_id [String] + # @param data [Array] Request of type Array, as a Hash + # * :accounting_tax_rate_id (String) + # * :description (String) + # * :ledger_account_id (String) + # * :name (String) + # * :quantity (Float) + # * :subtotal (Integer) + # * :tax (Integer) + # * :total (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemsReplaceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.replace(payable_id: "payable_id", data: [{ }]) + def replace(payable_id:, data:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), data: data }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/line_items" +end + Monite::LineItemsReplaceResponse.from_json(json_object: response.body) + end +# Get information about a specific line item with a given ID. +# Related guide: [Retrieve a line +# tps://docs.monite.com/accounts-payable/payables/line-items#retrieve-a-line-item) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param line_item_id [String] + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.get_by_id(line_item_id: "line_item_id", payable_id: "payable_id") + def get_by_id(line_item_id:, payable_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{line_item_id}/line_items/#{payable_id}" +end + Monite::LineItemResponse.from_json(json_object: response.body) + end +# Delete the line item with the given ID. +# Related guide: [Remove a line +# https://docs.monite.com/accounts-payable/payables/line-items#remove-a-line-item) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param line_item_id [String] + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.delete_by_id(line_item_id: "line_item_id", payable_id: "payable_id") + def delete_by_id(line_item_id:, payable_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{line_item_id}/line_items/#{payable_id}" +end + end +# Edits the information of a specific line item. +# Related guide: [Update a line +# https://docs.monite.com/accounts-payable/payables/line-items#update-a-line-item) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param line_item_id [String] + # @param payable_id [String] + # @param request [Hash] Request of type Monite::LineItemRequest, as a Hash + # * :accounting_tax_rate_id (String) + # * :description (String) + # * :ledger_account_id (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.update_by_id( +# line_item_id: "line_item_id", +# payable_id: "payable_id", +# request: { } +# ) + def update_by_id(line_item_id:, payable_id:, request:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{line_item_id}/line_items/#{payable_id}" +end + Monite::LineItemResponse.from_json(json_object: response.body) + end + end + class AsyncLineItemsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::Payables::AsyncLineItemsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get a list of all line items related to a specific payable. +# Related guide: [List all payable line +# onite.com/accounts-payable/payables/line-items#list-all-line-items-of-a-payable) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param payable_id [String] + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::LineItemCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param was_created_by_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.get(payable_id: "payable_id") + def get(payable_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, was_created_by_user_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "was_created_by_user_id": was_created_by_user_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)}/payables/#{payable_id}/line_items" +end + Monite::LineItemPaginationResponse.from_json(json_object: response.body) + end + end +# Add a new line item to a specific payable. +# The `subtotal` and `total` fields of line items are automatically calculated +# based on the `unit_price`, +# `quantity`, and `tax` fields, therefore, are read-only and appear only in the +# response schema. The field +# `ledger_account_id` is required **only** for account integration, otherwise, +# it is optional. +# Related guide: [Add line items to a +# ocs.monite.com/accounts-payable/payables/line-items#add-line-items-to-a-payable) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param payable_id [String] + # @param request [Hash] Request of type Monite::LineItemRequest, as a Hash + # * :accounting_tax_rate_id (String) + # * :description (String) + # * :ledger_account_id (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.create(payable_id: "payable_id", request: { }) + def create(payable_id:, request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/line_items" +end + Monite::LineItemResponse.from_json(json_object: response.body) + end + end +# Replaces the information of all line items of a specific payable. +# Related guide: [Replace all line +# s://docs.monite.com/accounts-payable/payables/line-items#replace-all-line-items) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param payable_id [String] + # @param data [Array] Request of type Array, as a Hash + # * :accounting_tax_rate_id (String) + # * :description (String) + # * :ledger_account_id (String) + # * :name (String) + # * :quantity (Float) + # * :subtotal (Integer) + # * :tax (Integer) + # * :total (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemsReplaceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.replace(payable_id: "payable_id", data: [{ }]) + def replace(payable_id:, data:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), data: data }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{payable_id}/line_items" +end + Monite::LineItemsReplaceResponse.from_json(json_object: response.body) + end + end +# Get information about a specific line item with a given ID. +# Related guide: [Retrieve a line +# tps://docs.monite.com/accounts-payable/payables/line-items#retrieve-a-line-item) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param line_item_id [String] + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.get_by_id(line_item_id: "line_item_id", payable_id: "payable_id") + def get_by_id(line_item_id:, payable_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{line_item_id}/line_items/#{payable_id}" +end + Monite::LineItemResponse.from_json(json_object: response.body) + end + end +# Delete the line item with the given ID. +# Related guide: [Remove a line +# https://docs.monite.com/accounts-payable/payables/line-items#remove-a-line-item) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param line_item_id [String] + # @param payable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.delete_by_id(line_item_id: "line_item_id", payable_id: "payable_id") + def delete_by_id(line_item_id:, payable_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payables/#{line_item_id}/line_items/#{payable_id}" +end + end + end +# Edits the information of a specific line item. +# Related guide: [Update a line +# https://docs.monite.com/accounts-payable/payables/line-items#update-a-line-item) +# See also: +# [Manage line +# items](https://docs.monite.com/accounts-payable/payables/line-items) +# [Collect payables](https://docs.monite.com/accounts-payable/payables/collect) + # + # @param line_item_id [String] + # @param payable_id [String] + # @param request [Hash] Request of type Monite::LineItemRequest, as a Hash + # * :accounting_tax_rate_id (String) + # * :description (String) + # * :ledger_account_id (String) + # * :name (String) + # * :quantity (Float) + # * :tax (Integer) + # * :unit (String) + # * :unit_price (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payables.line_items.update_by_id( +# line_item_id: "line_item_id", +# payable_id: "payable_id", +# request: { } +# ) + def update_by_id(line_item_id:, payable_id:, request:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payables/#{line_item_id}/line_items/#{payable_id}" +end + Monite::LineItemResponse.from_json(json_object: response.body) + end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payment_intents/client.rb b/lib/monite/payment_intents/client.rb new file mode 100644 index 0000000..84c9237 --- /dev/null +++ b/lib/monite/payment_intents/client.rb @@ -0,0 +1,337 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/payment_intent_cursor_fields" +require_relative "../types/payment_intents_list_response" +require_relative "../types/payment_intent_response" +require_relative "../types/payment_intent_history_response" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PaymentIntentsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PaymentIntentsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::PaymentIntentCursorFields] Allowed sort fields + # @param object_id [String] ID of a payable or receivable invoice. If provided, returns only payment intents +# associated with the specified invoice. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentsListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, object_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_id": object_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)}/payment_intents" +end + Monite::PaymentIntentsListResponse.from_json(json_object: response.body) + end + # @param payment_intent_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.get_by_id(payment_intent_id: "payment_intent_id") + def get_by_id(payment_intent_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_intents/#{payment_intent_id}" +end + Monite::PaymentIntentResponse.from_json(json_object: response.body) + end + # @param payment_intent_id [String] + # @param amount [Integer] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.update_by_id(payment_intent_id: "payment_intent_id", amount: 1) + def update_by_id(payment_intent_id:, amount:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_intents/#{payment_intent_id}" +end + Monite::PaymentIntentResponse.from_json(json_object: response.body) + end + # @param payment_intent_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentHistoryResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.get_history_by_id(payment_intent_id: "payment_intent_id") + def get_history_by_id(payment_intent_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_intents/#{payment_intent_id}/history" +end + Monite::PaymentIntentHistoryResponse.from_json(json_object: response.body) + end + end + class AsyncPaymentIntentsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPaymentIntentsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::PaymentIntentCursorFields] Allowed sort fields + # @param object_id [String] ID of a payable or receivable invoice. If provided, returns only payment intents +# associated with the specified invoice. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentsListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, object_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_id": object_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)}/payment_intents" +end + Monite::PaymentIntentsListResponse.from_json(json_object: response.body) + end + end + # @param payment_intent_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.get_by_id(payment_intent_id: "payment_intent_id") + def get_by_id(payment_intent_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_intents/#{payment_intent_id}" +end + Monite::PaymentIntentResponse.from_json(json_object: response.body) + end + end + # @param payment_intent_id [String] + # @param amount [Integer] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.update_by_id(payment_intent_id: "payment_intent_id", amount: 1) + def update_by_id(payment_intent_id:, amount:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_intents/#{payment_intent_id}" +end + Monite::PaymentIntentResponse.from_json(json_object: response.body) + end + end + # @param payment_intent_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentIntentHistoryResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_intents.get_history_by_id(payment_intent_id: "payment_intent_id") + def get_history_by_id(payment_intent_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_intents/#{payment_intent_id}/history" +end + Monite::PaymentIntentHistoryResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payment_links/client.rb b/lib/monite/payment_links/client.rb new file mode 100644 index 0000000..7df5f2a --- /dev/null +++ b/lib/monite/payment_links/client.rb @@ -0,0 +1,310 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/currency_enum" +require "date" +require_relative "../types/invoice" +require_relative "../types/payment_object" +require_relative "../types/monite_all_payment_methods_types" +require_relative "../types/payment_account_object" +require_relative "../types/public_payment_link_response" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PaymentLinksClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PaymentLinksClient] + def initialize(request_client:) + @request_client = request_client + end + # @param amount [Integer] The payment amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Required if +# `object` is not specified. + # @param currency [Monite::CurrencyEnum] The payment currency. Required if `object` is not specified. + # @param expires_at [DateTime] + # @param invoice [Hash] An object containing information about the invoice being paid. Used only if +# `object` is not specified.Request of type Monite::Invoice, as a Hash + # * :due_date (String) + # * :file (Hash) + # * :mimetype (String) + # * :name (String) + # * :url (String) + # * :issue_date (String) + # @param object [Hash] If the invoice being paid is a payable or receivable stored in Monite, provide +# the `object` object containing the invoice type and ID. Otherwise, use the +# `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to +# specify the invoice-related data.Request of type Monite::PaymentObject, as a Hash + # * :id (String) + # * :type (Monite::PaymentObjectType) + # @param payment_methods [Array] + # @param payment_reference [String] A payment reference number that the recipient can use to identify the payer or +# purpose of the transaction. Required if `object` is not specified. + # @param recipient [Hash] Request of type Monite::PaymentAccountObject, as a Hash + # * :id (String) + # * :type (Monite::PaymentAccountType) + # @param return_url [String] The URL where to redirect the payer after the payment. If `return_url` is +# specified, then after the payment is completed the payment page will display the +# "Return to platform" link that navigates to this URL. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PublicPaymentLinkResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_links.create(payment_methods: [SEPA_CREDIT], recipient: { id: "id", type: ENTITY }) + def create(amount: nil, currency: nil, expires_at: nil, invoice: nil, object: nil, payment_methods:, payment_reference: nil, recipient:, return_url: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount, currency: currency, expires_at: expires_at, invoice: invoice, object: object, payment_methods: payment_methods, payment_reference: payment_reference, recipient: recipient, return_url: return_url }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_links" +end + Monite::PublicPaymentLinkResponse.from_json(json_object: response.body) + end + # @param payment_link_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PublicPaymentLinkResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_links.get_by_id(payment_link_id: "payment_link_id") + def get_by_id(payment_link_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_links/#{payment_link_id}" +end + Monite::PublicPaymentLinkResponse.from_json(json_object: response.body) + end + # @param payment_link_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PublicPaymentLinkResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_links.expire_by_id(payment_link_id: "payment_link_id") + def expire_by_id(payment_link_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_links/#{payment_link_id}/expire" +end + Monite::PublicPaymentLinkResponse.from_json(json_object: response.body) + end + end + class AsyncPaymentLinksClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPaymentLinksClient] + def initialize(request_client:) + @request_client = request_client + end + # @param amount [Integer] The payment amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Required if +# `object` is not specified. + # @param currency [Monite::CurrencyEnum] The payment currency. Required if `object` is not specified. + # @param expires_at [DateTime] + # @param invoice [Hash] An object containing information about the invoice being paid. Used only if +# `object` is not specified.Request of type Monite::Invoice, as a Hash + # * :due_date (String) + # * :file (Hash) + # * :mimetype (String) + # * :name (String) + # * :url (String) + # * :issue_date (String) + # @param object [Hash] If the invoice being paid is a payable or receivable stored in Monite, provide +# the `object` object containing the invoice type and ID. Otherwise, use the +# `amount`, `currency`, `payment_reference`, and (optionally) `invoice` fields to +# specify the invoice-related data.Request of type Monite::PaymentObject, as a Hash + # * :id (String) + # * :type (Monite::PaymentObjectType) + # @param payment_methods [Array] + # @param payment_reference [String] A payment reference number that the recipient can use to identify the payer or +# purpose of the transaction. Required if `object` is not specified. + # @param recipient [Hash] Request of type Monite::PaymentAccountObject, as a Hash + # * :id (String) + # * :type (Monite::PaymentAccountType) + # @param return_url [String] The URL where to redirect the payer after the payment. If `return_url` is +# specified, then after the payment is completed the payment page will display the +# "Return to platform" link that navigates to this URL. + # @param request_options [Monite::RequestOptions] + # @return [Monite::PublicPaymentLinkResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_links.create(payment_methods: [SEPA_CREDIT], recipient: { id: "id", type: ENTITY }) + def create(amount: nil, currency: nil, expires_at: nil, invoice: nil, object: nil, payment_methods:, payment_reference: nil, recipient:, return_url: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount, currency: currency, expires_at: expires_at, invoice: invoice, object: object, payment_methods: payment_methods, payment_reference: payment_reference, recipient: recipient, return_url: return_url }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_links" +end + Monite::PublicPaymentLinkResponse.from_json(json_object: response.body) + end + end + # @param payment_link_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PublicPaymentLinkResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_links.get_by_id(payment_link_id: "payment_link_id") + def get_by_id(payment_link_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_links/#{payment_link_id}" +end + Monite::PublicPaymentLinkResponse.from_json(json_object: response.body) + end + end + # @param payment_link_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PublicPaymentLinkResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_links.expire_by_id(payment_link_id: "payment_link_id") + def expire_by_id(payment_link_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_links/#{payment_link_id}/expire" +end + Monite::PublicPaymentLinkResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payment_records/client.rb b/lib/monite/payment_records/client.rb new file mode 100644 index 0000000..79a48c3 --- /dev/null +++ b/lib/monite/payment_records/client.rb @@ -0,0 +1,288 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/payment_record_cursor_fields" +require_relative "../types/payment_record_response_list" +require_relative "../types/currency_enum" +require_relative "../types/payment_record_object_request" +require "date" +require_relative "../types/payment_record_response" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PaymentRecordsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PaymentRecordsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::PaymentRecordCursorFields] Allowed sort fields + # @param is_external [Boolean] + # @param object_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentRecordResponseList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_records.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, is_external: nil, object_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "is_external": is_external, "object_id": object_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)}/payment_records" +end + Monite::PaymentRecordResponseList.from_json(json_object: response.body) + end + # @param amount [Integer] + # @param currency [Monite::CurrencyEnum] + # @param entity_user_id [String] + # @param object [Hash] Request of type Monite::PaymentRecordObjectRequest, as a Hash + # * :id (String) + # * :type (Monite::ObjectTypeEnum) + # @param paid_at [DateTime] + # @param payment_intent_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentRecordResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_records.create( +# amount: 1, +# currency: AED, +# object: { id: "id", type: RECEIVABLE }, +# paid_at: DateTime.parse("2024-01-15T09:30:00.000Z"), +# payment_intent_id: "payment_intent_id" +# ) + def create(amount:, currency:, entity_user_id: nil, object:, paid_at:, payment_intent_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount, currency: currency, entity_user_id: entity_user_id, object: object, paid_at: paid_at, payment_intent_id: payment_intent_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_records" +end + Monite::PaymentRecordResponse.from_json(json_object: response.body) + end + # @param payment_record_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentRecordResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_records.get_by_id(payment_record_id: "payment_record_id") + def get_by_id(payment_record_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_records/#{payment_record_id}" +end + Monite::PaymentRecordResponse.from_json(json_object: response.body) + end + end + class AsyncPaymentRecordsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPaymentRecordsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::PaymentRecordCursorFields] Allowed sort fields + # @param is_external [Boolean] + # @param object_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentRecordResponseList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_records.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, is_external: nil, object_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "is_external": is_external, "object_id": object_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)}/payment_records" +end + Monite::PaymentRecordResponseList.from_json(json_object: response.body) + end + end + # @param amount [Integer] + # @param currency [Monite::CurrencyEnum] + # @param entity_user_id [String] + # @param object [Hash] Request of type Monite::PaymentRecordObjectRequest, as a Hash + # * :id (String) + # * :type (Monite::ObjectTypeEnum) + # @param paid_at [DateTime] + # @param payment_intent_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentRecordResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_records.create( +# amount: 1, +# currency: AED, +# object: { id: "id", type: RECEIVABLE }, +# paid_at: DateTime.parse("2024-01-15T09:30:00.000Z"), +# payment_intent_id: "payment_intent_id" +# ) + def create(amount:, currency:, entity_user_id: nil, object:, paid_at:, payment_intent_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount: amount, currency: currency, entity_user_id: entity_user_id, object: object, paid_at: paid_at, payment_intent_id: payment_intent_id }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_records" +end + Monite::PaymentRecordResponse.from_json(json_object: response.body) + end + end + # @param payment_record_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentRecordResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_records.get_by_id(payment_record_id: "payment_record_id") + def get_by_id(payment_record_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_records/#{payment_record_id}" +end + Monite::PaymentRecordResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payment_reminders/client.rb b/lib/monite/payment_reminders/client.rb new file mode 100644 index 0000000..d33c4f0 --- /dev/null +++ b/lib/monite/payment_reminders/client.rb @@ -0,0 +1,461 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/get_all_payment_reminders" +require_relative "../types/recipients" +require_relative "../types/reminder" +require_relative "../types/payment_reminder_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PaymentRemindersClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PaymentRemindersClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::GetAllPaymentReminders] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_reminders" +end + Monite::GetAllPaymentReminders.from_json(json_object: response.body) + end + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param term_1_reminder [Hash] Reminder to send for first payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_2_reminder [Hash] Reminder to send for second payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_final_reminder [Hash] Reminder to send for final payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.create(name: "name") + def create(name:, recipients: nil, term_1_reminder: nil, term_2_reminder: nil, term_final_reminder: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, term_1_reminder: term_1_reminder, term_2_reminder: term_2_reminder, term_final_reminder: term_final_reminder }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_reminders" +end + Monite::PaymentReminderResponse.from_json(json_object: response.body) + end + # @param payment_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.get_by_id(payment_reminder_id: "payment_reminder_id") + def get_by_id(payment_reminder_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_reminders/#{payment_reminder_id}" +end + Monite::PaymentReminderResponse.from_json(json_object: response.body) + end + # @param payment_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.delete_by_id(payment_reminder_id: "payment_reminder_id") + def delete_by_id(payment_reminder_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_reminders/#{payment_reminder_id}" +end + end + # @param payment_reminder_id [String] + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param term_1_reminder [Hash] Reminder to send for first payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_2_reminder [Hash] Reminder to send for second payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_final_reminder [Hash] Reminder to send for final payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.update_by_id(payment_reminder_id: "payment_reminder_id") + def update_by_id(payment_reminder_id:, name: nil, recipients: nil, term_1_reminder: nil, term_2_reminder: nil, term_final_reminder: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, term_1_reminder: term_1_reminder, term_2_reminder: term_2_reminder, term_final_reminder: term_final_reminder }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_reminders/#{payment_reminder_id}" +end + Monite::PaymentReminderResponse.from_json(json_object: response.body) + end + end + class AsyncPaymentRemindersClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPaymentRemindersClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::GetAllPaymentReminders] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_reminders" +end + Monite::GetAllPaymentReminders.from_json(json_object: response.body) + end + end + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param term_1_reminder [Hash] Reminder to send for first payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_2_reminder [Hash] Reminder to send for second payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_final_reminder [Hash] Reminder to send for final payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.create(name: "name") + def create(name:, recipients: nil, term_1_reminder: nil, term_2_reminder: nil, term_final_reminder: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, term_1_reminder: term_1_reminder, term_2_reminder: term_2_reminder, term_final_reminder: term_final_reminder }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_reminders" +end + Monite::PaymentReminderResponse.from_json(json_object: response.body) + end + end + # @param payment_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.get_by_id(payment_reminder_id: "payment_reminder_id") + def get_by_id(payment_reminder_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_reminders/#{payment_reminder_id}" +end + Monite::PaymentReminderResponse.from_json(json_object: response.body) + end + end + # @param payment_reminder_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.delete_by_id(payment_reminder_id: "payment_reminder_id") + def delete_by_id(payment_reminder_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_reminders/#{payment_reminder_id}" +end + end + end + # @param payment_reminder_id [String] + # @param name [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param term_1_reminder [Hash] Reminder to send for first payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_2_reminder [Hash] Reminder to send for second payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param term_final_reminder [Hash] Reminder to send for final payment termRequest of type Monite::Reminder, as a Hash + # * :body (String) + # * :days_before (Integer) + # * :subject (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentReminderResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_reminders.update_by_id(payment_reminder_id: "payment_reminder_id") + def update_by_id(payment_reminder_id:, name: nil, recipients: nil, term_1_reminder: nil, term_2_reminder: nil, term_final_reminder: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, recipients: recipients, term_1_reminder: term_1_reminder, term_2_reminder: term_2_reminder, term_final_reminder: term_final_reminder }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_reminders/#{payment_reminder_id}" +end + Monite::PaymentReminderResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/payment_terms/client.rb b/lib/monite/payment_terms/client.rb new file mode 100644 index 0000000..79d6b4b --- /dev/null +++ b/lib/monite/payment_terms/client.rb @@ -0,0 +1,441 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/payment_terms_list_response" +require_relative "../types/payment_term_discount" +require_relative "../types/payment_term" +require_relative "../types/payment_terms_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PaymentTermsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PaymentTermsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_terms" +end + Monite::PaymentTermsListResponse.from_json(json_object: response.body) + end + # @param description [String] + # @param name [String] + # @param term_1 [Hash] The first tier of the payment term. Represents the terms of the first early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_2 [Hash] The second tier of the payment term. Defines the terms of the second early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_final [Hash] The final tier of the payment term. Defines the invoice due date.Request of type Monite::PaymentTerm, as a Hash + # * :number_of_days (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.create(name: "name", term_final: { number_of_days: 1 }) + def create(description: nil, name:, term_1: nil, term_2: nil, term_final:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name, term_1: term_1, term_2: term_2, term_final: term_final }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_terms" +end + Monite::PaymentTermsResponse.from_json(json_object: response.body) + end + # @param payment_terms_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.get_by_id(payment_terms_id: "payment_terms_id") + def get_by_id(payment_terms_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_terms/#{payment_terms_id}" +end + Monite::PaymentTermsResponse.from_json(json_object: response.body) + end + # @param payment_terms_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.delete_by_id(payment_terms_id: "payment_terms_id") + def delete_by_id(payment_terms_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_terms/#{payment_terms_id}" +end + end + # @param payment_terms_id [String] + # @param description [String] + # @param name [String] + # @param term_1 [Hash] The first tier of the payment term. Represents the terms of the first early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_2 [Hash] The second tier of the payment term. Defines the terms of the second early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_final [Hash] The final tier of the payment term. Defines the invoice due date.Request of type Monite::PaymentTerm, as a Hash + # * :number_of_days (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.update_by_id(payment_terms_id: "payment_terms_id") + def update_by_id(payment_terms_id:, description: nil, name: nil, term_1: nil, term_2: nil, term_final: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name, term_1: term_1, term_2: term_2, term_final: term_final }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_terms/#{payment_terms_id}" +end + Monite::PaymentTermsResponse.from_json(json_object: response.body) + end + end + class AsyncPaymentTermsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPaymentTermsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_terms" +end + Monite::PaymentTermsListResponse.from_json(json_object: response.body) + end + end + # @param description [String] + # @param name [String] + # @param term_1 [Hash] The first tier of the payment term. Represents the terms of the first early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_2 [Hash] The second tier of the payment term. Defines the terms of the second early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_final [Hash] The final tier of the payment term. Defines the invoice due date.Request of type Monite::PaymentTerm, as a Hash + # * :number_of_days (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.create(name: "name", term_final: { number_of_days: 1 }) + def create(description: nil, name:, term_1: nil, term_2: nil, term_final:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name, term_1: term_1, term_2: term_2, term_final: term_final }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_terms" +end + Monite::PaymentTermsResponse.from_json(json_object: response.body) + end + end + # @param payment_terms_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.get_by_id(payment_terms_id: "payment_terms_id") + def get_by_id(payment_terms_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_terms/#{payment_terms_id}" +end + Monite::PaymentTermsResponse.from_json(json_object: response.body) + end + end + # @param payment_terms_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.delete_by_id(payment_terms_id: "payment_terms_id") + def delete_by_id(payment_terms_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payment_terms/#{payment_terms_id}" +end + end + end + # @param payment_terms_id [String] + # @param description [String] + # @param name [String] + # @param term_1 [Hash] The first tier of the payment term. Represents the terms of the first early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_2 [Hash] The second tier of the payment term. Defines the terms of the second early +# discount.Request of type Monite::PaymentTermDiscount, as a Hash + # * :discount (Integer) + # * :number_of_days (Integer) + # @param term_final [Hash] The final tier of the payment term. Defines the invoice due date.Request of type Monite::PaymentTerm, as a Hash + # * :number_of_days (Integer) + # @param request_options [Monite::RequestOptions] + # @return [Monite::PaymentTermsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.payment_terms.update_by_id(payment_terms_id: "payment_terms_id") + def update_by_id(payment_terms_id:, description: nil, name: nil, term_1: nil, term_2: nil, term_final: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, name: name, term_1: term_1, term_2: term_2, term_final: term_final }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payment_terms/#{payment_terms_id}" +end + Monite::PaymentTermsResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/pdf_templates/client.rb b/lib/monite/pdf_templates/client.rb new file mode 100644 index 0000000..616f2a2 --- /dev/null +++ b/lib/monite/pdf_templates/client.rb @@ -0,0 +1,405 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/template_list_response" +require_relative "../types/template_receivable_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PdfTemplatesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PdfTemplatesClient] + def initialize(request_client:) + @request_client = request_client + end +# This API call returns all supported templates with language codes. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates" +end + Monite::TemplateListResponse.from_json(json_object: response.body) + end +# This API call returns all supported system templates with language codes. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.get_system + def get_system(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates/system" +end + Monite::TemplateListResponse.from_json(json_object: response.body) + end + # @param document_template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.get_by_id(document_template_id: "document_template_id") + def get_by_id(document_template_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates/#{document_template_id}" +end + Monite::TemplateReceivableResponse.from_json(json_object: response.body) + end + # @param document_template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.make_default_by_id(document_template_id: "document_template_id") + def make_default_by_id(document_template_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates/#{document_template_id}/make_default" +end + Monite::TemplateReceivableResponse.from_json(json_object: response.body) + end +# Returns a sample PDF invoice generated using the specified template. + # + # @param document_template_id [String] + # @param request_options [Monite::RequestOptions] + # @yield on_data[chunk, overall_received_bytes, env] Leverage the Faraday on_data callback which +# will receive tuples of strings, the sum of characters received so far, and the +# response environment. The latter will allow access to the response status, +# headers and reason, as well as the request info. + # @return [Void] + def preview_by_id(document_template_id:, request_options: nil, &on_data) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.options.on_data = on_data + 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)}/document_templates/#{document_template_id}/preview" +end + end + end + class AsyncPdfTemplatesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPdfTemplatesClient] + def initialize(request_client:) + @request_client = request_client + end +# This API call returns all supported templates with language codes. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates" +end + Monite::TemplateListResponse.from_json(json_object: response.body) + end + end +# This API call returns all supported system templates with language codes. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.get_system + def get_system(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates/system" +end + Monite::TemplateListResponse.from_json(json_object: response.body) + end + end + # @param document_template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.get_by_id(document_template_id: "document_template_id") + def get_by_id(document_template_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates/#{document_template_id}" +end + Monite::TemplateReceivableResponse.from_json(json_object: response.body) + end + end + # @param document_template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TemplateReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.pdf_templates.make_default_by_id(document_template_id: "document_template_id") + def make_default_by_id(document_template_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/document_templates/#{document_template_id}/make_default" +end + Monite::TemplateReceivableResponse.from_json(json_object: response.body) + end + end +# Returns a sample PDF invoice generated using the specified template. + # + # @param document_template_id [String] + # @param request_options [Monite::RequestOptions] + # @yield on_data[chunk, overall_received_bytes, env] Leverage the Faraday on_data callback which +# will receive tuples of strings, the sum of characters received so far, and the +# response environment. The latter will allow access to the response status, +# headers and reason, as well as the request info. + # @return [Void] + def preview_by_id(document_template_id:, request_options: nil, &on_data) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.options.on_data = on_data + 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)}/document_templates/#{document_template_id}/preview" +end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/products/client.rb b/lib/monite/products/client.rb new file mode 100644 index 0000000..8e63f69 --- /dev/null +++ b/lib/monite/products/client.rb @@ -0,0 +1,482 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/product_cursor_fields" +require_relative "../types/product_service_type_enum" +require_relative "../types/currency_enum" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/product_service_pagination_response" +require_relative "../types/price" +require_relative "../types/product_service_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class ProductsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ProductsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::PRODUCT_CURSOR_FIELDS] Allowed sort fields + # @param id_in [String] + # @param name [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param type [Monite::ProductServiceTypeEnum] + # @param price [Integer] + # @param price_gt [Integer] + # @param price_lt [Integer] + # @param price_gte [Integer] + # @param price_lte [Integer] + # @param currency [Monite::CurrencyEnum] + # @param currency_in [Monite::CurrencyEnum] + # @param measure_unit_id [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServicePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, name: nil, name_contains: nil, name_icontains: nil, type: nil, price: nil, price_gt: nil, price_lt: nil, price_gte: nil, price_lte: nil, currency: nil, currency_in: nil, measure_unit_id: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "name": name, "name__contains": name_contains, "name__icontains": name_icontains, "type": type, "price": price, "price__gt": price_gt, "price__lt": price_lt, "price__gte": price_gte, "price__lte": price_lte, "currency": currency, "currency__in": currency_in, "measure_unit_id": measure_unit_id, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/products" +end + Monite::ProductServicePaginationResponse.from_json(json_object: response.body) + end + # @param description [String] Description of the product. + # @param ledger_account_id [String] + # @param measure_unit_id [String] The unique ID reference of the unit used to measure the quantity of this product +# (e.g. items, meters, kilograms). + # @param name [String] Name of the product. + # @param price [Hash] Request of type Monite::Price, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :value (Integer) + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServiceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.create(name: "name") + def create(description: nil, ledger_account_id: nil, measure_unit_id: nil, name:, price: nil, smallest_amount: nil, type: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, ledger_account_id: ledger_account_id, measure_unit_id: measure_unit_id, name: name, price: price, smallest_amount: smallest_amount, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/products" +end + Monite::ProductServiceResponse.from_json(json_object: response.body) + end + # @param product_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServiceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.get_by_id(product_id: "product_id") + def get_by_id(product_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/products/#{product_id}" +end + Monite::ProductServiceResponse.from_json(json_object: response.body) + end + # @param product_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.delete_by_id(product_id: "product_id") + def delete_by_id(product_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/products/#{product_id}" +end + end + # @param product_id [String] + # @param description [String] Description of the product. + # @param ledger_account_id [String] + # @param measure_unit_id [String] The unique ID reference of the unit used to measure the quantity of this product +# (e.g. items, meters, kilograms). + # @param name [String] Name of the product. + # @param price [Hash] Request of type Monite::Price, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :value (Integer) + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServiceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.update_by_id(product_id: "product_id") + def update_by_id(product_id:, description: nil, ledger_account_id: nil, measure_unit_id: nil, name: nil, price: nil, smallest_amount: nil, type: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, ledger_account_id: ledger_account_id, measure_unit_id: measure_unit_id, name: name, price: price, smallest_amount: smallest_amount, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/products/#{product_id}" +end + Monite::ProductServiceResponse.from_json(json_object: response.body) + end + end + class AsyncProductsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncProductsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::PRODUCT_CURSOR_FIELDS] Allowed sort fields + # @param id_in [String] + # @param name [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param type [Monite::ProductServiceTypeEnum] + # @param price [Integer] + # @param price_gt [Integer] + # @param price_lt [Integer] + # @param price_gte [Integer] + # @param price_lte [Integer] + # @param currency [Monite::CurrencyEnum] + # @param currency_in [Monite::CurrencyEnum] + # @param measure_unit_id [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServicePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, name: nil, name_contains: nil, name_icontains: nil, type: nil, price: nil, price_gt: nil, price_lt: nil, price_gte: nil, price_lte: nil, currency: nil, currency_in: nil, measure_unit_id: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "name": name, "name__contains": name_contains, "name__icontains": name_icontains, "type": type, "price": price, "price__gt": price_gt, "price__lt": price_lt, "price__gte": price_gte, "price__lte": price_lte, "currency": currency, "currency__in": currency_in, "measure_unit_id": measure_unit_id, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/products" +end + Monite::ProductServicePaginationResponse.from_json(json_object: response.body) + end + end + # @param description [String] Description of the product. + # @param ledger_account_id [String] + # @param measure_unit_id [String] The unique ID reference of the unit used to measure the quantity of this product +# (e.g. items, meters, kilograms). + # @param name [String] Name of the product. + # @param price [Hash] Request of type Monite::Price, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :value (Integer) + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServiceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.create(name: "name") + def create(description: nil, ledger_account_id: nil, measure_unit_id: nil, name:, price: nil, smallest_amount: nil, type: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, ledger_account_id: ledger_account_id, measure_unit_id: measure_unit_id, name: name, price: price, smallest_amount: smallest_amount, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/products" +end + Monite::ProductServiceResponse.from_json(json_object: response.body) + end + end + # @param product_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServiceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.get_by_id(product_id: "product_id") + def get_by_id(product_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/products/#{product_id}" +end + Monite::ProductServiceResponse.from_json(json_object: response.body) + end + end + # @param product_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.delete_by_id(product_id: "product_id") + def delete_by_id(product_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/products/#{product_id}" +end + end + end + # @param product_id [String] + # @param description [String] Description of the product. + # @param ledger_account_id [String] + # @param measure_unit_id [String] The unique ID reference of the unit used to measure the quantity of this product +# (e.g. items, meters, kilograms). + # @param name [String] Name of the product. + # @param price [Hash] Request of type Monite::Price, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :value (Integer) + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProductServiceResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.products.update_by_id(product_id: "product_id") + def update_by_id(product_id:, description: nil, ledger_account_id: nil, measure_unit_id: nil, name: nil, price: nil, smallest_amount: nil, type: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), description: description, ledger_account_id: ledger_account_id, measure_unit_id: measure_unit_id, name: name, price: price, smallest_amount: smallest_amount, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/products/#{product_id}" +end + Monite::ProductServiceResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/projects/client.rb b/lib/monite/projects/client.rb new file mode 100644 index 0000000..16a7b1f --- /dev/null +++ b/lib/monite/projects/client.rb @@ -0,0 +1,511 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/project_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/project_pagination_response" +require_relative "../types/project_resource" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class ProjectsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ProjectsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all projects for an entity + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::ProjectCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param start_date [String] + # @param start_date_gt [String] + # @param start_date_lt [String] + # @param start_date_gte [String] + # @param start_date_lte [String] + # @param end_date [String] + # @param end_date_gt [String] + # @param end_date_lt [String] + # @param end_date_gte [String] + # @param end_date_lte [String] + # @param name [String] + # @param name_iexact [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param code [String] + # @param created_by_entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, start_date: nil, start_date_gt: nil, start_date_lt: nil, start_date_gte: nil, start_date_lte: nil, end_date: nil, end_date_gt: nil, end_date_lt: nil, end_date_gte: nil, end_date_lte: nil, name: nil, name_iexact: nil, name_contains: nil, name_icontains: nil, code: nil, created_by_entity_user_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "start_date": start_date, "start_date__gt": start_date_gt, "start_date__lt": start_date_lt, "start_date__gte": start_date_gte, "start_date__lte": start_date_lte, "end_date": end_date, "end_date__gt": end_date_gt, "end_date__lt": end_date_lt, "end_date__gte": end_date_gte, "end_date__lte": end_date_lte, "name": name, "name__iexact": name_iexact, "name__contains": name_contains, "name__icontains": name_icontains, "code": code, "created_by_entity_user_id": created_by_entity_user_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)}/projects" +end + Monite::ProjectPaginationResponse.from_json(json_object: response.body) + end +# Create a new project. + # + # @param code [String] Project code + # @param color [String] Project color + # @param description [String] Description of project + # @param end_date [String] Project end date + # @param name [String] The project name. + # @param parent_id [String] Parent project ID + # @param partner_metadata [Hash{String => Object}] Project metadata + # @param start_date [String] Project start date + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this project. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.create(name: "Marketing") + def create(code: nil, color: nil, description: nil, end_date: nil, name:, parent_id: nil, partner_metadata: nil, start_date: nil, tag_ids: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), code: code, color: color, description: description, end_date: end_date, name: name, parent_id: parent_id, partner_metadata: partner_metadata, start_date: start_date, tag_ids: tag_ids }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/projects" +end + Monite::ProjectResource.from_json(json_object: response.body) + end +# Get a project with the given ID. + # + # @param project_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.get_by_id(project_id: "project_id") + def get_by_id(project_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/projects/#{project_id}" +end + Monite::ProjectResource.from_json(json_object: response.body) + end +# Delete a project. + # + # @param project_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.delete_by_id(project_id: "project_id") + def delete_by_id(project_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/projects/#{project_id}" +end + end +# Update a project. + # + # @param project_id [String] + # @param code [String] Project code + # @param color [String] Project color + # @param description [String] Description of project + # @param end_date [String] Project end date + # @param name [String] The project name. + # @param parent_id [String] Parent project ID + # @param partner_metadata [Hash{String => Object}] Project metadata + # @param start_date [String] Project start date + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this project. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.update_by_id(project_id: "project_id") + def update_by_id(project_id:, code: nil, color: nil, description: nil, end_date: nil, name: nil, parent_id: nil, partner_metadata: nil, start_date: nil, tag_ids: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), code: code, color: color, description: description, end_date: end_date, name: name, parent_id: parent_id, partner_metadata: partner_metadata, start_date: start_date, tag_ids: tag_ids }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/projects/#{project_id}" +end + Monite::ProjectResource.from_json(json_object: response.body) + end + end + class AsyncProjectsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncProjectsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get all projects for an entity + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::ProjectCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param start_date [String] + # @param start_date_gt [String] + # @param start_date_lt [String] + # @param start_date_gte [String] + # @param start_date_lte [String] + # @param end_date [String] + # @param end_date_gt [String] + # @param end_date_lt [String] + # @param end_date_gte [String] + # @param end_date_lte [String] + # @param name [String] + # @param name_iexact [String] + # @param name_contains [String] + # @param name_icontains [String] + # @param code [String] + # @param created_by_entity_user_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, start_date: nil, start_date_gt: nil, start_date_lt: nil, start_date_gte: nil, start_date_lte: nil, end_date: nil, end_date_gt: nil, end_date_lt: nil, end_date_gte: nil, end_date_lte: nil, name: nil, name_iexact: nil, name_contains: nil, name_icontains: nil, code: nil, created_by_entity_user_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "start_date": start_date, "start_date__gt": start_date_gt, "start_date__lt": start_date_lt, "start_date__gte": start_date_gte, "start_date__lte": start_date_lte, "end_date": end_date, "end_date__gt": end_date_gt, "end_date__lt": end_date_lt, "end_date__gte": end_date_gte, "end_date__lte": end_date_lte, "name": name, "name__iexact": name_iexact, "name__contains": name_contains, "name__icontains": name_icontains, "code": code, "created_by_entity_user_id": created_by_entity_user_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)}/projects" +end + Monite::ProjectPaginationResponse.from_json(json_object: response.body) + end + end +# Create a new project. + # + # @param code [String] Project code + # @param color [String] Project color + # @param description [String] Description of project + # @param end_date [String] Project end date + # @param name [String] The project name. + # @param parent_id [String] Parent project ID + # @param partner_metadata [Hash{String => Object}] Project metadata + # @param start_date [String] Project start date + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this project. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.create(name: "Marketing") + def create(code: nil, color: nil, description: nil, end_date: nil, name:, parent_id: nil, partner_metadata: nil, start_date: nil, tag_ids: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), code: code, color: color, description: description, end_date: end_date, name: name, parent_id: parent_id, partner_metadata: partner_metadata, start_date: start_date, tag_ids: tag_ids }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/projects" +end + Monite::ProjectResource.from_json(json_object: response.body) + end + end +# Get a project with the given ID. + # + # @param project_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.get_by_id(project_id: "project_id") + def get_by_id(project_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/projects/#{project_id}" +end + Monite::ProjectResource.from_json(json_object: response.body) + end + end +# Delete a project. + # + # @param project_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.delete_by_id(project_id: "project_id") + def delete_by_id(project_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/projects/#{project_id}" +end + end + end +# Update a project. + # + # @param project_id [String] + # @param code [String] Project code + # @param color [String] Project color + # @param description [String] Description of project + # @param end_date [String] Project end date + # @param name [String] The project name. + # @param parent_id [String] Parent project ID + # @param partner_metadata [Hash{String => Object}] Project metadata + # @param start_date [String] Project start date + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this project. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ProjectResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.projects.update_by_id(project_id: "project_id") + def update_by_id(project_id:, code: nil, color: nil, description: nil, end_date: nil, name: nil, parent_id: nil, partner_metadata: nil, start_date: nil, tag_ids: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), code: code, color: color, description: description, end_date: end_date, name: name, parent_id: parent_id, partner_metadata: partner_metadata, start_date: start_date, tag_ids: tag_ids }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/projects/#{project_id}" +end + Monite::ProjectResource.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/purchase_orders/client.rb b/lib/monite/purchase_orders/client.rb new file mode 100644 index 0000000..a69b44f --- /dev/null +++ b/lib/monite/purchase_orders/client.rb @@ -0,0 +1,784 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/purchase_order_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/purchase_order_status_enum" +require_relative "../types/currency_enum" +require_relative "../types/purchase_order_pagination_response" +require_relative "../types/purchase_order_item" +require_relative "../types/purchase_order_response_schema" +require_relative "../types/variables_object_list" +require_relative "../types/purchase_order_email_preview_response" +require_relative "../types/purchase_order_email_sent_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class PurchaseOrdersClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::PurchaseOrdersClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::PurchaseOrderCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param issued_at_gt [DateTime] + # @param issued_at_lt [DateTime] + # @param issued_at_gte [DateTime] + # @param issued_at_lte [DateTime] + # @param status [Monite::PurchaseOrderStatusEnum] + # @param document_id [String] + # @param document_id_in [String] + # @param created_by [String] + # @param counterpart_id [String] + # @param counterpart_id_in [String] + # @param counterpart_name [String] + # @param currency [Monite::CurrencyEnum] + # @param currency_in [Monite::CurrencyEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, issued_at_gt: nil, issued_at_lt: nil, issued_at_gte: nil, issued_at_lte: nil, status: nil, document_id: nil, document_id_in: nil, created_by: nil, counterpart_id: nil, counterpart_id_in: nil, counterpart_name: nil, currency: nil, currency_in: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte, "issued_at__gt": issued_at_gt, "issued_at__lt": issued_at_lt, "issued_at__gte": issued_at_gte, "issued_at__lte": issued_at_lte, "status": status, "document_id": document_id, "document_id__in": document_id_in, "created_by": created_by, "counterpart_id": counterpart_id, "counterpart_id__in": counterpart_id_in, "counterpart.name": counterpart_name, "currency": currency, "currency__in": currency_in }.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)}/payable_purchase_orders" +end + Monite::PurchaseOrderPaginationResponse.from_json(json_object: response.body) + end + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service. If not +# provided, counterpart's default address is used. + # @param counterpart_id [String] Counterpart unique ID. + # @param currency [Monite::CurrencyEnum] The currency in which the price of the product is set. (all items need to have +# the same currency) + # @param entity_vat_id_id [String] Entity VAT ID identifier that applied to purchase order + # @param items [Array] List of item to purchaseRequest of type Array, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :name (String) + # * :price (Integer) + # * :quantity (Integer) + # * :unit (String) + # * :vat_rate (Integer) + # @param message [String] Msg which will be send to counterpart for who the purchase order is issued. + # @param valid_for_days [Integer] Number of days for which purchase order is valid + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.create( +# counterpart_id: "counterpart_id", +# currency: AED, +# items: [{ currency: AED, name: "name", price: 1, quantity: 1, unit: "unit", vat_rate: 1 }], +# message: "message", +# valid_for_days: 1 +# ) + def create(counterpart_address_id: nil, counterpart_id:, currency:, entity_vat_id_id: nil, items:, message:, valid_for_days:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), counterpart_address_id: counterpart_address_id, counterpart_id: counterpart_id, currency: currency, entity_vat_id_id: entity_vat_id_id, items: items, message: message, valid_for_days: valid_for_days }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders" +end + Monite::PurchaseOrderResponseSchema.from_json(json_object: response.body) + end +# Get a list of placeholders allowed to insert into an email template for +# customization + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::VariablesObjectList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.get_variables + def get_variables(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_purchase_orders/variables" +end + Monite::VariablesObjectList.from_json(json_object: response.body) + end + # @param purchase_order_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.get_by_id(purchase_order_id: "purchase_order_id") + def get_by_id(purchase_order_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_purchase_orders/#{purchase_order_id}" +end + Monite::PurchaseOrderResponseSchema.from_json(json_object: response.body) + end + # @param purchase_order_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.delete_by_id(purchase_order_id: "purchase_order_id") + def delete_by_id(purchase_order_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_purchase_orders/#{purchase_order_id}" +end + end + # @param purchase_order_id [String] + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service. If not +# provided, counterpart's default address is used. + # @param counterpart_id [String] Counterpart unique ID. + # @param entity_vat_id_id [String] Entity VAT ID identifier that applied to purchase order + # @param items [Array] List of item to purchaseRequest of type Array, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :name (String) + # * :price (Integer) + # * :quantity (Integer) + # * :unit (String) + # * :vat_rate (Integer) + # @param message [String] Msg which will be send to counterpart for who the purchase order is issued. + # @param valid_for_days [Integer] Number of days for which purchase order is valid + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.update_by_id(purchase_order_id: "purchase_order_id") + def update_by_id(purchase_order_id:, counterpart_address_id: nil, counterpart_id: nil, entity_vat_id_id: nil, items: nil, message: nil, valid_for_days: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), counterpart_address_id: counterpart_address_id, counterpart_id: counterpart_id, entity_vat_id_id: entity_vat_id_id, items: items, message: message, valid_for_days: valid_for_days }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders/#{purchase_order_id}" +end + Monite::PurchaseOrderResponseSchema.from_json(json_object: response.body) + end + # @param purchase_order_id [String] + # @param body_text [String] + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderEmailPreviewResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.preview_by_id( +# purchase_order_id: "purchase_order_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def preview_by_id(purchase_order_id:, body_text:, subject_text:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders/#{purchase_order_id}/preview" +end + Monite::PurchaseOrderEmailPreviewResponse.from_json(json_object: response.body) + end + # @param purchase_order_id [String] + # @param body_text [String] + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderEmailSentResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.send_by_id( +# purchase_order_id: "purchase_order_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def send_by_id(purchase_order_id:, body_text:, subject_text:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders/#{purchase_order_id}/send" +end + Monite::PurchaseOrderEmailSentResponse.from_json(json_object: response.body) + end + end + class AsyncPurchaseOrdersClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncPurchaseOrdersClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::PurchaseOrderCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param updated_at_gt [DateTime] + # @param updated_at_lt [DateTime] + # @param updated_at_gte [DateTime] + # @param updated_at_lte [DateTime] + # @param issued_at_gt [DateTime] + # @param issued_at_lt [DateTime] + # @param issued_at_gte [DateTime] + # @param issued_at_lte [DateTime] + # @param status [Monite::PurchaseOrderStatusEnum] + # @param document_id [String] + # @param document_id_in [String] + # @param created_by [String] + # @param counterpart_id [String] + # @param counterpart_id_in [String] + # @param counterpart_name [String] + # @param currency [Monite::CurrencyEnum] + # @param currency_in [Monite::CurrencyEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, updated_at_gt: nil, updated_at_lt: nil, updated_at_gte: nil, updated_at_lte: nil, issued_at_gt: nil, issued_at_lt: nil, issued_at_gte: nil, issued_at_lte: nil, status: nil, document_id: nil, document_id_in: nil, created_by: nil, counterpart_id: nil, counterpart_id_in: nil, counterpart_name: nil, currency: nil, currency_in: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "updated_at__gt": updated_at_gt, "updated_at__lt": updated_at_lt, "updated_at__gte": updated_at_gte, "updated_at__lte": updated_at_lte, "issued_at__gt": issued_at_gt, "issued_at__lt": issued_at_lt, "issued_at__gte": issued_at_gte, "issued_at__lte": issued_at_lte, "status": status, "document_id": document_id, "document_id__in": document_id_in, "created_by": created_by, "counterpart_id": counterpart_id, "counterpart_id__in": counterpart_id_in, "counterpart.name": counterpart_name, "currency": currency, "currency__in": currency_in }.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)}/payable_purchase_orders" +end + Monite::PurchaseOrderPaginationResponse.from_json(json_object: response.body) + end + end + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service. If not +# provided, counterpart's default address is used. + # @param counterpart_id [String] Counterpart unique ID. + # @param currency [Monite::CurrencyEnum] The currency in which the price of the product is set. (all items need to have +# the same currency) + # @param entity_vat_id_id [String] Entity VAT ID identifier that applied to purchase order + # @param items [Array] List of item to purchaseRequest of type Array, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :name (String) + # * :price (Integer) + # * :quantity (Integer) + # * :unit (String) + # * :vat_rate (Integer) + # @param message [String] Msg which will be send to counterpart for who the purchase order is issued. + # @param valid_for_days [Integer] Number of days for which purchase order is valid + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.create( +# counterpart_id: "counterpart_id", +# currency: AED, +# items: [{ currency: AED, name: "name", price: 1, quantity: 1, unit: "unit", vat_rate: 1 }], +# message: "message", +# valid_for_days: 1 +# ) + def create(counterpart_address_id: nil, counterpart_id:, currency:, entity_vat_id_id: nil, items:, message:, valid_for_days:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), counterpart_address_id: counterpart_address_id, counterpart_id: counterpart_id, currency: currency, entity_vat_id_id: entity_vat_id_id, items: items, message: message, valid_for_days: valid_for_days }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders" +end + Monite::PurchaseOrderResponseSchema.from_json(json_object: response.body) + end + end +# Get a list of placeholders allowed to insert into an email template for +# customization + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::VariablesObjectList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.get_variables + def get_variables(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_purchase_orders/variables" +end + Monite::VariablesObjectList.from_json(json_object: response.body) + end + end + # @param purchase_order_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.get_by_id(purchase_order_id: "purchase_order_id") + def get_by_id(purchase_order_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_purchase_orders/#{purchase_order_id}" +end + Monite::PurchaseOrderResponseSchema.from_json(json_object: response.body) + end + end + # @param purchase_order_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.delete_by_id(purchase_order_id: "purchase_order_id") + def delete_by_id(purchase_order_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/payable_purchase_orders/#{purchase_order_id}" +end + end + end + # @param purchase_order_id [String] + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service. If not +# provided, counterpart's default address is used. + # @param counterpart_id [String] Counterpart unique ID. + # @param entity_vat_id_id [String] Entity VAT ID identifier that applied to purchase order + # @param items [Array] List of item to purchaseRequest of type Array, as a Hash + # * :currency (Monite::CurrencyEnum) + # * :name (String) + # * :price (Integer) + # * :quantity (Integer) + # * :unit (String) + # * :vat_rate (Integer) + # @param message [String] Msg which will be send to counterpart for who the purchase order is issued. + # @param valid_for_days [Integer] Number of days for which purchase order is valid + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderResponseSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.update_by_id(purchase_order_id: "purchase_order_id") + def update_by_id(purchase_order_id:, counterpart_address_id: nil, counterpart_id: nil, entity_vat_id_id: nil, items: nil, message: nil, valid_for_days: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), counterpart_address_id: counterpart_address_id, counterpart_id: counterpart_id, entity_vat_id_id: entity_vat_id_id, items: items, message: message, valid_for_days: valid_for_days }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders/#{purchase_order_id}" +end + Monite::PurchaseOrderResponseSchema.from_json(json_object: response.body) + end + end + # @param purchase_order_id [String] + # @param body_text [String] + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderEmailPreviewResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.preview_by_id( +# purchase_order_id: "purchase_order_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def preview_by_id(purchase_order_id:, body_text:, subject_text:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders/#{purchase_order_id}/preview" +end + Monite::PurchaseOrderEmailPreviewResponse.from_json(json_object: response.body) + end + end + # @param purchase_order_id [String] + # @param body_text [String] + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::PurchaseOrderEmailSentResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.purchase_orders.send_by_id( +# purchase_order_id: "purchase_order_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def send_by_id(purchase_order_id:, body_text:, subject_text:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/payable_purchase_orders/#{purchase_order_id}/send" +end + Monite::PurchaseOrderEmailSentResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/receivables/client.rb b/lib/monite/receivables/client.rb new file mode 100644 index 0000000..3a9ca78 --- /dev/null +++ b/lib/monite/receivables/client.rb @@ -0,0 +1,2288 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "types/receivables_get_request_status_in_item" +require_relative "../types/receivable_cursor_fields" +require_relative "../types/receivable_type" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "types/receivables_get_request_status" +require_relative "../types/receivable_pagination_response" +require_relative "../types/receivable_facade_create_payload" +require_relative "../types/receivable_response" +require_relative "../types/receivable_templates_variables_object_list" +require_relative "../types/receivable_update_payload" +require_relative "../types/signature" +require_relative "../types/success_result" +require_relative "../types/receivable_history_cursor_fields" +require_relative "../types/receivable_history_event_type_enum" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/receivable_history_pagination_response" +require_relative "../types/receivable_history_response" +require_relative "../types/line_item" +require_relative "../types/line_items_response" +require_relative "../types/receivable_mail_cursor_fields" +require_relative "../types/receivable_mail_status_enum" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/receivable_mail_pagination_response" +require_relative "../types/receivable_mail_response" +require "date" +require_relative "../types/receivable_file_url" +require_relative "../types/language_code_enum" +require_relative "../types/receivables_preview_type_enum" +require_relative "../types/receivable_preview_response" +require_relative "../types/recipients" +require_relative "../types/receivable_send_response" +require_relative "../types/reminder_type_enum" +require_relative "../types/receivables_send_response" +require_relative "../types/receivables_verify_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class ReceivablesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::ReceivablesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of [accounts +# receivable](https://docs.monite.com/accounts-receivable/index) documents - +# invoices, quotes, and credit notes - of the specified entity. +# Results can be filtered by amount, counterpart, due date, and other criteria. +# Multiple filters are combined using logical AND unless specified otherwise. If +# no documents matching the search criteria are found, the endpoint returns a +# successful response with an empty `data` array. +# This endpoint supports +# [pagination](https://docs.monite.com/api/concepts/pagination-sorting-filtering) +# and sorting. By default, results are sorted by the creation date in ascending +# order (from oldest to newest). +# #### Examples +# ##### Invoices +# * Get all overdue invoices: +# ``` +# GET /receivables?type=invoice&status=overdue +# ``` +# * Get all invoices created for the counterpart named "Solarwind" +# (case-insensitive): +# ``` +# GET /receivables?type=invoice?counterpart_name__icontains=Solarwind +# ``` +# * Get invoices whose total amount starts from 500 EUR: +# ``` +# GET /receivables?type=invoice&total_amount__gte=50000 +# ``` +# * Get invoices that are due for payment in September 2024: +# ``` +# GET +# ype=invoice&due_date__gte=2024-09-01T00:00:00Z&due_date__lt=2024-10-01T00:00:00Z +# ``` +# * Get invoices created on or after September 1, 2024: +# ``` +# GET /receivables?type=invoice&created_at__gte=2024-09-01T00:00:00Z +# ``` +# * Find an invoice created from a specific quote: +# ``` +# GET /receivables?type=invoice?based_on=QUOTE_ID +# ``` +# ##### Quotes +# * Get the latest created quote: +# ``` +# GET /receivables?type=quote&sort=created_at&order=desc&limit=1 +# ``` +# * Get the latest issued quote: +# ``` +# GET /receivables?type=quote&sort=issue_date&order=desc&limit=1 +# ``` +# ##### Credit notes +# * Find all credit notes created for a specific invoice: +# ``` +# GET /receivables?type=credit_note?based_on=INVOICE_ID +# ``` + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. +# When using pagination with a non-default `limit`, you must provide the `limit` +# value alongside `pagination_token` in all subsequent pagination requests. Unlike +# other query parameters, `limit` is not inferred from `pagination_token`. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters except `limit` are +# ignored and inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param id_in [String] Return only receivables with the specified IDs. Valid but nonexistent IDs do not +# raise errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param status_in [Monite::Receivables::ReceivablesGetRequestStatusInItem] Return only receivables that have the specified statuses. See the applicable +# [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), +# [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and +# [credit note +# https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=issued` + # @param entity_user_id_in [String] Return only receivables created by the entity users with the specified IDs.To +# specify multiple user IDs, repeat this parameter for each ID: +# `entity_user_id__in=&entity_user_id__in=` +# If the request is authenticated using an entity user token, this user must have +# the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be +# able to query receivables created by other users. +# IDs of deleted users will still produce results here if those users had +# associated receivables. Valid but nonexistent user IDs do not raise errors but +# produce no results. + # @param sort [Monite::ReceivableCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param tag_ids_in [String] Return only receivables whose [tags](https://docs.monite.com/common/tags) +# include at least one of the tags with the specified IDs. +# For example, given receivables with the following tags: +# 1. tagA +# 2. tagB +# 3. tagA, tagB +# 4. tagC +# 5. tagB, tagC +# `tag_ids__in=&tag_ids__in=` will return receivables 1, 2, 3, and 5. +# Valid but nonexistent tag IDs do not raise errors but produce no results. + # @param tag_ids [String] Return only receivables whose [tags](https://docs.monite.com/common/tags) +# include all of the tags with the specified IDs and optionally other tags that +# are not specified. +# For example, given receivables with the following tags: +# 1. tagA +# 2. tagB +# 3. tagA, tagB +# 4. tagC +# 5. tagA, tagB, tagC +# `tag_ids=&tag_ids=` will return receivables 3 and 5. + # @param type [Monite::ReceivableType] + # @param document_id [String] + # @param document_id_contains [String] + # @param document_id_icontains [String] + # @param issue_date_gt [DateTime] + # @param issue_date_lt [DateTime] + # @param issue_date_gte [DateTime] + # @param issue_date_lte [DateTime] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param counterpart_id [String] + # @param counterpart_name [String] + # @param counterpart_name_contains [String] + # @param counterpart_name_icontains [String] + # @param total_amount [Integer] + # @param total_amount_gt [Integer] + # @param total_amount_lt [Integer] + # @param total_amount_gte [Integer] + # @param total_amount_lte [Integer] + # @param status [Monite::Receivables::ReceivablesGetRequestStatus] + # @param entity_user_id [String] + # @param based_on [String] + # @param due_date_gt [String] + # @param due_date_lt [String] + # @param due_date_gte [String] + # @param due_date_lte [String] + # @param project_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get + def get(order: nil, limit: nil, pagination_token: nil, id_in: nil, status_in: nil, entity_user_id_in: nil, sort: nil, tag_ids_in: nil, tag_ids: nil, type: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, issue_date_gt: nil, issue_date_lt: nil, issue_date_gte: nil, issue_date_lte: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, counterpart_id: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, status: nil, entity_user_id: nil, based_on: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, project_id: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "id__in": id_in, "status__in": status_in, "entity_user_id__in": entity_user_id_in, "sort": sort, "tag_ids__in": tag_ids_in, "tag_ids": tag_ids, "type": type, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "issue_date__gt": issue_date_gt, "issue_date__lt": issue_date_lt, "issue_date__gte": issue_date_gte, "issue_date__lte": issue_date_lte, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "status": status, "entity_user_id": entity_user_id, "based_on": based_on, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "project_id": project_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)}/receivables" +end + Monite::ReceivablePaginationResponse.from_json(json_object: response.body) + end + # @param request [Monite::ReceivableFacadeCreateQuotePayload, Monite::ReceivableFacadeCreateInvoicePayload, Monite::ReceivableCreateBasedOnPayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.create(request: { counterpart_billing_address_id: "counterpart_billing_address_id", counterpart_id: "counterpart_id", currency: AED, line_items: [{ quantity: 1.1 }], type: "quote" }) + def create(request:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end +# Get a list of placeholders that can be used in email templates for +# customization. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableTemplatesVariablesObjectList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_variables + def get_variables(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/variables" +end + Monite::ReceivableTemplatesVariablesObjectList.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_by_id(receivable_id: "receivable_id") + def get_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.delete_by_id(receivable_id: "receivable_id") + def delete_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}" +end + end + # @param receivable_id [String] + # @param request [Monite::UpdateQuotePayload, Monite::UpdateInvoicePayload, Monite::UpdateCreditNotePayload, Monite::UpdateIssuedInvoicePayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.update_by_id(receivable_id: "receivable_id", request: { quote: { } }) + def update_by_id(receivable_id:, request:, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param signature [Hash] A digital signature, if required for quote acceptanceRequest of type Monite::Signature, as a Hash + # * :email (String) + # * :full_name (String) + # * :signature_image (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::SuccessResult] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.accept_by_id(receivable_id: "receivable_id") + def accept_by_id(receivable_id:, signature: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), signature: signature }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/accept" +end + Monite::SuccessResult.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.cancel_by_id(receivable_id: "receivable_id") + def cancel_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/cancel" +end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.clone_by_id(receivable_id: "receivable_id") + def clone_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/clone" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param comment [String] Field with a comment on why the client declined this Quote + # @param request_options [Monite::RequestOptions] + # @return [Monite::SuccessResult] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.decline_by_id(receivable_id: "receivable_id") + def decline_by_id(receivable_id:, comment: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/decline" +end + Monite::SuccessResult.from_json(json_object: response.body) + end +# Returns the history of the specified accounts receivable document. The history +# contains all revisions of the document, status updates, and other events that +# occurred during the document's lifecycle. For more information, see [Document +# history](https://docs.monite.com/accounts-receivable/document-history). +# You can filter the history by the date range and event type. Events are sorted +# from oldest to newest by default. + # + # @param receivable_id [String] ID of the accounts receivable document whose history you want to get. + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::RECEIVABLE_HISTORY_CURSOR_FIELDS] Allowed sort fields + # @param event_type_in [Monite::ReceivableHistoryEventTypeEnum] Return only the specified [event +# ypes](https://docs.monite.com/accounts-receivable/document-history#event-types). +# To include multiple types, repeat this parameter for each value: +# `event_type__in=receivable_updated&event_type__in=status_changed` + # @param entity_user_id_in [String] Return only events caused by the entity users with the specified IDs. To specify +# multiple user IDs, repeat this parameter for each ID: +# `entity_user_id__in=&entity_user_id__in=` + # @param timestamp_gt [DateTime] Return only events that occurred after the specified date and time. The value +# must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. + # @param timestamp_lt [DateTime] Return only events that occurred before the specified date and time. + # @param timestamp_gte [DateTime] Return only events that occurred on or after the specified date and time. + # @param timestamp_lte [DateTime] Return only events that occurred before or on the specified date and time. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableHistoryPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_history(receivable_id: "receivable_id") + def get_history(receivable_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, event_type_in: nil, entity_user_id_in: nil, timestamp_gt: nil, timestamp_lt: nil, timestamp_gte: nil, timestamp_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "event_type__in": event_type_in, "entity_user_id__in": entity_user_id_in, "timestamp__gt": timestamp_gt, "timestamp__lt": timestamp_lt, "timestamp__gte": timestamp_gte, "timestamp__lte": timestamp_lte }.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)}/receivables/#{receivable_id}/history" +end + Monite::ReceivableHistoryPaginationResponse.from_json(json_object: response.body) + end +# Returns a single record from the change history of the specified accounts +# receivable document. + # + # @param receivable_history_id [String] ID of the history record to return. You can get these IDs from `GET +# /receivables/{receivable_id}/history`. + # @param receivable_id [String] ID of the accounts receivable document whose history you want to get. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableHistoryResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_history_by_id(receivable_history_id: "receivable_history_id", receivable_id: "receivable_id") + def get_history_by_id(receivable_history_id:, receivable_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_history_id}/history/#{receivable_id}" +end + Monite::ReceivableHistoryResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.issue_by_id(receivable_id: "receivable_id") + def issue_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/issue" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end +# Replace all line items of an existing invoice or quote with a new list of line +# items. + # + # @param receivable_id [String] + # @param data [Array] Request of type Array, as a Hash + # * :discount (Hash) + # * :amount (Integer) + # * :type (Monite::DiscountType) + # * :product (Hash) + # * :description (String) + # * :ledger_account_id (String) + # * :measure_unit (Hash) + # * :description (String) + # * :name (String) + # * :name (String) + # * :price (Hash) + # * :currency (Monite::CurrencyEnum) + # * :value (Integer) + # * :smallest_amount (Float) + # * :type (Monite::ProductServiceTypeEnum) + # * :product_id (String) + # * :quantity (Float) + # * :tax_rate_value (Integer) + # * :vat_rate_id (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.update_line_items_by_id(receivable_id: "receivable_id", data: [{ quantity: 1.1 }]) + def update_line_items_by_id(receivable_id:, data:, request_options: nil) + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), data: data }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/line_items" +end + Monite::LineItemsResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ReceivableMailCursorFields] Allowed sort fields + # @param status [Monite::ReceivableMailStatusEnum] + # @param status_in [Monite::ReceivableMailStatusEnum] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableMailPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_mails(receivable_id: "receivable_id") + def get_mails(receivable_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, status: nil, status_in: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "status": status, "status__in": status_in, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/receivables/#{receivable_id}/mails" +end + Monite::ReceivableMailPaginationResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param mail_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableMailResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_mail_by_id(receivable_id: "receivable_id", mail_id: "mail_id") + def get_mail_by_id(receivable_id:, mail_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/mails/#{mail_id}" +end + Monite::ReceivableMailResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param comment [String] Optional comment explaining how the payment was made. + # @param paid_at [DateTime] Date and time when the invoice was paid. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.mark_as_paid_by_id(receivable_id: "receivable_id") + def mark_as_paid_by_id(receivable_id:, comment: nil, paid_at: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment, paid_at: paid_at }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/mark_as_paid" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end +# Deprecated. Use `POST /payment_records` to record an invoice payment. + # + # @param receivable_id [String] + # @param amount_paid [Integer] How much has been paid on the invoice (in minor units). + # @param comment [String] Optional comment explaining how the payment was made. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.mark_as_partially_paid_by_id(receivable_id: "receivable_id", amount_paid: 1) + def mark_as_partially_paid_by_id(receivable_id:, amount_paid:, comment: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount_paid: amount_paid, comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/mark_as_partially_paid" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param comment [String] Optional comment explains why the Invoice goes uncollectible. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.mark_as_uncollectible_by_id(receivable_id: "receivable_id") + def mark_as_uncollectible_by_id(receivable_id:, comment: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/mark_as_uncollectible" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableFileUrl] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_pdf_link_by_id(receivable_id: "receivable_id") + def get_pdf_link_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/pdf_link" +end + Monite::ReceivableFileUrl.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param body_text [String] Body text of the content + # @param language [Monite::LanguageCodeEnum] Language code for localization purposes + # @param subject_text [String] Subject text of the content + # @param type [Monite::ReceivablesPreviewTypeEnum] The type of the preview document. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablePreviewResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.preview_by_id( +# receivable_id: "receivable_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def preview_by_id(receivable_id:, body_text:, language: nil, subject_text:, type: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, language: language, subject_text: subject_text, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/preview" +end + Monite::ReceivablePreviewResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param body_text [String] Body text of the content + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param subject_text [String] Subject text of the content + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableSendResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.send_by_id( +# receivable_id: "receivable_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def send_by_id(receivable_id:, body_text:, recipients: nil, subject_text:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, recipients: recipients, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/send" +end + Monite::ReceivableSendResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param reminder_type [Monite::ReminderTypeEnum] The type of the reminder to be sent. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablesSendResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.send_test_reminder_by_id(receivable_id: "receivable_id", reminder_type: TERM_1) + def send_test_reminder_by_id(receivable_id:, recipients: nil, reminder_type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), recipients: recipients, reminder_type: reminder_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/send_test_reminder" +end + Monite::ReceivablesSendResponse.from_json(json_object: response.body) + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablesVerifyResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.verify_by_id(receivable_id: "receivable_id") + def verify_by_id(receivable_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/verify" +end + Monite::ReceivablesVerifyResponse.from_json(json_object: response.body) + end + end + class AsyncReceivablesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncReceivablesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns a list of [accounts +# receivable](https://docs.monite.com/accounts-receivable/index) documents - +# invoices, quotes, and credit notes - of the specified entity. +# Results can be filtered by amount, counterpart, due date, and other criteria. +# Multiple filters are combined using logical AND unless specified otherwise. If +# no documents matching the search criteria are found, the endpoint returns a +# successful response with an empty `data` array. +# This endpoint supports +# [pagination](https://docs.monite.com/api/concepts/pagination-sorting-filtering) +# and sorting. By default, results are sorted by the creation date in ascending +# order (from oldest to newest). +# #### Examples +# ##### Invoices +# * Get all overdue invoices: +# ``` +# GET /receivables?type=invoice&status=overdue +# ``` +# * Get all invoices created for the counterpart named "Solarwind" +# (case-insensitive): +# ``` +# GET /receivables?type=invoice?counterpart_name__icontains=Solarwind +# ``` +# * Get invoices whose total amount starts from 500 EUR: +# ``` +# GET /receivables?type=invoice&total_amount__gte=50000 +# ``` +# * Get invoices that are due for payment in September 2024: +# ``` +# GET +# ype=invoice&due_date__gte=2024-09-01T00:00:00Z&due_date__lt=2024-10-01T00:00:00Z +# ``` +# * Get invoices created on or after September 1, 2024: +# ``` +# GET /receivables?type=invoice&created_at__gte=2024-09-01T00:00:00Z +# ``` +# * Find an invoice created from a specific quote: +# ``` +# GET /receivables?type=invoice?based_on=QUOTE_ID +# ``` +# ##### Quotes +# * Get the latest created quote: +# ``` +# GET /receivables?type=quote&sort=created_at&order=desc&limit=1 +# ``` +# * Get the latest issued quote: +# ``` +# GET /receivables?type=quote&sort=issue_date&order=desc&limit=1 +# ``` +# ##### Credit notes +# * Find all credit notes created for a specific invoice: +# ``` +# GET /receivables?type=credit_note?based_on=INVOICE_ID +# ``` + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. +# When using pagination with a non-default `limit`, you must provide the `limit` +# value alongside `pagination_token` in all subsequent pagination requests. Unlike +# other query parameters, `limit` is not inferred from `pagination_token`. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters except `limit` are +# ignored and inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param id_in [String] Return only receivables with the specified IDs. Valid but nonexistent IDs do not +# raise errors but produce no results. +# To specify multiple IDs, repeat this parameter for each value: +# `id__in=&id__in=` + # @param status_in [Monite::Receivables::ReceivablesGetRequestStatusInItem] Return only receivables that have the specified statuses. See the applicable +# [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), +# [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), and +# [credit note +# https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). +# To specify multiple statuses, repeat this parameter for each value: +# `status__in=draft&status__in=issued` + # @param entity_user_id_in [String] Return only receivables created by the entity users with the specified IDs.To +# specify multiple user IDs, repeat this parameter for each ID: +# `entity_user_id__in=&entity_user_id__in=` +# If the request is authenticated using an entity user token, this user must have +# the `receivable.read.allowed` (rather than `allowed_for_own`) permission to be +# able to query receivables created by other users. +# IDs of deleted users will still produce results here if those users had +# associated receivables. Valid but nonexistent user IDs do not raise errors but +# produce no results. + # @param sort [Monite::ReceivableCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param tag_ids_in [String] Return only receivables whose [tags](https://docs.monite.com/common/tags) +# include at least one of the tags with the specified IDs. +# For example, given receivables with the following tags: +# 1. tagA +# 2. tagB +# 3. tagA, tagB +# 4. tagC +# 5. tagB, tagC +# `tag_ids__in=&tag_ids__in=` will return receivables 1, 2, 3, and 5. +# Valid but nonexistent tag IDs do not raise errors but produce no results. + # @param tag_ids [String] Return only receivables whose [tags](https://docs.monite.com/common/tags) +# include all of the tags with the specified IDs and optionally other tags that +# are not specified. +# For example, given receivables with the following tags: +# 1. tagA +# 2. tagB +# 3. tagA, tagB +# 4. tagC +# 5. tagA, tagB, tagC +# `tag_ids=&tag_ids=` will return receivables 3 and 5. + # @param type [Monite::ReceivableType] + # @param document_id [String] + # @param document_id_contains [String] + # @param document_id_icontains [String] + # @param issue_date_gt [DateTime] + # @param issue_date_lt [DateTime] + # @param issue_date_gte [DateTime] + # @param issue_date_lte [DateTime] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param counterpart_id [String] + # @param counterpart_name [String] + # @param counterpart_name_contains [String] + # @param counterpart_name_icontains [String] + # @param total_amount [Integer] + # @param total_amount_gt [Integer] + # @param total_amount_lt [Integer] + # @param total_amount_gte [Integer] + # @param total_amount_lte [Integer] + # @param status [Monite::Receivables::ReceivablesGetRequestStatus] + # @param entity_user_id [String] + # @param based_on [String] + # @param due_date_gt [String] + # @param due_date_lt [String] + # @param due_date_gte [String] + # @param due_date_lte [String] + # @param project_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get + def get(order: nil, limit: nil, pagination_token: nil, id_in: nil, status_in: nil, entity_user_id_in: nil, sort: nil, tag_ids_in: nil, tag_ids: nil, type: nil, document_id: nil, document_id_contains: nil, document_id_icontains: nil, issue_date_gt: nil, issue_date_lt: nil, issue_date_gte: nil, issue_date_lte: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, counterpart_id: nil, counterpart_name: nil, counterpart_name_contains: nil, counterpart_name_icontains: nil, total_amount: nil, total_amount_gt: nil, total_amount_lt: nil, total_amount_gte: nil, total_amount_lte: nil, status: nil, entity_user_id: nil, based_on: nil, due_date_gt: nil, due_date_lt: nil, due_date_gte: nil, due_date_lte: nil, project_id: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "id__in": id_in, "status__in": status_in, "entity_user_id__in": entity_user_id_in, "sort": sort, "tag_ids__in": tag_ids_in, "tag_ids": tag_ids, "type": type, "document_id": document_id, "document_id__contains": document_id_contains, "document_id__icontains": document_id_icontains, "issue_date__gt": issue_date_gt, "issue_date__lt": issue_date_lt, "issue_date__gte": issue_date_gte, "issue_date__lte": issue_date_lte, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, "counterpart_name__contains": counterpart_name_contains, "counterpart_name__icontains": counterpart_name_icontains, "total_amount": total_amount, "total_amount__gt": total_amount_gt, "total_amount__lt": total_amount_lt, "total_amount__gte": total_amount_gte, "total_amount__lte": total_amount_lte, "status": status, "entity_user_id": entity_user_id, "based_on": based_on, "due_date__gt": due_date_gt, "due_date__lt": due_date_lt, "due_date__gte": due_date_gte, "due_date__lte": due_date_lte, "project_id": project_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)}/receivables" +end + Monite::ReceivablePaginationResponse.from_json(json_object: response.body) + end + end + # @param request [Monite::ReceivableFacadeCreateQuotePayload, Monite::ReceivableFacadeCreateInvoicePayload, Monite::ReceivableCreateBasedOnPayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.create(request: { counterpart_billing_address_id: "counterpart_billing_address_id", counterpart_id: "counterpart_id", currency: AED, line_items: [{ quantity: 1.1 }], type: "quote" }) + def create(request:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end +# Get a list of placeholders that can be used in email templates for +# customization. + # + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableTemplatesVariablesObjectList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_variables + def get_variables(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/variables" +end + Monite::ReceivableTemplatesVariablesObjectList.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_by_id(receivable_id: "receivable_id") + def get_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.delete_by_id(receivable_id: "receivable_id") + def delete_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}" +end + end + end + # @param receivable_id [String] + # @param request [Monite::UpdateQuotePayload, Monite::UpdateInvoicePayload, Monite::UpdateCreditNotePayload, Monite::UpdateIssuedInvoicePayload] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.update_by_id(receivable_id: "receivable_id", request: { quote: { } }) + def update_by_id(receivable_id:, request:, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request || {}), **(request_options&.additional_body_parameters || {}) }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param signature [Hash] A digital signature, if required for quote acceptanceRequest of type Monite::Signature, as a Hash + # * :email (String) + # * :full_name (String) + # * :signature_image (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::SuccessResult] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.accept_by_id(receivable_id: "receivable_id") + def accept_by_id(receivable_id:, signature: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), signature: signature }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/accept" +end + Monite::SuccessResult.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.cancel_by_id(receivable_id: "receivable_id") + def cancel_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/cancel" +end + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.clone_by_id(receivable_id: "receivable_id") + def clone_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/clone" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param comment [String] Field with a comment on why the client declined this Quote + # @param request_options [Monite::RequestOptions] + # @return [Monite::SuccessResult] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.decline_by_id(receivable_id: "receivable_id") + def decline_by_id(receivable_id:, comment: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/decline" +end + Monite::SuccessResult.from_json(json_object: response.body) + end + end +# Returns the history of the specified accounts receivable document. The history +# contains all revisions of the document, status updates, and other events that +# occurred during the document's lifecycle. For more information, see [Document +# history](https://docs.monite.com/accounts-receivable/document-history). +# You can filter the history by the date range and event type. Events are sorted +# from oldest to newest by default. + # + # @param receivable_id [String] ID of the accounts receivable document whose history you want to get. + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::RECEIVABLE_HISTORY_CURSOR_FIELDS] Allowed sort fields + # @param event_type_in [Monite::ReceivableHistoryEventTypeEnum] Return only the specified [event +# ypes](https://docs.monite.com/accounts-receivable/document-history#event-types). +# To include multiple types, repeat this parameter for each value: +# `event_type__in=receivable_updated&event_type__in=status_changed` + # @param entity_user_id_in [String] Return only events caused by the entity users with the specified IDs. To specify +# multiple user IDs, repeat this parameter for each ID: +# `entity_user_id__in=&entity_user_id__in=` + # @param timestamp_gt [DateTime] Return only events that occurred after the specified date and time. The value +# must be in the ISO 8601 format `YYYY-MM-DDThh:mm[:ss[.ffffff]][Z|±hh:mm]`. + # @param timestamp_lt [DateTime] Return only events that occurred before the specified date and time. + # @param timestamp_gte [DateTime] Return only events that occurred on or after the specified date and time. + # @param timestamp_lte [DateTime] Return only events that occurred before or on the specified date and time. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableHistoryPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_history(receivable_id: "receivable_id") + def get_history(receivable_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, event_type_in: nil, entity_user_id_in: nil, timestamp_gt: nil, timestamp_lt: nil, timestamp_gte: nil, timestamp_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "event_type__in": event_type_in, "entity_user_id__in": entity_user_id_in, "timestamp__gt": timestamp_gt, "timestamp__lt": timestamp_lt, "timestamp__gte": timestamp_gte, "timestamp__lte": timestamp_lte }.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)}/receivables/#{receivable_id}/history" +end + Monite::ReceivableHistoryPaginationResponse.from_json(json_object: response.body) + end + end +# Returns a single record from the change history of the specified accounts +# receivable document. + # + # @param receivable_history_id [String] ID of the history record to return. You can get these IDs from `GET +# /receivables/{receivable_id}/history`. + # @param receivable_id [String] ID of the accounts receivable document whose history you want to get. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableHistoryResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_history_by_id(receivable_history_id: "receivable_history_id", receivable_id: "receivable_id") + def get_history_by_id(receivable_history_id:, receivable_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_history_id}/history/#{receivable_id}" +end + Monite::ReceivableHistoryResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.issue_by_id(receivable_id: "receivable_id") + def issue_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/issue" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end +# Replace all line items of an existing invoice or quote with a new list of line +# items. + # + # @param receivable_id [String] + # @param data [Array] Request of type Array, as a Hash + # * :discount (Hash) + # * :amount (Integer) + # * :type (Monite::DiscountType) + # * :product (Hash) + # * :description (String) + # * :ledger_account_id (String) + # * :measure_unit (Hash) + # * :description (String) + # * :name (String) + # * :name (String) + # * :price (Hash) + # * :currency (Monite::CurrencyEnum) + # * :value (Integer) + # * :smallest_amount (Float) + # * :type (Monite::ProductServiceTypeEnum) + # * :product_id (String) + # * :quantity (Float) + # * :tax_rate_value (Integer) + # * :vat_rate_id (String) + # @param request_options [Monite::RequestOptions] + # @return [Monite::LineItemsResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.update_line_items_by_id(receivable_id: "receivable_id", data: [{ quantity: 1.1 }]) + def update_line_items_by_id(receivable_id:, data:, request_options: nil) + Async do + response = @request_client.conn.put do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), data: data }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/line_items" +end + Monite::LineItemsResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param order [Monite::OrderEnum] Order by + # @param limit [Integer] Max is 100 + # @param pagination_token [String] A token, obtained from previous page. Prior over other filters + # @param sort [Monite::ReceivableMailCursorFields] Allowed sort fields + # @param status [Monite::ReceivableMailStatusEnum] + # @param status_in [Monite::ReceivableMailStatusEnum] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableMailPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_mails(receivable_id: "receivable_id") + def get_mails(receivable_id:, order: nil, limit: nil, pagination_token: nil, sort: nil, status: nil, status_in: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "status": status, "status__in": status_in, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/receivables/#{receivable_id}/mails" +end + Monite::ReceivableMailPaginationResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param mail_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableMailResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_mail_by_id(receivable_id: "receivable_id", mail_id: "mail_id") + def get_mail_by_id(receivable_id:, mail_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/mails/#{mail_id}" +end + Monite::ReceivableMailResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param comment [String] Optional comment explaining how the payment was made. + # @param paid_at [DateTime] Date and time when the invoice was paid. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.mark_as_paid_by_id(receivable_id: "receivable_id") + def mark_as_paid_by_id(receivable_id:, comment: nil, paid_at: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment, paid_at: paid_at }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/mark_as_paid" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end +# Deprecated. Use `POST /payment_records` to record an invoice payment. + # + # @param receivable_id [String] + # @param amount_paid [Integer] How much has been paid on the invoice (in minor units). + # @param comment [String] Optional comment explaining how the payment was made. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.mark_as_partially_paid_by_id(receivable_id: "receivable_id", amount_paid: 1) + def mark_as_partially_paid_by_id(receivable_id:, amount_paid:, comment: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), amount_paid: amount_paid, comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/mark_as_partially_paid" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param comment [String] Optional comment explains why the Invoice goes uncollectible. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.mark_as_uncollectible_by_id(receivable_id: "receivable_id") + def mark_as_uncollectible_by_id(receivable_id:, comment: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), comment: comment }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/mark_as_uncollectible" +end + Monite::ReceivableResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableFileUrl] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.get_pdf_link_by_id(receivable_id: "receivable_id") + def get_pdf_link_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/pdf_link" +end + Monite::ReceivableFileUrl.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param body_text [String] Body text of the content + # @param language [Monite::LanguageCodeEnum] Language code for localization purposes + # @param subject_text [String] Subject text of the content + # @param type [Monite::ReceivablesPreviewTypeEnum] The type of the preview document. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablePreviewResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.preview_by_id( +# receivable_id: "receivable_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def preview_by_id(receivable_id:, body_text:, language: nil, subject_text:, type: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, language: language, subject_text: subject_text, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/preview" +end + Monite::ReceivablePreviewResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param body_text [String] Body text of the content + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param subject_text [String] Subject text of the content + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivableSendResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.send_by_id( +# receivable_id: "receivable_id", +# body_text: "body_text", +# subject_text: "subject_text" +# ) + def send_by_id(receivable_id:, body_text:, recipients: nil, subject_text:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, recipients: recipients, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/send" +end + Monite::ReceivableSendResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param reminder_type [Monite::ReminderTypeEnum] The type of the reminder to be sent. + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablesSendResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.send_test_reminder_by_id(receivable_id: "receivable_id", reminder_type: TERM_1) + def send_test_reminder_by_id(receivable_id:, recipients: nil, reminder_type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), recipients: recipients, reminder_type: reminder_type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/receivables/#{receivable_id}/send_test_reminder" +end + Monite::ReceivablesSendResponse.from_json(json_object: response.body) + end + end + # @param receivable_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::ReceivablesVerifyResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.receivables.verify_by_id(receivable_id: "receivable_id") + def verify_by_id(receivable_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/receivables/#{receivable_id}/verify" +end + Monite::ReceivablesVerifyResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/receivables/types/receivables_get_request_status.rb b/lib/monite/receivables/types/receivables_get_request_status.rb new file mode 100644 index 0000000..f5ab2db --- /dev/null +++ b/lib/monite/receivables/types/receivables_get_request_status.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Monite + module Receivables + class ReceivablesGetRequestStatus + + DRAFT = "draft" + ISSUED = "issued" + ACCEPTED = "accepted" + EXPIRED = "expired" + DECLINED = "declined" + RECURRING = "recurring" + PARTIALLY_PAID = "partially_paid" + PAID = "paid" + OVERDUE = "overdue" + UNCOLLECTIBLE = "uncollectible" + CANCELED = "canceled" + + end + end +end \ No newline at end of file diff --git a/lib/monite/receivables/types/receivables_get_request_status_in_item.rb b/lib/monite/receivables/types/receivables_get_request_status_in_item.rb new file mode 100644 index 0000000..41b841b --- /dev/null +++ b/lib/monite/receivables/types/receivables_get_request_status_in_item.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Monite + module Receivables + class ReceivablesGetRequestStatusInItem + + DRAFT = "draft" + ISSUED = "issued" + ACCEPTED = "accepted" + EXPIRED = "expired" + DECLINED = "declined" + RECURRING = "recurring" + PARTIALLY_PAID = "partially_paid" + PAID = "paid" + OVERDUE = "overdue" + UNCOLLECTIBLE = "uncollectible" + CANCELED = "canceled" + + end + end +end \ No newline at end of file diff --git a/lib/monite/recurrences/client.rb b/lib/monite/recurrences/client.rb new file mode 100644 index 0000000..474fecb --- /dev/null +++ b/lib/monite/recurrences/client.rb @@ -0,0 +1,449 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/get_all_recurrences" +require_relative "../types/day_of_month" +require_relative "../types/recipients" +require_relative "../types/recurrence" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class RecurrencesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::RecurrencesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::GetAllRecurrences] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.get + def get(request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/recurrences" +end + Monite::GetAllRecurrences.from_json(json_object: response.body) + end + # @param body_text [String] + # @param day_of_month [Monite::DayOfMonth] + # @param end_month [Integer] + # @param end_year [Integer] + # @param invoice_id [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param start_month [Integer] + # @param start_year [Integer] + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::Recurrence] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.create( +# day_of_month: FIRST_DAY, +# end_month: 1, +# end_year: 1, +# invoice_id: "invoice_id", +# start_month: 1, +# start_year: 1 +# ) + def create(body_text: nil, day_of_month:, end_month:, end_year:, invoice_id:, recipients: nil, start_month:, start_year:, subject_text: nil, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, day_of_month: day_of_month, end_month: end_month, end_year: end_year, invoice_id: invoice_id, recipients: recipients, start_month: start_month, start_year: start_year, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/recurrences" +end + Monite::Recurrence.from_json(json_object: response.body) + end + # @param recurrence_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::Recurrence] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.get_by_id(recurrence_id: "recurrence_id") + def get_by_id(recurrence_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/recurrences/#{recurrence_id}" +end + Monite::Recurrence.from_json(json_object: response.body) + end + # @param recurrence_id [String] + # @param body_text [String] + # @param day_of_month [Monite::DayOfMonth] + # @param end_month [Integer] + # @param end_year [Integer] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::Recurrence] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.update_by_id(recurrence_id: "recurrence_id") + def update_by_id(recurrence_id:, body_text: nil, day_of_month: nil, end_month: nil, end_year: nil, recipients: nil, subject_text: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, day_of_month: day_of_month, end_month: end_month, end_year: end_year, recipients: recipients, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/recurrences/#{recurrence_id}" +end + Monite::Recurrence.from_json(json_object: response.body) + end + # @param recurrence_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.cancel_by_id(recurrence_id: "recurrence_id") + def cancel_by_id(recurrence_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/recurrences/#{recurrence_id}/cancel" +end + end + end + class AsyncRecurrencesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncRecurrencesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param request_options [Monite::RequestOptions] + # @return [Monite::GetAllRecurrences] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.get + def get(request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/recurrences" +end + Monite::GetAllRecurrences.from_json(json_object: response.body) + end + end + # @param body_text [String] + # @param day_of_month [Monite::DayOfMonth] + # @param end_month [Integer] + # @param end_year [Integer] + # @param invoice_id [String] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param start_month [Integer] + # @param start_year [Integer] + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::Recurrence] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.create( +# day_of_month: FIRST_DAY, +# end_month: 1, +# end_year: 1, +# invoice_id: "invoice_id", +# start_month: 1, +# start_year: 1 +# ) + def create(body_text: nil, day_of_month:, end_month:, end_year:, invoice_id:, recipients: nil, start_month:, start_year:, subject_text: nil, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, day_of_month: day_of_month, end_month: end_month, end_year: end_year, invoice_id: invoice_id, recipients: recipients, start_month: start_month, start_year: start_year, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/recurrences" +end + Monite::Recurrence.from_json(json_object: response.body) + end + end + # @param recurrence_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::Recurrence] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.get_by_id(recurrence_id: "recurrence_id") + def get_by_id(recurrence_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/recurrences/#{recurrence_id}" +end + Monite::Recurrence.from_json(json_object: response.body) + end + end + # @param recurrence_id [String] + # @param body_text [String] + # @param day_of_month [Monite::DayOfMonth] + # @param end_month [Integer] + # @param end_year [Integer] + # @param recipients [Hash] Request of type Monite::Recipients, as a Hash + # * :bcc (Array) + # * :cc (Array) + # * :to (Array) + # @param subject_text [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::Recurrence] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.update_by_id(recurrence_id: "recurrence_id") + def update_by_id(recurrence_id:, body_text: nil, day_of_month: nil, end_month: nil, end_year: nil, recipients: nil, subject_text: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), body_text: body_text, day_of_month: day_of_month, end_month: end_month, end_year: end_year, recipients: recipients, subject_text: subject_text }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/recurrences/#{recurrence_id}" +end + Monite::Recurrence.from_json(json_object: response.body) + end + end + # @param recurrence_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.recurrences.cancel_by_id(recurrence_id: "recurrence_id") + def cancel_by_id(recurrence_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/recurrences/#{recurrence_id}/cancel" +end + end + end + end +end \ No newline at end of file diff --git a/lib/monite/roles/client.rb b/lib/monite/roles/client.rb new file mode 100644 index 0000000..727ee1d --- /dev/null +++ b/lib/monite/roles/client.rb @@ -0,0 +1,382 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/role_cursor_fields" +require "date" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/role_pagination_response" +require_relative "../types/biz_objects_schema_input" +require_relative "../types/role_response" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class RolesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::RolesClient] + def initialize(request_client:) + @request_client = request_client + end +# Find all roles that match the search criteria. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::RoleCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param id_in [String] + # @param name [String] + # @param created_at [DateTime] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::RolePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, name: nil, created_at: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "name": name, "created_at": created_at, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/roles" +end + Monite::RolePaginationResponse.from_json(json_object: response.body) + end +# Create a new role from the specified values. + # + # @param name [String] Role name + # @param permissions [Hash] Access permissionsRequest of type Monite::BizObjectsSchemaInput, as a Hash + # * :objects (Array) + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.create(name: "name", permissions: { }) + def create(name:, permissions:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, permissions: permissions }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/roles" +end + Monite::RoleResponse.from_json(json_object: response.body) + end + # @param role_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.get_by_id(role_id: "role_id") + def get_by_id(role_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/roles/#{role_id}" +end + Monite::RoleResponse.from_json(json_object: response.body) + end +# Change the specified fields with the provided values. + # + # @param role_id [String] + # @param name [String] Role name + # @param permissions [Hash] Access permissionsRequest of type Monite::BizObjectsSchemaInput, as a Hash + # * :objects (Array) + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.update_by_id(role_id: "role_id") + def update_by_id(role_id:, name: nil, permissions: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, permissions: permissions }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/roles/#{role_id}" +end + Monite::RoleResponse.from_json(json_object: response.body) + end + end + class AsyncRolesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncRolesClient] + def initialize(request_client:) + @request_client = request_client + end +# Find all roles that match the search criteria. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::RoleCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param id_in [String] + # @param name [String] + # @param created_at [DateTime] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::RolePaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, id_in: nil, name: nil, created_at: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "id__in": id_in, "name": name, "created_at": created_at, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/roles" +end + Monite::RolePaginationResponse.from_json(json_object: response.body) + end + end +# Create a new role from the specified values. + # + # @param name [String] Role name + # @param permissions [Hash] Access permissionsRequest of type Monite::BizObjectsSchemaInput, as a Hash + # * :objects (Array) + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.create(name: "name", permissions: { }) + def create(name:, permissions:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, permissions: permissions }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/roles" +end + Monite::RoleResponse.from_json(json_object: response.body) + end + end + # @param role_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.get_by_id(role_id: "role_id") + def get_by_id(role_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/roles/#{role_id}" +end + Monite::RoleResponse.from_json(json_object: response.body) + end + end +# Change the specified fields with the provided values. + # + # @param role_id [String] + # @param name [String] Role name + # @param permissions [Hash] Access permissionsRequest of type Monite::BizObjectsSchemaInput, as a Hash + # * :objects (Array) + # @param request_options [Monite::RequestOptions] + # @return [Monite::RoleResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.roles.update_by_id(role_id: "role_id") + def update_by_id(role_id:, name: nil, permissions: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, permissions: permissions }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/roles/#{role_id}" +end + Monite::RoleResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/tags/client.rb b/lib/monite/tags/client.rb new file mode 100644 index 0000000..a9d6f86 --- /dev/null +++ b/lib/monite/tags/client.rb @@ -0,0 +1,470 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/tag_cursor_fields" +require_relative "../types/tags_pagination_response" +require_relative "../types/tag_category" +require_relative "../types/tag_read_schema" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class TagsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::TagsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get a list of all tags. Tags can be assigned to resources to assist with +# searching and filtering. +# Tags can also be used as trigger conditions in payable approval policies. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::TagCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_by_entity_user_id [String] + # @param name_in [String] + # @param id_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagsPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_by_entity_user_id: nil, name_in: nil, id_in: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_by_entity_user_id": created_by_entity_user_id, "name__in": name_in, "id__in": id_in }.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)}/tags" +end + Monite::TagsPaginationResponse.from_json(json_object: response.body) + end +# Create a new tag. The tag name must be unique. +# Tag names are case-sensitive, that is `Marketing` and `marketing` are two +# different tags. +# The response returns an auto-generated ID assigned to this tag. +# To assign this tag to a resource, send the tag ID in the `tag_ids` list when +# creating or updating a resource. + # + # @param category [Monite::TagCategory] The tag category. + # @param description [String] The tag description. + # @param name [String] The tag name. Must be unique. + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagReadSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.create(name: "Marketing") + def create(category: nil, description: nil, name:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), category: category, description: description, name: name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/tags" +end + Monite::TagReadSchema.from_json(json_object: response.body) + end +# Get information about a tag with the given ID. + # + # @param tag_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagReadSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.get_by_id(tag_id: "tag_id") + def get_by_id(tag_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/tags/#{tag_id}" +end + Monite::TagReadSchema.from_json(json_object: response.body) + end +# Delete a tag with the given ID. This tag will be automatically deleted from all +# resources where it was used. + # + # @param tag_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.delete_by_id(tag_id: "tag_id") + def delete_by_id(tag_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/tags/#{tag_id}" +end + end +# Change the tag name. The new name must be unique among existing tags. +# Tag names are case-sensitive, that is `Marketing` and `marketing` are two +# different tags. + # + # @param tag_id [String] + # @param category [Monite::TagCategory] The tag category. + # @param description [String] The tag description. + # @param name [String] The tag name. Must be unique. + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagReadSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.update_by_id(tag_id: "tag_id") + def update_by_id(tag_id:, category: nil, description: nil, name: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), category: category, description: description, name: name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/tags/#{tag_id}" +end + Monite::TagReadSchema.from_json(json_object: response.body) + end + end + class AsyncTagsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncTagsClient] + def initialize(request_client:) + @request_client = request_client + end +# Get a list of all tags. Tags can be assigned to resources to assist with +# searching and filtering. +# Tags can also be used as trigger conditions in payable approval policies. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::TagCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param created_by_entity_user_id [String] + # @param name_in [String] + # @param id_in [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagsPaginationResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, created_by_entity_user_id: nil, name_in: nil, id_in: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "created_by_entity_user_id": created_by_entity_user_id, "name__in": name_in, "id__in": id_in }.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)}/tags" +end + Monite::TagsPaginationResponse.from_json(json_object: response.body) + end + end +# Create a new tag. The tag name must be unique. +# Tag names are case-sensitive, that is `Marketing` and `marketing` are two +# different tags. +# The response returns an auto-generated ID assigned to this tag. +# To assign this tag to a resource, send the tag ID in the `tag_ids` list when +# creating or updating a resource. + # + # @param category [Monite::TagCategory] The tag category. + # @param description [String] The tag description. + # @param name [String] The tag name. Must be unique. + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagReadSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.create(name: "Marketing") + def create(category: nil, description: nil, name:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), category: category, description: description, name: name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/tags" +end + Monite::TagReadSchema.from_json(json_object: response.body) + end + end +# Get information about a tag with the given ID. + # + # @param tag_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagReadSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.get_by_id(tag_id: "tag_id") + def get_by_id(tag_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/tags/#{tag_id}" +end + Monite::TagReadSchema.from_json(json_object: response.body) + end + end +# Delete a tag with the given ID. This tag will be automatically deleted from all +# resources where it was used. + # + # @param tag_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.delete_by_id(tag_id: "tag_id") + def delete_by_id(tag_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/tags/#{tag_id}" +end + end + end +# Change the tag name. The new name must be unique among existing tags. +# Tag names are case-sensitive, that is `Marketing` and `marketing` are two +# different tags. + # + # @param tag_id [String] + # @param category [Monite::TagCategory] The tag category. + # @param description [String] The tag description. + # @param name [String] The tag name. Must be unique. + # @param request_options [Monite::RequestOptions] + # @return [Monite::TagReadSchema] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.tags.update_by_id(tag_id: "tag_id") + def update_by_id(tag_id:, category: nil, description: nil, name: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), category: category, description: description, name: name }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/tags/#{tag_id}" +end + Monite::TagReadSchema.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/text_templates/client.rb b/lib/monite/text_templates/client.rb new file mode 100644 index 0000000..621e0e1 --- /dev/null +++ b/lib/monite/text_templates/client.rb @@ -0,0 +1,516 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/text_template_type" +require_relative "../types/document_type_enum" +require_relative "../types/text_template_response_list" +require_relative "../types/text_template_response" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class TextTemplatesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::TextTemplatesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get text templates + # + # @param type [Monite::TextTemplateType] + # @param document_type [Monite::DocumentTypeEnum] + # @param is_default [Boolean] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponseList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.get + def get(type: nil, document_type: nil, is_default: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "type": type, "document_type": document_type, "is_default": is_default }.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)}/text_templates" +end + Monite::TextTemplateResponseList.from_json(json_object: response.body) + end +# Create a text template + # + # @param document_type [Monite::DocumentTypeEnum] + # @param name [String] + # @param template [String] + # @param type [Monite::TextTemplateType] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.create( +# document_type: QUOTE, +# name: "name", +# template: "template", +# type: EMAIL_HEADER +# ) + def create(document_type:, name:, template:, type:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), document_type: document_type, name: name, template: template, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/text_templates" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end +# Get all custom contents + # + # @param text_template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.get_by_id(text_template_id: "text_template_id") + def get_by_id(text_template_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/text_templates/#{text_template_id}" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end +# Delete custom content by ID + # + # @param text_template_id [String] UUID text_template ID + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.delete_by_id(text_template_id: "text_template_id") + def delete_by_id(text_template_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/text_templates/#{text_template_id}" +end + end +# Update custom content by ID + # + # @param text_template_id [String] UUID text_template ID + # @param name [String] + # @param template [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.update_by_id(text_template_id: "text_template_id") + def update_by_id(text_template_id:, name: nil, template: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, template: template }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/text_templates/#{text_template_id}" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end +# Make text template default + # + # @param text_template_id [String] UUID text_template ID + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.make_default_by_id(text_template_id: "text_template_id") + def make_default_by_id(text_template_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/text_templates/#{text_template_id}/make_default" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end + end + class AsyncTextTemplatesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncTextTemplatesClient] + def initialize(request_client:) + @request_client = request_client + end +# Get text templates + # + # @param type [Monite::TextTemplateType] + # @param document_type [Monite::DocumentTypeEnum] + # @param is_default [Boolean] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponseList] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.get + def get(type: nil, document_type: nil, is_default: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "type": type, "document_type": document_type, "is_default": is_default }.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)}/text_templates" +end + Monite::TextTemplateResponseList.from_json(json_object: response.body) + end + end +# Create a text template + # + # @param document_type [Monite::DocumentTypeEnum] + # @param name [String] + # @param template [String] + # @param type [Monite::TextTemplateType] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.create( +# document_type: QUOTE, +# name: "name", +# template: "template", +# type: EMAIL_HEADER +# ) + def create(document_type:, name:, template:, type:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), document_type: document_type, name: name, template: template, type: type }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/text_templates" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end + end +# Get all custom contents + # + # @param text_template_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.get_by_id(text_template_id: "text_template_id") + def get_by_id(text_template_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/text_templates/#{text_template_id}" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end + end +# Delete custom content by ID + # + # @param text_template_id [String] UUID text_template ID + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.delete_by_id(text_template_id: "text_template_id") + def delete_by_id(text_template_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/text_templates/#{text_template_id}" +end + end + end +# Update custom content by ID + # + # @param text_template_id [String] UUID text_template ID + # @param name [String] + # @param template [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.update_by_id(text_template_id: "text_template_id") + def update_by_id(text_template_id:, name: nil, template: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), name: name, template: template }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/text_templates/#{text_template_id}" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end + end +# Make text template default + # + # @param text_template_id [String] UUID text_template ID + # @param request_options [Monite::RequestOptions] + # @return [Monite::TextTemplateResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.text_templates.make_default_by_id(text_template_id: "text_template_id") + def make_default_by_id(text_template_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/text_templates/#{text_template_id}/make_default" +end + Monite::TextTemplateResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/types/access_token_response.rb b/lib/monite/types/access_token_response.rb new file mode 100644 index 0000000..c3d548f --- /dev/null +++ b/lib/monite/types/access_token_response.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AccessTokenResponse + # @return [String] + attr_reader :access_token + # @return [Integer] + attr_reader :expires_in + # @return [String] + attr_reader :token_type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param access_token [String] + # @param expires_in [Integer] + # @param token_type [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccessTokenResponse] + def initialize(access_token:, expires_in:, token_type:, additional_properties: nil) + @access_token = access_token + @expires_in = expires_in + @token_type = token_type + @additional_properties = additional_properties + @_field_set = { "access_token": access_token, "expires_in": expires_in, "token_type": token_type } + end +# Deserialize a JSON object to an instance of AccessTokenResponse + # + # @param json_object [String] + # @return [Monite::AccessTokenResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + access_token = parsed_json["access_token"] + expires_in = parsed_json["expires_in"] + token_type = parsed_json["token_type"] + new( + access_token: access_token, + expires_in: expires_in, + token_type: token_type, + additional_properties: struct + ) + end +# Serialize an instance of AccessTokenResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.access_token.is_a?(String) != false || raise("Passed value for field obj.access_token is not the expected type, validation failed.") + obj.expires_in.is_a?(Integer) != false || raise("Passed value for field obj.expires_in is not the expected type, validation failed.") + obj.token_type.is_a?(String) != false || raise("Passed value for field obj.token_type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/account_disabled_reason.rb b/lib/monite/types/account_disabled_reason.rb new file mode 100644 index 0000000..925b8bf --- /dev/null +++ b/lib/monite/types/account_disabled_reason.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Monite + class AccountDisabledReason + + REQUIREMENTS_PAST_DUE = "requirements.past_due" + REQUIREMENTS_PENDING_VERIFICATION = "requirements.pending_verification" + LISTED = "listed" + PLATFORM_PAUSED = "platform_paused" + REJECTED_FRAUD = "rejected.fraud" + REJECTED_LISTED = "rejected.listed" + REJECTED_TERMS_OF_SERVICE = "rejected.terms_of_service" + REJECTED_OTHER = "rejected.other" + UNDER_REVIEW = "under_review" + OTHER = "other" + + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_connection_list.rb b/lib/monite/types/accounting_connection_list.rb new file mode 100644 index 0000000..78db40e --- /dev/null +++ b/lib/monite/types/accounting_connection_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "accounting_connection_response" +require "ostruct" +require "json" + +module Monite + class AccountingConnectionList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingConnectionList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of AccountingConnectionList + # + # @param json_object [String] + # @return [Monite::AccountingConnectionList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::AccountingConnectionResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of AccountingConnectionList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_connection_response.rb b/lib/monite/types/accounting_connection_response.rb new file mode 100644 index 0000000..ada3b94 --- /dev/null +++ b/lib/monite/types/accounting_connection_response.rb @@ -0,0 +1,125 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "error_schema" +require "date" +require_relative "connection_status" +require "ostruct" +require "json" + +module Monite + class AccountingConnectionResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :connection_url + # @return [Array] + attr_reader :errors + # @return [DateTime] + attr_reader :last_pull + # @return [String] + attr_reader :platform + # @return [Monite::ConnectionStatus] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param connection_url [String] + # @param errors [Array] + # @param last_pull [DateTime] + # @param platform [String] + # @param status [Monite::ConnectionStatus] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingConnectionResponse] + def initialize(id:, created_at:, updated_at:, connection_url:, errors: OMIT, last_pull: OMIT, platform: OMIT, status: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @connection_url = connection_url + @errors = errors if errors != OMIT + @last_pull = last_pull if last_pull != OMIT + @platform = platform if platform != OMIT + @status = status if status != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "connection_url": connection_url, "errors": errors, "last_pull": last_pull, "platform": platform, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingConnectionResponse + # + # @param json_object [String] + # @return [Monite::AccountingConnectionResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + connection_url = parsed_json["connection_url"] + errors = parsed_json["errors"]&.map do | item | + item = item.to_json + Monite::ErrorSchema.from_json(json_object: item) +end + last_pull = unless parsed_json["last_pull"].nil? + DateTime.parse(parsed_json["last_pull"]) +else + nil +end + platform = parsed_json["platform"] + status = parsed_json["status"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + connection_url: connection_url, + errors: errors, + last_pull: last_pull, + platform: platform, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of AccountingConnectionResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.connection_url.is_a?(String) != false || raise("Passed value for field obj.connection_url is not the expected type, validation failed.") + obj.errors&.is_a?(Array) != false || raise("Passed value for field obj.errors is not the expected type, validation failed.") + obj.last_pull&.is_a?(DateTime) != false || raise("Passed value for field obj.last_pull is not the expected type, validation failed.") + obj.platform&.is_a?(String) != false || raise("Passed value for field obj.platform is not the expected type, validation failed.") + obj.status&.is_a?(Monite::ConnectionStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_customer_ref_object.rb b/lib/monite/types/accounting_customer_ref_object.rb new file mode 100644 index 0000000..d49c4bd --- /dev/null +++ b/lib/monite/types/accounting_customer_ref_object.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AccountingCustomerRefObject + # @return [String] A unique identifier of the customer in the accounting system. + attr_reader :id + # @return [String] Customer name in the accounting system. + attr_reader :company_name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique identifier of the customer in the accounting system. + # @param company_name [String] Customer name in the accounting system. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingCustomerRefObject] + def initialize(id:, company_name: OMIT, additional_properties: nil) + @id = id + @company_name = company_name if company_name != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "company_name": company_name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingCustomerRefObject + # + # @param json_object [String] + # @return [Monite::AccountingCustomerRefObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + company_name = parsed_json["company_name"] + new( + id: id, + company_name: company_name, + additional_properties: struct + ) + end +# Serialize an instance of AccountingCustomerRefObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.company_name&.is_a?(String) != false || raise("Passed value for field obj.company_name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_line_item.rb b/lib/monite/types/accounting_line_item.rb new file mode 100644 index 0000000..1a91c8a --- /dev/null +++ b/lib/monite/types/accounting_line_item.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true +require_relative "accounting_ref_object" +require "ostruct" +require "json" + +module Monite +# Contains the details of an invoice line item retrieved from an accounting +# system. + class AccountingLineItem + # @return [String] The name or description of the product or service being invoiced. + attr_reader :description + # @return [Float] Discount amount for this line item (if any). + attr_reader :discount_amount + # @return [Float] Discount percentage for this line item (if any). + attr_reader :discount_percentage + # @return [String] ID of the ledger account associated with this line item. You can use `GET +# /ledger_accounts/{ledger_account_id}` to get further details about this ledger +# account. + attr_reader :ledger_account_id + # @return [Float] The quantity of the product or service. + attr_reader :quantity + # @return [Monite::AccountingRefObject] An internal reference to the tax rate in the accounting system that the line +# item is linked to. + attr_reader :tax_rate_ref + # @return [Float] The cost per unit of the product or service. + attr_reader :unit_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] The name or description of the product or service being invoiced. + # @param discount_amount [Float] Discount amount for this line item (if any). + # @param discount_percentage [Float] Discount percentage for this line item (if any). + # @param ledger_account_id [String] ID of the ledger account associated with this line item. You can use `GET +# /ledger_accounts/{ledger_account_id}` to get further details about this ledger +# account. + # @param quantity [Float] The quantity of the product or service. + # @param tax_rate_ref [Monite::AccountingRefObject] An internal reference to the tax rate in the accounting system that the line +# item is linked to. + # @param unit_amount [Float] The cost per unit of the product or service. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingLineItem] + def initialize(description: OMIT, discount_amount: OMIT, discount_percentage: OMIT, ledger_account_id: OMIT, quantity: OMIT, tax_rate_ref: OMIT, unit_amount: OMIT, additional_properties: nil) + @description = description if description != OMIT + @discount_amount = discount_amount if discount_amount != OMIT + @discount_percentage = discount_percentage if discount_percentage != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @quantity = quantity if quantity != OMIT + @tax_rate_ref = tax_rate_ref if tax_rate_ref != OMIT + @unit_amount = unit_amount if unit_amount != OMIT + @additional_properties = additional_properties + @_field_set = { "description": description, "discount_amount": discount_amount, "discount_percentage": discount_percentage, "ledger_account_id": ledger_account_id, "quantity": quantity, "tax_rate_ref": tax_rate_ref, "unit_amount": unit_amount }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingLineItem + # + # @param json_object [String] + # @return [Monite::AccountingLineItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + discount_amount = parsed_json["discount_amount"] + discount_percentage = parsed_json["discount_percentage"] + ledger_account_id = parsed_json["ledger_account_id"] + quantity = parsed_json["quantity"] + unless parsed_json["tax_rate_ref"].nil? + tax_rate_ref = parsed_json["tax_rate_ref"].to_json + tax_rate_ref = Monite::AccountingRefObject.from_json(json_object: tax_rate_ref) + else + tax_rate_ref = nil + end + unit_amount = parsed_json["unit_amount"] + new( + description: description, + discount_amount: discount_amount, + discount_percentage: discount_percentage, + ledger_account_id: ledger_account_id, + quantity: quantity, + tax_rate_ref: tax_rate_ref, + unit_amount: unit_amount, + additional_properties: struct + ) + end +# Serialize an instance of AccountingLineItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.discount_amount&.is_a?(Float) != false || raise("Passed value for field obj.discount_amount is not the expected type, validation failed.") + obj.discount_percentage&.is_a?(Float) != false || raise("Passed value for field obj.discount_percentage is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.tax_rate_ref.nil? || Monite::AccountingRefObject.validate_raw(obj: obj.tax_rate_ref) + obj.unit_amount&.is_a?(Float) != false || raise("Passed value for field obj.unit_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_message_response.rb b/lib/monite/types/accounting_message_response.rb new file mode 100644 index 0000000..05b9b1d --- /dev/null +++ b/lib/monite/types/accounting_message_response.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AccountingMessageResponse + # @return [String] + attr_reader :message + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param message [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingMessageResponse] + def initialize(message:, additional_properties: nil) + @message = message + @additional_properties = additional_properties + @_field_set = { "message": message } + end +# Deserialize a JSON object to an instance of AccountingMessageResponse + # + # @param json_object [String] + # @return [Monite::AccountingMessageResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + message = parsed_json["message"] + new(message: message, additional_properties: struct) + end +# Serialize an instance of AccountingMessageResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_payable.rb b/lib/monite/types/accounting_payable.rb new file mode 100644 index 0000000..ac01808 --- /dev/null +++ b/lib/monite/types/accounting_payable.rb @@ -0,0 +1,182 @@ +# frozen_string_literal: true +require_relative "accounting_payable_due_date" +require_relative "accounting_line_item" +require_relative "accounting_purchase_order_ref" +require_relative "accounting_vendor_ref_object" +require "ostruct" +require "json" + +module Monite +# Details of an accounts payable invoice (bill) retrieved from an accounting +# system. + class AccountingPayable + # @return [String] An internal identifier of the payable in the accounting system. + attr_reader :id + # @return [Float] Remaining amount to be paid. + attr_reader :amount_due + # @return [String] ISO-4217 currency code of the payable. + attr_reader :currency + # @return [Float] Rate to convert the total amount of the transaction into the entity's base +# currency at the time of the transaction. + attr_reader :currency_rate + # @return [Monite::AccountingPayableDueDate] The payable's due date. + attr_reader :due_date + # @return [String] Invoice number of the payable. + attr_reader :invoice_number + # @return [Array] + attr_reader :lines + # @return [String] Any additional information or business notes about the payable. + attr_reader :memo + # @return [String] Date when the payable was added to the accounting service. This may differ from +# the payable creation date. + attr_reader :posted_date + # @return [Array] A list of purchase orders linked to the payable, if any. + attr_reader :purchase_order_refs + # @return [String] The status of the payable in the accounting system. Possible values: `open`, +# `draft`, `partially_paid`, `paid`, `unknown`, `void`. + attr_reader :status + # @return [Float] Amount payable, including discounts but excluding VAT/taxes. + attr_reader :subtotal + # @return [Float] Total VAT or tax amount. + attr_reader :tax_amount + # @return [Float] The total amount payable, including discounts and VAT/taxes. + attr_reader :total_amount + # @return [Monite::AccountingVendorRefObject] Information about the vendor from whom the payable was received. + attr_reader :vendor_ref + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] An internal identifier of the payable in the accounting system. + # @param amount_due [Float] Remaining amount to be paid. + # @param currency [String] ISO-4217 currency code of the payable. + # @param currency_rate [Float] Rate to convert the total amount of the transaction into the entity's base +# currency at the time of the transaction. + # @param due_date [Monite::AccountingPayableDueDate] The payable's due date. + # @param invoice_number [String] Invoice number of the payable. + # @param lines [Array] + # @param memo [String] Any additional information or business notes about the payable. + # @param posted_date [String] Date when the payable was added to the accounting service. This may differ from +# the payable creation date. + # @param purchase_order_refs [Array] A list of purchase orders linked to the payable, if any. + # @param status [String] The status of the payable in the accounting system. Possible values: `open`, +# `draft`, `partially_paid`, `paid`, `unknown`, `void`. + # @param subtotal [Float] Amount payable, including discounts but excluding VAT/taxes. + # @param tax_amount [Float] Total VAT or tax amount. + # @param total_amount [Float] The total amount payable, including discounts and VAT/taxes. + # @param vendor_ref [Monite::AccountingVendorRefObject] Information about the vendor from whom the payable was received. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingPayable] + def initialize(id:, amount_due: OMIT, currency: OMIT, currency_rate: OMIT, due_date: OMIT, invoice_number: OMIT, lines: OMIT, memo: OMIT, posted_date: OMIT, purchase_order_refs: OMIT, status:, subtotal: OMIT, tax_amount: OMIT, total_amount:, vendor_ref: OMIT, additional_properties: nil) + @id = id + @amount_due = amount_due if amount_due != OMIT + @currency = currency if currency != OMIT + @currency_rate = currency_rate if currency_rate != OMIT + @due_date = due_date if due_date != OMIT + @invoice_number = invoice_number if invoice_number != OMIT + @lines = lines if lines != OMIT + @memo = memo if memo != OMIT + @posted_date = posted_date if posted_date != OMIT + @purchase_order_refs = purchase_order_refs if purchase_order_refs != OMIT + @status = status + @subtotal = subtotal if subtotal != OMIT + @tax_amount = tax_amount if tax_amount != OMIT + @total_amount = total_amount + @vendor_ref = vendor_ref if vendor_ref != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "amount_due": amount_due, "currency": currency, "currency_rate": currency_rate, "due_date": due_date, "invoice_number": invoice_number, "lines": lines, "memo": memo, "posted_date": posted_date, "purchase_order_refs": purchase_order_refs, "status": status, "subtotal": subtotal, "tax_amount": tax_amount, "total_amount": total_amount, "vendor_ref": vendor_ref }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingPayable + # + # @param json_object [String] + # @return [Monite::AccountingPayable] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + amount_due = parsed_json["amount_due"] + currency = parsed_json["currency"] + currency_rate = parsed_json["currency_rate"] + unless parsed_json["due_date"].nil? + due_date = parsed_json["due_date"].to_json + due_date = Monite::AccountingPayableDueDate.from_json(json_object: due_date) + else + due_date = nil + end + invoice_number = parsed_json["invoice_number"] + lines = parsed_json["lines"]&.map do | item | + item = item.to_json + Monite::AccountingLineItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + posted_date = parsed_json["posted_date"] + purchase_order_refs = parsed_json["purchase_order_refs"]&.map do | item | + item = item.to_json + Monite::AccountingPurchaseOrderRef.from_json(json_object: item) +end + status = parsed_json["status"] + subtotal = parsed_json["subtotal"] + tax_amount = parsed_json["tax_amount"] + total_amount = parsed_json["total_amount"] + unless parsed_json["vendor_ref"].nil? + vendor_ref = parsed_json["vendor_ref"].to_json + vendor_ref = Monite::AccountingVendorRefObject.from_json(json_object: vendor_ref) + else + vendor_ref = nil + end + new( + id: id, + amount_due: amount_due, + currency: currency, + currency_rate: currency_rate, + due_date: due_date, + invoice_number: invoice_number, + lines: lines, + memo: memo, + posted_date: posted_date, + purchase_order_refs: purchase_order_refs, + status: status, + subtotal: subtotal, + tax_amount: tax_amount, + total_amount: total_amount, + vendor_ref: vendor_ref, + additional_properties: struct + ) + end +# Serialize an instance of AccountingPayable to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.amount_due&.is_a?(Float) != false || raise("Passed value for field obj.amount_due is not the expected type, validation failed.") + obj.currency&.is_a?(String) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.currency_rate&.is_a?(Float) != false || raise("Passed value for field obj.currency_rate is not the expected type, validation failed.") + obj.due_date.nil? || Monite::AccountingPayableDueDate.validate_raw(obj: obj.due_date) + obj.invoice_number&.is_a?(String) != false || raise("Passed value for field obj.invoice_number is not the expected type, validation failed.") + obj.lines&.is_a?(Array) != false || raise("Passed value for field obj.lines is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.posted_date&.is_a?(String) != false || raise("Passed value for field obj.posted_date is not the expected type, validation failed.") + obj.purchase_order_refs&.is_a?(Array) != false || raise("Passed value for field obj.purchase_order_refs is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtotal&.is_a?(Float) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tax_amount&.is_a?(Float) != false || raise("Passed value for field obj.tax_amount is not the expected type, validation failed.") + obj.total_amount.is_a?(Float) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.vendor_ref.nil? || Monite::AccountingVendorRefObject.validate_raw(obj: obj.vendor_ref) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_payable_due_date.rb b/lib/monite/types/accounting_payable_due_date.rb new file mode 100644 index 0000000..4cac251 --- /dev/null +++ b/lib/monite/types/accounting_payable_due_date.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require "json" +require "date" + +module Monite +# The payable's due date. + class AccountingPayableDueDate + + +# Deserialize a JSON object to an instance of AccountingPayableDueDate + # + # @param json_object [String] + # @return [Monite::AccountingPayableDueDate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(DateTime) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return unless struct.nil? + DateTime.parse(struct) +else + nil +end +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(DateTime) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_payable_list.rb b/lib/monite/types/accounting_payable_list.rb new file mode 100644 index 0000000..7171a77 --- /dev/null +++ b/lib/monite/types/accounting_payable_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "accounting_payable" +require "ostruct" +require "json" + +module Monite + class AccountingPayableList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingPayableList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of AccountingPayableList + # + # @param json_object [String] + # @return [Monite::AccountingPayableList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::AccountingPayable.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of AccountingPayableList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_purchase_order_ref.rb b/lib/monite/types/accounting_purchase_order_ref.rb new file mode 100644 index 0000000..87804bb --- /dev/null +++ b/lib/monite/types/accounting_purchase_order_ref.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AccountingPurchaseOrderRef + # @return [String] An internal ID of the purchase order in the accounting system. + attr_reader :id + # @return [String] Reference number of the purchase order. + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] An internal ID of the purchase order in the accounting system. + # @param name [String] Reference number of the purchase order. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingPurchaseOrderRef] + def initialize(id:, name: OMIT, additional_properties: nil) + @id = id + @name = name if name != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingPurchaseOrderRef + # + # @param json_object [String] + # @return [Monite::AccountingPurchaseOrderRef] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + name = parsed_json["name"] + new( + id: id, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of AccountingPurchaseOrderRef to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_receivable.rb b/lib/monite/types/accounting_receivable.rb new file mode 100644 index 0000000..e3fbb95 --- /dev/null +++ b/lib/monite/types/accounting_receivable.rb @@ -0,0 +1,142 @@ +# frozen_string_literal: true +require_relative "accounting_customer_ref_object" +require_relative "accounting_receivable_due_date" +require_relative "accounting_line_item" +require "ostruct" +require "json" + +module Monite +# Invoice details retrieved from an accounting system. + class AccountingReceivable + # @return [String] An internal identifier of the invoice in the accounting system. + attr_reader :id + # @return [String] ISO-4217 currency code of the invoice. + attr_reader :currency + # @return [Float] Rate to convert the total amount of the transaction into the entity's base +# currency at the time of the transaction. + attr_reader :currency_rate + # @return [Monite::AccountingCustomerRefObject] Information about the customer that the invoice was sent to. + attr_reader :customer_ref + # @return [Monite::AccountingReceivableDueDate] Invoice due date. + attr_reader :due_date + # @return [String] Invoice document number. + attr_reader :invoice_number + # @return [Array] + attr_reader :lines + # @return [String] Any additional information or business notes about the invoice. + attr_reader :memo + # @return [Hash{String => Object}] An object containing additional invoice data returned by the accounting system. +# This sometimes includes custom invoice fields. + attr_reader :pass_through + # @return [String] Date when the invoice was added to the accounting service. This may differ from +# the invoice creation date. + attr_reader :posted_date + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] An internal identifier of the invoice in the accounting system. + # @param currency [String] ISO-4217 currency code of the invoice. + # @param currency_rate [Float] Rate to convert the total amount of the transaction into the entity's base +# currency at the time of the transaction. + # @param customer_ref [Monite::AccountingCustomerRefObject] Information about the customer that the invoice was sent to. + # @param due_date [Monite::AccountingReceivableDueDate] Invoice due date. + # @param invoice_number [String] Invoice document number. + # @param lines [Array] + # @param memo [String] Any additional information or business notes about the invoice. + # @param pass_through [Hash{String => Object}] An object containing additional invoice data returned by the accounting system. +# This sometimes includes custom invoice fields. + # @param posted_date [String] Date when the invoice was added to the accounting service. This may differ from +# the invoice creation date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingReceivable] + def initialize(id: OMIT, currency: OMIT, currency_rate: OMIT, customer_ref: OMIT, due_date: OMIT, invoice_number: OMIT, lines: OMIT, memo: OMIT, pass_through: OMIT, posted_date: OMIT, additional_properties: nil) + @id = id if id != OMIT + @currency = currency if currency != OMIT + @currency_rate = currency_rate if currency_rate != OMIT + @customer_ref = customer_ref if customer_ref != OMIT + @due_date = due_date if due_date != OMIT + @invoice_number = invoice_number if invoice_number != OMIT + @lines = lines if lines != OMIT + @memo = memo if memo != OMIT + @pass_through = pass_through if pass_through != OMIT + @posted_date = posted_date if posted_date != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "currency": currency, "currency_rate": currency_rate, "customer_ref": customer_ref, "due_date": due_date, "invoice_number": invoice_number, "lines": lines, "memo": memo, "pass_through": pass_through, "posted_date": posted_date }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingReceivable + # + # @param json_object [String] + # @return [Monite::AccountingReceivable] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + currency = parsed_json["currency"] + currency_rate = parsed_json["currency_rate"] + unless parsed_json["customer_ref"].nil? + customer_ref = parsed_json["customer_ref"].to_json + customer_ref = Monite::AccountingCustomerRefObject.from_json(json_object: customer_ref) + else + customer_ref = nil + end + unless parsed_json["due_date"].nil? + due_date = parsed_json["due_date"].to_json + due_date = Monite::AccountingReceivableDueDate.from_json(json_object: due_date) + else + due_date = nil + end + invoice_number = parsed_json["invoice_number"] + lines = parsed_json["lines"]&.map do | item | + item = item.to_json + Monite::AccountingLineItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + pass_through = parsed_json["pass_through"] + posted_date = parsed_json["posted_date"] + new( + id: id, + currency: currency, + currency_rate: currency_rate, + customer_ref: customer_ref, + due_date: due_date, + invoice_number: invoice_number, + lines: lines, + memo: memo, + pass_through: pass_through, + posted_date: posted_date, + additional_properties: struct + ) + end +# Serialize an instance of AccountingReceivable to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.currency&.is_a?(String) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.currency_rate&.is_a?(Float) != false || raise("Passed value for field obj.currency_rate is not the expected type, validation failed.") + obj.customer_ref.nil? || Monite::AccountingCustomerRefObject.validate_raw(obj: obj.customer_ref) + obj.due_date.nil? || Monite::AccountingReceivableDueDate.validate_raw(obj: obj.due_date) + obj.invoice_number&.is_a?(String) != false || raise("Passed value for field obj.invoice_number is not the expected type, validation failed.") + obj.lines&.is_a?(Array) != false || raise("Passed value for field obj.lines is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.pass_through&.is_a?(Hash) != false || raise("Passed value for field obj.pass_through is not the expected type, validation failed.") + obj.posted_date&.is_a?(String) != false || raise("Passed value for field obj.posted_date is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_receivable_due_date.rb b/lib/monite/types/accounting_receivable_due_date.rb new file mode 100644 index 0000000..627652c --- /dev/null +++ b/lib/monite/types/accounting_receivable_due_date.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require "json" +require "date" + +module Monite +# Invoice due date. + class AccountingReceivableDueDate + + +# Deserialize a JSON object to an instance of AccountingReceivableDueDate + # + # @param json_object [String] + # @return [Monite::AccountingReceivableDueDate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(DateTime) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return unless struct.nil? + DateTime.parse(struct) +else + nil +end +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(DateTime) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_receivable_list.rb b/lib/monite/types/accounting_receivable_list.rb new file mode 100644 index 0000000..1c60e26 --- /dev/null +++ b/lib/monite/types/accounting_receivable_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "accounting_receivable" +require "ostruct" +require "json" + +module Monite + class AccountingReceivableList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingReceivableList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of AccountingReceivableList + # + # @param json_object [String] + # @return [Monite::AccountingReceivableList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::AccountingReceivable.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of AccountingReceivableList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_ref_object.rb b/lib/monite/types/accounting_ref_object.rb new file mode 100644 index 0000000..8982a1d --- /dev/null +++ b/lib/monite/types/accounting_ref_object.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AccountingRefObject + # @return [String] An internal ID of the tax rate in the accounting system. + attr_reader :id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] An internal ID of the tax rate in the accounting system. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingRefObject] + def initialize(id: OMIT, additional_properties: nil) + @id = id if id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingRefObject + # + # @param json_object [String] + # @return [Monite::AccountingRefObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + new(id: id, additional_properties: struct) + end +# Serialize an instance of AccountingRefObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_settings.rb b/lib/monite/types/accounting_settings.rb new file mode 100644 index 0000000..918bec9 --- /dev/null +++ b/lib/monite/types/accounting_settings.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require_relative "default_ledger_account_i_ds" +require "ostruct" +require "json" + +module Monite + class AccountingSettings + # @return [Monite::DefaultLedgerAccountIDs] Default ledger accounts that will be used for various objects pushed into an +# accounting system. Use `GET /ledger_accounts` to get the IDs of these ledger +# accounts. + attr_reader :ledger_account_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param ledger_account_ids [Monite::DefaultLedgerAccountIDs] Default ledger accounts that will be used for various objects pushed into an +# accounting system. Use `GET /ledger_accounts` to get the IDs of these ledger +# accounts. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingSettings] + def initialize(ledger_account_ids: OMIT, additional_properties: nil) + @ledger_account_ids = ledger_account_ids if ledger_account_ids != OMIT + @additional_properties = additional_properties + @_field_set = { "ledger_account_ids": ledger_account_ids }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingSettings + # + # @param json_object [String] + # @return [Monite::AccountingSettings] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["ledger_account_ids"].nil? + ledger_account_ids = parsed_json["ledger_account_ids"].to_json + ledger_account_ids = Monite::DefaultLedgerAccountIDs.from_json(json_object: ledger_account_ids) + else + ledger_account_ids = nil + end + new(ledger_account_ids: ledger_account_ids, additional_properties: struct) + end +# Serialize an instance of AccountingSettings to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.ledger_account_ids.nil? || Monite::DefaultLedgerAccountIDs.validate_raw(obj: obj.ledger_account_ids) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_tax_rate_list_response.rb b/lib/monite/types/accounting_tax_rate_list_response.rb new file mode 100644 index 0000000..7cfa06a --- /dev/null +++ b/lib/monite/types/accounting_tax_rate_list_response.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require_relative "accounting_tax_rate_response" +require "ostruct" +require "json" + +module Monite + class AccountingTaxRateListResponse + # @return [Array] + attr_reader :data + # @return [String] + attr_reader :next_pagination_token + # @return [String] + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] + # @param prev_pagination_token [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingTaxRateListResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingTaxRateListResponse + # + # @param json_object [String] + # @return [Monite::AccountingTaxRateListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::AccountingTaxRateResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of AccountingTaxRateListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_tax_rate_response.rb b/lib/monite/types/accounting_tax_rate_response.rb new file mode 100644 index 0000000..a068caa --- /dev/null +++ b/lib/monite/types/accounting_tax_rate_response.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true +require_relative "tax_component_response" +require "ostruct" +require "json" + +module Monite + class AccountingTaxRateResponse + # @return [String] + attr_reader :id + # @return [String] Code for the tax rate from the accounting platform. + attr_reader :code + # @return [Array] + attr_reader :components + # @return [Integer] Effective tax rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :effective_tax_rate + # @return [String] + attr_reader :name + # @return [String] + attr_reader :status + # @return [Integer] Total (not compounded) sum of the components of a tax rate in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :total_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param code [String] Code for the tax rate from the accounting platform. + # @param components [Array] + # @param effective_tax_rate [Integer] Effective tax rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param name [String] + # @param status [String] + # @param total_tax_rate [Integer] Total (not compounded) sum of the components of a tax rate in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingTaxRateResponse] + def initialize(id:, code: OMIT, components: OMIT, effective_tax_rate: OMIT, name: OMIT, status: OMIT, total_tax_rate: OMIT, additional_properties: nil) + @id = id + @code = code if code != OMIT + @components = components if components != OMIT + @effective_tax_rate = effective_tax_rate if effective_tax_rate != OMIT + @name = name if name != OMIT + @status = status if status != OMIT + @total_tax_rate = total_tax_rate if total_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "code": code, "components": components, "effective_tax_rate": effective_tax_rate, "name": name, "status": status, "total_tax_rate": total_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingTaxRateResponse + # + # @param json_object [String] + # @return [Monite::AccountingTaxRateResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + code = parsed_json["code"] + components = parsed_json["components"]&.map do | item | + item = item.to_json + Monite::TaxComponentResponse.from_json(json_object: item) +end + effective_tax_rate = parsed_json["effective_tax_rate"] + name = parsed_json["name"] + status = parsed_json["status"] + total_tax_rate = parsed_json["total_tax_rate"] + new( + id: id, + code: code, + components: components, + effective_tax_rate: effective_tax_rate, + name: name, + status: status, + total_tax_rate: total_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of AccountingTaxRateResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.code&.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") + obj.components&.is_a?(Array) != false || raise("Passed value for field obj.components is not the expected type, validation failed.") + obj.effective_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.effective_tax_rate is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.status&.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.total_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.total_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/accounting_vendor_ref_object.rb b/lib/monite/types/accounting_vendor_ref_object.rb new file mode 100644 index 0000000..4345f51 --- /dev/null +++ b/lib/monite/types/accounting_vendor_ref_object.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AccountingVendorRefObject + # @return [String] A unique identifier of the vendor in the accounting system. + attr_reader :id + # @return [String] Vendor name in the accounting system. + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique identifier of the vendor in the accounting system. + # @param name [String] Vendor name in the accounting system. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AccountingVendorRefObject] + def initialize(id:, name: OMIT, additional_properties: nil) + @id = id + @name = name if name != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AccountingVendorRefObject + # + # @param json_object [String] + # @return [Monite::AccountingVendorRefObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + name = parsed_json["name"] + new( + id: id, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of AccountingVendorRefObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/action_enum.rb b/lib/monite/types/action_enum.rb new file mode 100644 index 0000000..be23745 --- /dev/null +++ b/lib/monite/types/action_enum.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + class ActionEnum + + CREATE = "create" + READ = "read" + UPDATE = "update" + DELETE = "delete" + + end +end \ No newline at end of file diff --git a/lib/monite/types/action_schema.rb b/lib/monite/types/action_schema.rb new file mode 100644 index 0000000..a1b8876 --- /dev/null +++ b/lib/monite/types/action_schema.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true +require_relative "action_enum" +require_relative "permission_enum" +require "ostruct" +require "json" + +module Monite + class ActionSchema + # @return [Monite::ActionEnum] Action name + attr_reader :action_name + # @return [Monite::PermissionEnum] Permission type + attr_reader :permission + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param action_name [Monite::ActionEnum] Action name + # @param permission [Monite::PermissionEnum] Permission type + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ActionSchema] + def initialize(action_name: OMIT, permission: OMIT, additional_properties: nil) + @action_name = action_name if action_name != OMIT + @permission = permission if permission != OMIT + @additional_properties = additional_properties + @_field_set = { "action_name": action_name, "permission": permission }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ActionSchema + # + # @param json_object [String] + # @return [Monite::ActionSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + action_name = parsed_json["action_name"] + permission = parsed_json["permission"] + new( + action_name: action_name, + permission: permission, + additional_properties: struct + ) + end +# Serialize an instance of ActionSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.action_name&.is_a?(Monite::ActionEnum) != false || raise("Passed value for field obj.action_name is not the expected type, validation failed.") + obj.permission&.is_a?(Monite::PermissionEnum) != false || raise("Passed value for field obj.permission is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/aggregation_function_enum.rb b/lib/monite/types/aggregation_function_enum.rb new file mode 100644 index 0000000..7ba7e8a --- /dev/null +++ b/lib/monite/types/aggregation_function_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class AggregationFunctionEnum + + COUNT = "count" + AVERAGE = "average" + SUMMARY = "summary" + MIN = "min" + MAX = "max" + + end +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_mandate.rb b/lib/monite/types/airwallex_mandate.rb new file mode 100644 index 0000000..757e11f --- /dev/null +++ b/lib/monite/types/airwallex_mandate.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require_relative "airwallex_mandate_type" +require_relative "airwallex_mandate_version" +require "ostruct" +require "json" + +module Monite + class AirwallexMandate + # @return [String] PDF copy of mandate will be sent to the email by Airwallex + attr_reader :email + # @return [String] Name of the person signed the mandate, must be a bank account owner + attr_reader :signatory + # @return [Monite::AIRWALLEX_MANDATE_TYPE] + attr_reader :type + # @return [Monite::AIRWALLEX_MANDATE_VERSION] + attr_reader :version + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] PDF copy of mandate will be sent to the email by Airwallex + # @param signatory [String] Name of the person signed the mandate, must be a bank account owner + # @param type [Monite::AIRWALLEX_MANDATE_TYPE] + # @param version [Monite::AIRWALLEX_MANDATE_VERSION] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AirwallexMandate] + def initialize(email:, signatory:, type:, version:, additional_properties: nil) + @email = email + @signatory = signatory + @type = type + @version = version + @additional_properties = additional_properties + @_field_set = { "email": email, "signatory": signatory, "type": type, "version": version } + end +# Deserialize a JSON object to an instance of AirwallexMandate + # + # @param json_object [String] + # @return [Monite::AirwallexMandate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + signatory = parsed_json["signatory"] + type = parsed_json["type"] + version = parsed_json["version"] + new( + email: email, + signatory: signatory, + type: type, + version: version, + additional_properties: struct + ) + end +# Serialize an instance of AirwallexMandate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.signatory.is_a?(String) != false || raise("Passed value for field obj.signatory is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.version.is_a?(String) != false || raise("Passed value for field obj.version is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_mandate_type.rb b/lib/monite/types/airwallex_mandate_type.rb new file mode 100644 index 0000000..c78f0f5 --- /dev/null +++ b/lib/monite/types/airwallex_mandate_type.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + AIRWALLEX_MANDATE_TYPE = String +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_mandate_version.rb b/lib/monite/types/airwallex_mandate_version.rb new file mode 100644 index 0000000..3d5e76b --- /dev/null +++ b/lib/monite/types/airwallex_mandate_version.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + AIRWALLEX_MANDATE_VERSION = String +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_plaid_account.rb b/lib/monite/types/airwallex_plaid_account.rb new file mode 100644 index 0000000..47d1465 --- /dev/null +++ b/lib/monite/types/airwallex_plaid_account.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AirwallexPlaidAccount + # @return [String] Plaid`s unique identifier for the account + attr_reader :id + # @return [String] The last 2-4 alphanumeric characters of an account's official account number + attr_reader :mask + # @return [String] The name of the account, either assigned by the user or by the financial +# institution itself + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Plaid`s unique identifier for the account + # @param mask [String] The last 2-4 alphanumeric characters of an account's official account number + # @param name [String] The name of the account, either assigned by the user or by the financial +# institution itself + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AirwallexPlaidAccount] + def initialize(id:, mask:, name:, additional_properties: nil) + @id = id + @mask = mask + @name = name + @additional_properties = additional_properties + @_field_set = { "id": id, "mask": mask, "name": name } + end +# Deserialize a JSON object to an instance of AirwallexPlaidAccount + # + # @param json_object [String] + # @return [Monite::AirwallexPlaidAccount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + mask = parsed_json["mask"] + name = parsed_json["name"] + new( + id: id, + mask: mask, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of AirwallexPlaidAccount to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.mask.is_a?(String) != false || raise("Passed value for field obj.mask is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_plaid_bank_account_verification_status.rb b/lib/monite/types/airwallex_plaid_bank_account_verification_status.rb new file mode 100644 index 0000000..990a814 --- /dev/null +++ b/lib/monite/types/airwallex_plaid_bank_account_verification_status.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class AirwallexPlaidBankAccountVerificationStatus + + VERIFIED = "verified" + EXPIRED = "expired" + SUSPENDED = "suspended" + + end +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_plaid_institution.rb b/lib/monite/types/airwallex_plaid_institution.rb new file mode 100644 index 0000000..4677b4b --- /dev/null +++ b/lib/monite/types/airwallex_plaid_institution.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AirwallexPlaidInstitution + # @return [String] The institution identifier assigned by Plaid + attr_reader :id + # @return [String] The full financial institution name + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] The institution identifier assigned by Plaid + # @param name [String] The full financial institution name + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AirwallexPlaidInstitution] + def initialize(id:, name:, additional_properties: nil) + @id = id + @name = name + @additional_properties = additional_properties + @_field_set = { "id": id, "name": name } + end +# Deserialize a JSON object to an instance of AirwallexPlaidInstitution + # + # @param json_object [String] + # @return [Monite::AirwallexPlaidInstitution] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + name = parsed_json["name"] + new( + id: id, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of AirwallexPlaidInstitution to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/airwallex_plaid_verification.rb b/lib/monite/types/airwallex_plaid_verification.rb new file mode 100644 index 0000000..34718ac --- /dev/null +++ b/lib/monite/types/airwallex_plaid_verification.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +require_relative "airwallex_plaid_bank_account_verification_status" +require "ostruct" +require "json" + +module Monite + class AirwallexPlaidVerification + # @return [Monite::AirwallexPlaidBankAccountVerificationStatus] Status of the bank account verification + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param status [Monite::AirwallexPlaidBankAccountVerificationStatus] Status of the bank account verification + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AirwallexPlaidVerification] + def initialize(status:, additional_properties: nil) + @status = status + @additional_properties = additional_properties + @_field_set = { "status": status } + end +# Deserialize a JSON object to an instance of AirwallexPlaidVerification + # + # @param json_object [String] + # @return [Monite::AirwallexPlaidVerification] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + status = parsed_json["status"] + new(status: status, additional_properties: struct) + end +# Serialize an instance of AirwallexPlaidVerification to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.status.is_a?(Monite::AirwallexPlaidBankAccountVerificationStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/all_document_export_response_schema.rb b/lib/monite/types/all_document_export_response_schema.rb new file mode 100644 index 0000000..86f8296 --- /dev/null +++ b/lib/monite/types/all_document_export_response_schema.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "document_export_response_schema" +require "ostruct" +require "json" + +module Monite + class AllDocumentExportResponseSchema + # @return [Array] A set of export objects returned per page. + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results. If there is no next page, i.e. you have reached the last +# page, the value is `null`. + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results. If there is no previous page, i.e. you have reached +# the first page, the value is `null`. + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A set of export objects returned per page. + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results. If there is no next page, i.e. you have reached the last +# page, the value is `null`. + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results. If there is no previous page, i.e. you have reached +# the first page, the value is `null`. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AllDocumentExportResponseSchema] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AllDocumentExportResponseSchema + # + # @param json_object [String] + # @return [Monite::AllDocumentExportResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::DocumentExportResponseSchema.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of AllDocumentExportResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/all_overdue_reminders_response.rb b/lib/monite/types/all_overdue_reminders_response.rb new file mode 100644 index 0000000..2f803b0 --- /dev/null +++ b/lib/monite/types/all_overdue_reminders_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "overdue_reminder_response" +require "ostruct" +require "json" + +module Monite + class AllOverdueRemindersResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AllOverdueRemindersResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of AllOverdueRemindersResponse + # + # @param json_object [String] + # @return [Monite::AllOverdueRemindersResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::OverdueReminderResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of AllOverdueRemindersResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/allowed_countries.rb b/lib/monite/types/allowed_countries.rb new file mode 100644 index 0000000..fde64e1 --- /dev/null +++ b/lib/monite/types/allowed_countries.rb @@ -0,0 +1,260 @@ +# frozen_string_literal: true + +module Monite + class AllowedCountries + + AF = "AF" + AX = "AX" + AL = "AL" + DZ = "DZ" + AS = "AS" + AD = "AD" + AO = "AO" + AI = "AI" + AQ = "AQ" + AG = "AG" + AR = "AR" + AM = "AM" + AW = "AW" + AU = "AU" + AT = "AT" + AZ = "AZ" + BS = "BS" + BH = "BH" + BD = "BD" + BB = "BB" + BY = "BY" + BE = "BE" + BZ = "BZ" + BJ = "BJ" + BM = "BM" + BT = "BT" + BO = "BO" + BA = "BA" + BW = "BW" + BV = "BV" + BR = "BR" + IO = "IO" + BN = "BN" + BG = "BG" + BF = "BF" + BI = "BI" + KH = "KH" + CM = "CM" + CA = "CA" + IC = "IC" + CV = "CV" + KY = "KY" + CF = "CF" + EA = "EA" + TD = "TD" + CL = "CL" + CN = "CN" + CX = "CX" + CC = "CC" + CO = "CO" + KM = "KM" + CG = "CG" + CD = "CD" + CK = "CK" + CR = "CR" + CI = "CI" + HR = "HR" + CU = "CU" + CY = "CY" + CZ = "CZ" + DK = "DK" + DJ = "DJ" + DM = "DM" + DO = "DO" + EC = "EC" + EG = "EG" + SV = "SV" + GQ = "GQ" + ER = "ER" + EE = "EE" + SZ = "SZ" + ET = "ET" + FK = "FK" + FO = "FO" + FJ = "FJ" + FI = "FI" + FR = "FR" + GF = "GF" + PF = "PF" + TF = "TF" + GA = "GA" + GM = "GM" + GE = "GE" + DE = "DE" + GH = "GH" + GI = "GI" + GR = "GR" + GL = "GL" + GD = "GD" + GP = "GP" + GU = "GU" + GT = "GT" + GG = "GG" + GN = "GN" + GW = "GW" + GY = "GY" + HT = "HT" + HM = "HM" + VA = "VA" + HN = "HN" + HK = "HK" + HU = "HU" + IS = "IS" + IN = "IN" + ID = "ID" + IR = "IR" + IQ = "IQ" + IE = "IE" + IM = "IM" + IL = "IL" + IT = "IT" + JM = "JM" + JP = "JP" + JE = "JE" + JO = "JO" + KZ = "KZ" + KE = "KE" + KI = "KI" + KP = "KP" + KR = "KR" + KW = "KW" + KG = "KG" + LA = "LA" + LV = "LV" + LB = "LB" + LS = "LS" + LR = "LR" + LY = "LY" + LI = "LI" + LT = "LT" + LU = "LU" + MO = "MO" + MG = "MG" + MW = "MW" + MY = "MY" + MV = "MV" + ML = "ML" + MT = "MT" + MH = "MH" + MQ = "MQ" + MR = "MR" + MU = "MU" + YT = "YT" + MX = "MX" + FM = "FM" + MD = "MD" + MC = "MC" + MN = "MN" + ME = "ME" + MS = "MS" + MA = "MA" + MZ = "MZ" + MM = "MM" + NA = "NA" + NR = "NR" + NP = "NP" + NL = "NL" + AN = "AN" + NC = "NC" + NZ = "NZ" + NI = "NI" + NE = "NE" + NG = "NG" + NU = "NU" + NF = "NF" + MP = "MP" + MK = "MK" + NO = "NO" + OM = "OM" + PK = "PK" + PW = "PW" + PS = "PS" + PA = "PA" + PG = "PG" + PY = "PY" + PE = "PE" + PH = "PH" + PN = "PN" + PL = "PL" + PT = "PT" + PR = "PR" + QA = "QA" + RE = "RE" + RO = "RO" + RU = "RU" + RW = "RW" + SH = "SH" + KN = "KN" + LC = "LC" + PM = "PM" + VC = "VC" + WS = "WS" + SM = "SM" + ST = "ST" + SA = "SA" + SN = "SN" + RS = "RS" + SC = "SC" + SL = "SL" + SG = "SG" + SK = "SK" + SI = "SI" + SB = "SB" + SO = "SO" + ZA = "ZA" + SS = "SS" + GS = "GS" + ES = "ES" + LK = "LK" + SD = "SD" + SR = "SR" + SJ = "SJ" + SE = "SE" + CH = "CH" + SY = "SY" + TW = "TW" + TJ = "TJ" + TZ = "TZ" + TH = "TH" + TL = "TL" + TG = "TG" + TK = "TK" + TO = "TO" + TT = "TT" + TN = "TN" + TR = "TR" + TM = "TM" + TC = "TC" + TV = "TV" + UG = "UG" + UA = "UA" + AE = "AE" + GB = "GB" + US = "US" + UM = "UM" + UY = "UY" + UZ = "UZ" + VU = "VU" + VE = "VE" + VN = "VN" + VG = "VG" + VI = "VI" + WF = "WF" + EH = "EH" + YE = "YE" + ZM = "ZM" + ZW = "ZW" + BL = "BL" + BQ = "BQ" + CW = "CW" + MF = "MF" + SX = "SX" + + end +end \ No newline at end of file diff --git a/lib/monite/types/allowed_einvoicing_country_codes.rb b/lib/monite/types/allowed_einvoicing_country_codes.rb new file mode 100644 index 0000000..ecab2c3 --- /dev/null +++ b/lib/monite/types/allowed_einvoicing_country_codes.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class AllowedEinvoicingCountryCodes + + DE = "DE" + NL = "NL" + BE = "BE" + + end +end \ No newline at end of file diff --git a/lib/monite/types/allowed_file_types.rb b/lib/monite/types/allowed_file_types.rb new file mode 100644 index 0000000..222dc50 --- /dev/null +++ b/lib/monite/types/allowed_file_types.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Monite + class AllowedFileTypes + + OCR_RESULTS = "ocr_results" + OCR_FILES = "ocr_files" + PAYABLES = "payables" + RECEIVABLES = "receivables" + RECEIPTS = "receipts" + USERPICS = "userpics" + ENTITY_LOGO = "entity_logo" + COMPANIES_LOGO = "companies_logo" + ZIP = "zip" + IDENTITY_DOCUMENTS = "identity_documents" + ADDITIONAL_IDENTITY_DOCUMENTS = "additional_identity_documents" + RECEIVABLE_SIGNATURES = "receivable_signatures" + + end +end \ No newline at end of file diff --git a/lib/monite/types/analytics_data_point.rb b/lib/monite/types/analytics_data_point.rb new file mode 100644 index 0000000..ef2ebe5 --- /dev/null +++ b/lib/monite/types/analytics_data_point.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class AnalyticsDataPoint + # @return [String] + attr_reader :dimension_value + # @return [Integer] + attr_reader :metric_value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param dimension_value [String] + # @param metric_value [Integer] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::AnalyticsDataPoint] + def initialize(dimension_value: OMIT, metric_value:, additional_properties: nil) + @dimension_value = dimension_value if dimension_value != OMIT + @metric_value = metric_value + @additional_properties = additional_properties + @_field_set = { "dimension_value": dimension_value, "metric_value": metric_value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of AnalyticsDataPoint + # + # @param json_object [String] + # @return [Monite::AnalyticsDataPoint] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + dimension_value = parsed_json["dimension_value"] + metric_value = parsed_json["metric_value"] + new( + dimension_value: dimension_value, + metric_value: metric_value, + additional_properties: struct + ) + end +# Serialize an instance of AnalyticsDataPoint to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.dimension_value&.is_a?(String) != false || raise("Passed value for field obj.dimension_value is not the expected type, validation failed.") + obj.metric_value.is_a?(Integer) != false || raise("Passed value for field obj.metric_value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/api_version.rb b/lib/monite/types/api_version.rb new file mode 100644 index 0000000..6ea2b1f --- /dev/null +++ b/lib/monite/types/api_version.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Monite + class ApiVersion + + TWO_THOUSAND_TWENTY_FOUR_0525 = "2024-05-25" + TWO_THOUSAND_TWENTY_FOUR_0131 = "2024-01-31" + TWO_THOUSAND_TWENTY_THREE_0901 = "2023-09-01" + TWO_THOUSAND_TWENTY_THREE_0604 = "2023-06-04" + TWO_THOUSAND_TWENTY_THREE_0412 = "2023-04-12" + TWO_THOUSAND_TWENTY_THREE_0314 = "2023-03-14" + TWO_THOUSAND_TWENTY_THREE_0301 = "2023-03-01" + TWO_THOUSAND_TWENTY_THREE_0207 = "2023-02-07" + TWO_THOUSAND_TWENTY_TWO_1116 = "2022-11-16" + + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_cursor_fields.rb b/lib/monite/types/approval_policy_cursor_fields.rb new file mode 100644 index 0000000..7eadea0 --- /dev/null +++ b/lib/monite/types/approval_policy_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ApprovalPolicyCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_resource.rb b/lib/monite/types/approval_policy_resource.rb new file mode 100644 index 0000000..866e164 --- /dev/null +++ b/lib/monite/types/approval_policy_resource.rb @@ -0,0 +1,182 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "approval_policy_resource_script_item" +require_relative "approval_policy_resource_trigger" +require_relative "approval_policy_resource_status" +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class ApprovalPolicyResource + # @return [DateTime] The date and time (in the ISO 8601 format) when the approval policy becomes +# active. Only payables submitted for approval during the policy's active period +# will trigger this policy. If omitted or `null`, the policy is effective +# immediately. The value will be converted to UTC. + attr_reader :starts_at + # @return [DateTime] The date and time (in the ISO 8601 format) when the approval policy stops being +# active and stops triggering approval workflows.If `ends_at` is provided in the +# request, then `starts_at` must also be provided and `ends_at` must be later than +# `starts_at`. The value will be converted to UTC. + attr_reader :ends_at + # @return [String] The name of the approval policy. + attr_reader :name + # @return [String] A brief description of the approval policy. + attr_reader :description + # @return [Array] A list of JSON objects that represents the approval policy script. The script +# contains the logic that determines whether an action should be sent to approval. +# This field is required, and it should contain at least one script object. + attr_reader :script + # @return [Monite::ApprovalPolicyResourceTrigger] A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + attr_reader :trigger + # @return [String] + attr_reader :id + # @return [Monite::ApprovalPolicyResourceStatus] The current status of the approval policy. + attr_reader :status + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :created_by + # @return [String] + attr_reader :updated_by + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param starts_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy becomes +# active. Only payables submitted for approval during the policy's active period +# will trigger this policy. If omitted or `null`, the policy is effective +# immediately. The value will be converted to UTC. + # @param ends_at [DateTime] The date and time (in the ISO 8601 format) when the approval policy stops being +# active and stops triggering approval workflows.If `ends_at` is provided in the +# request, then `starts_at` must also be provided and `ends_at` must be later than +# `starts_at`. The value will be converted to UTC. + # @param name [String] The name of the approval policy. + # @param description [String] A brief description of the approval policy. + # @param script [Array] A list of JSON objects that represents the approval policy script. The script +# contains the logic that determines whether an action should be sent to approval. +# This field is required, and it should contain at least one script object. + # @param trigger [Monite::ApprovalPolicyResourceTrigger] A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + # @param id [String] + # @param status [Monite::ApprovalPolicyResourceStatus] The current status of the approval policy. + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param created_by [String] + # @param updated_by [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalPolicyResource] + def initialize(starts_at: OMIT, ends_at: OMIT, name:, description:, script:, trigger: OMIT, id:, status:, created_at:, updated_at:, created_by:, updated_by: OMIT, additional_properties: nil) + @starts_at = starts_at if starts_at != OMIT + @ends_at = ends_at if ends_at != OMIT + @name = name + @description = description + @script = script + @trigger = trigger if trigger != OMIT + @id = id + @status = status + @created_at = created_at + @updated_at = updated_at + @created_by = created_by + @updated_by = updated_by if updated_by != OMIT + @additional_properties = additional_properties + @_field_set = { "starts_at": starts_at, "ends_at": ends_at, "name": name, "description": description, "script": script, "trigger": trigger, "id": id, "status": status, "created_at": created_at, "updated_at": updated_at, "created_by": created_by, "updated_by": updated_by }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ApprovalPolicyResource + # + # @param json_object [String] + # @return [Monite::ApprovalPolicyResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + starts_at = unless parsed_json["starts_at"].nil? + DateTime.parse(parsed_json["starts_at"]) +else + nil +end + ends_at = unless parsed_json["ends_at"].nil? + DateTime.parse(parsed_json["ends_at"]) +else + nil +end + name = parsed_json["name"] + description = parsed_json["description"] + script = parsed_json["script"]&.map do | item | + item = item.to_json + Monite::ApprovalPolicyResourceScriptItem.from_json(json_object: item) +end + unless parsed_json["trigger"].nil? + trigger = parsed_json["trigger"].to_json + trigger = Monite::ApprovalPolicyResourceTrigger.from_json(json_object: trigger) + else + trigger = nil + end + id = parsed_json["id"] + status = parsed_json["status"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_by = parsed_json["created_by"] + updated_by = parsed_json["updated_by"] + new( + starts_at: starts_at, + ends_at: ends_at, + name: name, + description: description, + script: script, + trigger: trigger, + id: id, + status: status, + created_at: created_at, + updated_at: updated_at, + created_by: created_by, + updated_by: updated_by, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalPolicyResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.starts_at&.is_a?(DateTime) != false || raise("Passed value for field obj.starts_at is not the expected type, validation failed.") + obj.ends_at&.is_a?(DateTime) != false || raise("Passed value for field obj.ends_at is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.script.is_a?(Array) != false || raise("Passed value for field obj.script is not the expected type, validation failed.") + obj.trigger.nil? || Monite::ApprovalPolicyResourceTrigger.validate_raw(obj: obj.trigger) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.status.is_a?(Monite::ApprovalPolicyResourceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_by.is_a?(String) != false || raise("Passed value for field obj.created_by is not the expected type, validation failed.") + obj.updated_by&.is_a?(String) != false || raise("Passed value for field obj.updated_by is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_resource_list.rb b/lib/monite/types/approval_policy_resource_list.rb new file mode 100644 index 0000000..c3e6e36 --- /dev/null +++ b/lib/monite/types/approval_policy_resource_list.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "approval_policy_resource" +require "ostruct" +require "json" + +module Monite + class ApprovalPolicyResourceList + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalPolicyResourceList] + def initialize(data:, prev_pagination_token: OMIT, next_pagination_token: OMIT, additional_properties: nil) + @data = data + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "prev_pagination_token": prev_pagination_token, "next_pagination_token": next_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ApprovalPolicyResourceList + # + # @param json_object [String] + # @return [Monite::ApprovalPolicyResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ApprovalPolicyResource.from_json(json_object: item) +end + prev_pagination_token = parsed_json["prev_pagination_token"] + next_pagination_token = parsed_json["next_pagination_token"] + new( + data: data, + prev_pagination_token: prev_pagination_token, + next_pagination_token: next_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalPolicyResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_resource_script_item.rb b/lib/monite/types/approval_policy_resource_script_item.rb new file mode 100644 index 0000000..9a576b6 --- /dev/null +++ b/lib/monite/types/approval_policy_resource_script_item.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true +require "json" + +module Monite + class ApprovalPolicyResourceScriptItem + + +# Deserialize a JSON object to an instance of ApprovalPolicyResourceScriptItem + # + # @param json_object [String] + # @return [Monite::ApprovalPolicyResourceScriptItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_resource_status.rb b/lib/monite/types/approval_policy_resource_status.rb new file mode 100644 index 0000000..59e1135 --- /dev/null +++ b/lib/monite/types/approval_policy_resource_status.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite +# The current status of the approval policy. + class ApprovalPolicyResourceStatus + + ACTIVE = "active" + PENDING = "pending" + + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_resource_trigger.rb b/lib/monite/types/approval_policy_resource_trigger.rb new file mode 100644 index 0000000..00767dc --- /dev/null +++ b/lib/monite/types/approval_policy_resource_trigger.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require "json" + +module Monite +# A JSON object that represents the trigger for the approval policy. The trigger +# specifies the event that will trigger the policy to be evaluated. + class ApprovalPolicyResourceTrigger + + +# Deserialize a JSON object to an instance of ApprovalPolicyResourceTrigger + # + # @param json_object [String] + # @return [Monite::ApprovalPolicyResourceTrigger] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_policy_status.rb b/lib/monite/types/approval_policy_status.rb new file mode 100644 index 0000000..99b1cd3 --- /dev/null +++ b/lib/monite/types/approval_policy_status.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class ApprovalPolicyStatus + + ACTIVE = "active" + DELETED = "deleted" + PENDING = "pending" + + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_process_resource_list.rb b/lib/monite/types/approval_process_resource_list.rb new file mode 100644 index 0000000..41b9067 --- /dev/null +++ b/lib/monite/types/approval_process_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "process_resource" +require "ostruct" +require "json" + +module Monite + class ApprovalProcessResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalProcessResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of ApprovalProcessResourceList + # + # @param json_object [String] + # @return [Monite::ApprovalProcessResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ProcessResource.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of ApprovalProcessResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_process_step_resource.rb b/lib/monite/types/approval_process_step_resource.rb new file mode 100644 index 0000000..6f21bda --- /dev/null +++ b/lib/monite/types/approval_process_step_resource.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true +require_relative "approval_process_step_status" +require "ostruct" +require "json" + +module Monite + class ApprovalProcessStepResource + # @return [String] + attr_reader :object_id + # @return [Integer] + attr_reader :required_approval_count + # @return [Monite::ApprovalProcessStepStatus] + attr_reader :status + # @return [Array] + attr_reader :user_ids + # @return [Array] + attr_reader :role_ids + # @return [Array] + attr_reader :approved_by + # @return [String] + attr_reader :rejected_by + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object_id [String] + # @param required_approval_count [Integer] + # @param status [Monite::ApprovalProcessStepStatus] + # @param user_ids [Array] + # @param role_ids [Array] + # @param approved_by [Array] + # @param rejected_by [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalProcessStepResource] + def initialize(object_id:, required_approval_count:, status:, user_ids:, role_ids:, approved_by:, rejected_by: OMIT, additional_properties: nil) + @object_id = object_id + @required_approval_count = required_approval_count + @status = status + @user_ids = user_ids + @role_ids = role_ids + @approved_by = approved_by + @rejected_by = rejected_by if rejected_by != OMIT + @additional_properties = additional_properties + @_field_set = { "object_id": object_id, "required_approval_count": required_approval_count, "status": status, "user_ids": user_ids, "role_ids": role_ids, "approved_by": approved_by, "rejected_by": rejected_by }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ApprovalProcessStepResource + # + # @param json_object [String] + # @return [Monite::ApprovalProcessStepResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + object_id = parsed_json["object_id"] + required_approval_count = parsed_json["required_approval_count"] + status = parsed_json["status"] + user_ids = parsed_json["user_ids"] + role_ids = parsed_json["role_ids"] + approved_by = parsed_json["approved_by"] + rejected_by = parsed_json["rejected_by"] + new( + object_id: object_id, + required_approval_count: required_approval_count, + status: status, + user_ids: user_ids, + role_ids: role_ids, + approved_by: approved_by, + rejected_by: rejected_by, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalProcessStepResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.object_id.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.required_approval_count.is_a?(Integer) != false || raise("Passed value for field obj.required_approval_count is not the expected type, validation failed.") + obj.status.is_a?(Monite::ApprovalProcessStepStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.user_ids.is_a?(Array) != false || raise("Passed value for field obj.user_ids is not the expected type, validation failed.") + obj.role_ids.is_a?(Array) != false || raise("Passed value for field obj.role_ids is not the expected type, validation failed.") + obj.approved_by.is_a?(Array) != false || raise("Passed value for field obj.approved_by is not the expected type, validation failed.") + obj.rejected_by&.is_a?(String) != false || raise("Passed value for field obj.rejected_by is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_process_step_resource_list.rb b/lib/monite/types/approval_process_step_resource_list.rb new file mode 100644 index 0000000..76b550c --- /dev/null +++ b/lib/monite/types/approval_process_step_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "approval_process_step_resource" +require "ostruct" +require "json" + +module Monite + class ApprovalProcessStepResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalProcessStepResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of ApprovalProcessStepResourceList + # + # @param json_object [String] + # @return [Monite::ApprovalProcessStepResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ApprovalProcessStepResource.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of ApprovalProcessStepResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_process_step_status.rb b/lib/monite/types/approval_process_step_status.rb new file mode 100644 index 0000000..d6c311c --- /dev/null +++ b/lib/monite/types/approval_process_step_status.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Monite + class ApprovalProcessStepStatus + + WAITING = "waiting" + APPROVED = "approved" + REJECTED = "rejected" + CANCELED = "canceled" + FAILED = "failed" + NOT_STARTED = "not_started" + SKIPPED = "skipped" + + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_create_by_role_request.rb b/lib/monite/types/approval_request_create_by_role_request.rb new file mode 100644 index 0000000..71c48a8 --- /dev/null +++ b/lib/monite/types/approval_request_create_by_role_request.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "object_type" +require "ostruct" +require "json" + +module Monite + class ApprovalRequestCreateByRoleRequest + # @return [String] + attr_reader :object_id + # @return [Monite::ObjectType] + attr_reader :object_type + # @return [Integer] + attr_reader :required_approval_count + # @return [Array] + attr_reader :role_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object_id [String] + # @param object_type [Monite::ObjectType] + # @param required_approval_count [Integer] + # @param role_ids [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalRequestCreateByRoleRequest] + def initialize(object_id:, object_type:, required_approval_count:, role_ids:, additional_properties: nil) + @object_id = object_id + @object_type = object_type + @required_approval_count = required_approval_count + @role_ids = role_ids + @additional_properties = additional_properties + @_field_set = { "object_id": object_id, "object_type": object_type, "required_approval_count": required_approval_count, "role_ids": role_ids } + end +# Deserialize a JSON object to an instance of ApprovalRequestCreateByRoleRequest + # + # @param json_object [String] + # @return [Monite::ApprovalRequestCreateByRoleRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + object_id = parsed_json["object_id"] + object_type = parsed_json["object_type"] + required_approval_count = parsed_json["required_approval_count"] + role_ids = parsed_json["role_ids"] + new( + object_id: object_id, + object_type: object_type, + required_approval_count: required_approval_count, + role_ids: role_ids, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalRequestCreateByRoleRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.object_id.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::ObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.required_approval_count.is_a?(Integer) != false || raise("Passed value for field obj.required_approval_count is not the expected type, validation failed.") + obj.role_ids.is_a?(Array) != false || raise("Passed value for field obj.role_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_create_by_user_request.rb b/lib/monite/types/approval_request_create_by_user_request.rb new file mode 100644 index 0000000..306a87d --- /dev/null +++ b/lib/monite/types/approval_request_create_by_user_request.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "object_type" +require "ostruct" +require "json" + +module Monite + class ApprovalRequestCreateByUserRequest + # @return [String] + attr_reader :object_id + # @return [Monite::ObjectType] + attr_reader :object_type + # @return [Integer] + attr_reader :required_approval_count + # @return [Array] + attr_reader :user_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object_id [String] + # @param object_type [Monite::ObjectType] + # @param required_approval_count [Integer] + # @param user_ids [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalRequestCreateByUserRequest] + def initialize(object_id:, object_type:, required_approval_count:, user_ids:, additional_properties: nil) + @object_id = object_id + @object_type = object_type + @required_approval_count = required_approval_count + @user_ids = user_ids + @additional_properties = additional_properties + @_field_set = { "object_id": object_id, "object_type": object_type, "required_approval_count": required_approval_count, "user_ids": user_ids } + end +# Deserialize a JSON object to an instance of ApprovalRequestCreateByUserRequest + # + # @param json_object [String] + # @return [Monite::ApprovalRequestCreateByUserRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + object_id = parsed_json["object_id"] + object_type = parsed_json["object_type"] + required_approval_count = parsed_json["required_approval_count"] + user_ids = parsed_json["user_ids"] + new( + object_id: object_id, + object_type: object_type, + required_approval_count: required_approval_count, + user_ids: user_ids, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalRequestCreateByUserRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.object_id.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::ObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.required_approval_count.is_a?(Integer) != false || raise("Passed value for field obj.required_approval_count is not the expected type, validation failed.") + obj.user_ids.is_a?(Array) != false || raise("Passed value for field obj.user_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_create_request.rb b/lib/monite/types/approval_request_create_request.rb new file mode 100644 index 0000000..96f4758 --- /dev/null +++ b/lib/monite/types/approval_request_create_request.rb @@ -0,0 +1,58 @@ +# frozen_string_literal: true +require "json" +require_relative "approval_request_create_by_role_request" +require_relative "approval_request_create_by_user_request" + +module Monite + class ApprovalRequestCreateRequest + + +# Deserialize a JSON object to an instance of ApprovalRequestCreateRequest + # + # @param json_object [String] + # @return [Monite::ApprovalRequestCreateRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::ApprovalRequestCreateByRoleRequest.validate_raw(obj: struct) + unless struct.nil? + return Monite::ApprovalRequestCreateByRoleRequest.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::ApprovalRequestCreateByUserRequest.validate_raw(obj: struct) + unless struct.nil? + return Monite::ApprovalRequestCreateByUserRequest.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::ApprovalRequestCreateByRoleRequest.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::ApprovalRequestCreateByUserRequest.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_cursor_fields.rb b/lib/monite/types/approval_request_cursor_fields.rb new file mode 100644 index 0000000..eb06775 --- /dev/null +++ b/lib/monite/types/approval_request_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ApprovalRequestCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_resource_list.rb b/lib/monite/types/approval_request_resource_list.rb new file mode 100644 index 0000000..1fd4bb8 --- /dev/null +++ b/lib/monite/types/approval_request_resource_list.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "approval_request_resource_with_metadata" +require "ostruct" +require "json" + +module Monite + class ApprovalRequestResourceList + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalRequestResourceList] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ApprovalRequestResourceList + # + # @param json_object [String] + # @return [Monite::ApprovalRequestResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ApprovalRequestResourceWithMetadata.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalRequestResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_resource_with_metadata.rb b/lib/monite/types/approval_request_resource_with_metadata.rb new file mode 100644 index 0000000..b0885d7 --- /dev/null +++ b/lib/monite/types/approval_request_resource_with_metadata.rb @@ -0,0 +1,145 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "object_type" +require_relative "approval_request_status" +require "ostruct" +require "json" + +module Monite + class ApprovalRequestResourceWithMetadata + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [Array] + attr_reader :approved_by + # @return [String] ID of the user who created the approval request + attr_reader :created_by + # @return [String] + attr_reader :object_id + # @return [Monite::ObjectType] + attr_reader :object_type + # @return [String] + attr_reader :rejected_by + # @return [Integer] + attr_reader :required_approval_count + # @return [Array] + attr_reader :role_ids + # @return [Monite::ApprovalRequestStatus] + attr_reader :status + # @return [Array] + attr_reader :user_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param approved_by [Array] + # @param created_by [String] ID of the user who created the approval request + # @param object_id [String] + # @param object_type [Monite::ObjectType] + # @param rejected_by [String] + # @param required_approval_count [Integer] + # @param role_ids [Array] + # @param status [Monite::ApprovalRequestStatus] + # @param user_ids [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ApprovalRequestResourceWithMetadata] + def initialize(id:, created_at:, updated_at:, approved_by:, created_by:, object_id:, object_type:, rejected_by: OMIT, required_approval_count:, role_ids:, status:, user_ids:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @approved_by = approved_by + @created_by = created_by + @object_id = object_id + @object_type = object_type + @rejected_by = rejected_by if rejected_by != OMIT + @required_approval_count = required_approval_count + @role_ids = role_ids + @status = status + @user_ids = user_ids + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "approved_by": approved_by, "created_by": created_by, "object_id": object_id, "object_type": object_type, "rejected_by": rejected_by, "required_approval_count": required_approval_count, "role_ids": role_ids, "status": status, "user_ids": user_ids }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ApprovalRequestResourceWithMetadata + # + # @param json_object [String] + # @return [Monite::ApprovalRequestResourceWithMetadata] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + approved_by = parsed_json["approved_by"] + created_by = parsed_json["created_by"] + object_id = parsed_json["object_id"] + object_type = parsed_json["object_type"] + rejected_by = parsed_json["rejected_by"] + required_approval_count = parsed_json["required_approval_count"] + role_ids = parsed_json["role_ids"] + status = parsed_json["status"] + user_ids = parsed_json["user_ids"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + approved_by: approved_by, + created_by: created_by, + object_id: object_id, + object_type: object_type, + rejected_by: rejected_by, + required_approval_count: required_approval_count, + role_ids: role_ids, + status: status, + user_ids: user_ids, + additional_properties: struct + ) + end +# Serialize an instance of ApprovalRequestResourceWithMetadata to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.approved_by.is_a?(Array) != false || raise("Passed value for field obj.approved_by is not the expected type, validation failed.") + obj.created_by.is_a?(String) != false || raise("Passed value for field obj.created_by is not the expected type, validation failed.") + obj.object_id.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::ObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.rejected_by&.is_a?(String) != false || raise("Passed value for field obj.rejected_by is not the expected type, validation failed.") + obj.required_approval_count.is_a?(Integer) != false || raise("Passed value for field obj.required_approval_count is not the expected type, validation failed.") + obj.role_ids.is_a?(Array) != false || raise("Passed value for field obj.role_ids is not the expected type, validation failed.") + obj.status.is_a?(Monite::ApprovalRequestStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.user_ids.is_a?(Array) != false || raise("Passed value for field obj.user_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/approval_request_status.rb b/lib/monite/types/approval_request_status.rb new file mode 100644 index 0000000..72e9f83 --- /dev/null +++ b/lib/monite/types/approval_request_status.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + class ApprovalRequestStatus + + WAITING = "waiting" + APPROVED = "approved" + REJECTED = "rejected" + CANCELED = "canceled" + + end +end \ No newline at end of file diff --git a/lib/monite/types/bank_account.rb b/lib/monite/types/bank_account.rb new file mode 100644 index 0000000..877d596 --- /dev/null +++ b/lib/monite/types/bank_account.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite + class BankAccount + # @return [String] The ID of the bank account. + attr_reader :id + # @return [String] The name of the person or business that owns this bank account. + attr_reader :account_holder_name + # @return [String] The bank account number. Typically used for UK and US bank accounts. US account +# numbers contain 9 to 12 digits. UK account numbers typically contain 8 digits. + attr_reader :account_number + # @return [String] The BIC/SWIFT code of the bank. + attr_reader :bic + # @return [Monite::AllowedCountries] The country in which the bank account is registered, repsesented as a two-letter +# country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [Monite::CurrencyEnum] The currency of the bank account, represented as a three-letter ISO [currency +# code](https://docs.monite.com/references/currencies). + attr_reader :currency + # @return [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. Used only for entity bank accounts. + attr_reader :display_name + # @return [String] The IBAN of the bank account. + attr_reader :iban + # @return [Boolean] Indicates whether this bank account is the default one for its currency. + attr_reader :is_default + # @return [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. Used only for counterpart bank accounts. + attr_reader :name + # @return [String] The bank's routing transit number (RTN). Typically used for US banks. US routing +# numbers consist of 9 digits. + attr_reader :routing_number + # @return [String] The bank's sort code. Typically used for UK banks. + attr_reader :sort_code + # @return [String] ID of the entity user who added this bank account, or `null` if it was added +# using a partner access token. Used only for entity bank accounts. + attr_reader :was_created_by_user_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] The ID of the bank account. + # @param account_holder_name [String] The name of the person or business that owns this bank account. + # @param account_number [String] The bank account number. Typically used for UK and US bank accounts. US account +# numbers contain 9 to 12 digits. UK account numbers typically contain 8 digits. + # @param bic [String] The BIC/SWIFT code of the bank. + # @param country [Monite::AllowedCountries] The country in which the bank account is registered, repsesented as a two-letter +# country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param currency [Monite::CurrencyEnum] The currency of the bank account, represented as a three-letter ISO [currency +# code](https://docs.monite.com/references/currencies). + # @param display_name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. Used only for entity bank accounts. + # @param iban [String] The IBAN of the bank account. + # @param is_default [Boolean] Indicates whether this bank account is the default one for its currency. + # @param name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. Used only for counterpart bank accounts. + # @param routing_number [String] The bank's routing transit number (RTN). Typically used for US banks. US routing +# numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. Typically used for UK banks. + # @param was_created_by_user_id [String] ID of the entity user who added this bank account, or `null` if it was added +# using a partner access token. Used only for entity bank accounts. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BankAccount] + def initialize(id:, account_holder_name: OMIT, account_number: OMIT, bic: OMIT, country: OMIT, currency: OMIT, display_name: OMIT, iban: OMIT, is_default: OMIT, name: OMIT, routing_number: OMIT, sort_code: OMIT, was_created_by_user_id: OMIT, additional_properties: nil) + @id = id + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bic = bic if bic != OMIT + @country = country if country != OMIT + @currency = currency if currency != OMIT + @display_name = display_name if display_name != OMIT + @iban = iban if iban != OMIT + @is_default = is_default if is_default != OMIT + @name = name if name != OMIT + @routing_number = routing_number if routing_number != OMIT + @sort_code = sort_code if sort_code != OMIT + @was_created_by_user_id = was_created_by_user_id if was_created_by_user_id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "account_holder_name": account_holder_name, "account_number": account_number, "bic": bic, "country": country, "currency": currency, "display_name": display_name, "iban": iban, "is_default": is_default, "name": name, "routing_number": routing_number, "sort_code": sort_code, "was_created_by_user_id": was_created_by_user_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of BankAccount + # + # @param json_object [String] + # @return [Monite::BankAccount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bic = parsed_json["bic"] + country = parsed_json["country"] + currency = parsed_json["currency"] + display_name = parsed_json["display_name"] + iban = parsed_json["iban"] + is_default = parsed_json["is_default"] + name = parsed_json["name"] + routing_number = parsed_json["routing_number"] + sort_code = parsed_json["sort_code"] + was_created_by_user_id = parsed_json["was_created_by_user_id"] + new( + id: id, + account_holder_name: account_holder_name, + account_number: account_number, + bic: bic, + country: country, + currency: currency, + display_name: display_name, + iban: iban, + is_default: is_default, + name: name, + routing_number: routing_number, + sort_code: sort_code, + was_created_by_user_id: was_created_by_user_id, + additional_properties: struct + ) + end +# Serialize an instance of BankAccount to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.display_name&.is_a?(String) != false || raise("Passed value for field obj.display_name is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.is_default&.is_a?(Boolean) != false || raise("Passed value for field obj.is_default is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.routing_number&.is_a?(String) != false || raise("Passed value for field obj.routing_number is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + obj.was_created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.was_created_by_user_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/bank_account_verification_type.rb b/lib/monite/types/bank_account_verification_type.rb new file mode 100644 index 0000000..c324dca --- /dev/null +++ b/lib/monite/types/bank_account_verification_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class BankAccountVerificationType + + AIRWALLEX_PLAID = "airwallex_plaid" + MICRO_DEPOSIT = "micro_deposit" + + end +end \ No newline at end of file diff --git a/lib/monite/types/bank_account_verifications.rb b/lib/monite/types/bank_account_verifications.rb new file mode 100644 index 0000000..26032c7 --- /dev/null +++ b/lib/monite/types/bank_account_verifications.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true +require_relative "airwallex_plaid_verification" +require "ostruct" +require "json" + +module Monite + class BankAccountVerifications + # @return [Monite::AirwallexPlaidVerification] Airwallex Plaid verification + attr_reader :airwallex_plaid + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param airwallex_plaid [Monite::AirwallexPlaidVerification] Airwallex Plaid verification + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BankAccountVerifications] + def initialize(airwallex_plaid: OMIT, additional_properties: nil) + @airwallex_plaid = airwallex_plaid if airwallex_plaid != OMIT + @additional_properties = additional_properties + @_field_set = { "airwallex_plaid": airwallex_plaid }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of BankAccountVerifications + # + # @param json_object [String] + # @return [Monite::BankAccountVerifications] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["airwallex_plaid"].nil? + airwallex_plaid = parsed_json["airwallex_plaid"].to_json + airwallex_plaid = Monite::AirwallexPlaidVerification.from_json(json_object: airwallex_plaid) + else + airwallex_plaid = nil + end + new(airwallex_plaid: airwallex_plaid, additional_properties: struct) + end +# Serialize an instance of BankAccountVerifications to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.airwallex_plaid.nil? || Monite::AirwallexPlaidVerification.validate_raw(obj: obj.airwallex_plaid) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/based_on_receivable_created_event_data.rb b/lib/monite/types/based_on_receivable_created_event_data.rb new file mode 100644 index 0000000..9f898e1 --- /dev/null +++ b/lib/monite/types/based_on_receivable_created_event_data.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "receivable_type" +require "ostruct" +require "json" + +module Monite +# In invoice history, this object contains information about a credit note created +# for this invoice. +# In quote history, it contains information about an invoice created from this +# quote. + class BasedOnReceivableCreatedEventData + # @return [String] The ID of the newly created receivable document. + attr_reader :receivable_id + # @return [Monite::ReceivableType] The type of the receivable document that was created based on the current +# document. + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param receivable_id [String] The ID of the newly created receivable document. + # @param type [Monite::ReceivableType] The type of the receivable document that was created based on the current +# document. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BasedOnReceivableCreatedEventData] + def initialize(receivable_id:, type:, additional_properties: nil) + @receivable_id = receivable_id + @type = type + @additional_properties = additional_properties + @_field_set = { "receivable_id": receivable_id, "type": type } + end +# Deserialize a JSON object to an instance of BasedOnReceivableCreatedEventData + # + # @param json_object [String] + # @return [Monite::BasedOnReceivableCreatedEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + receivable_id = parsed_json["receivable_id"] + type = parsed_json["type"] + new( + receivable_id: receivable_id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of BasedOnReceivableCreatedEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.receivable_id.is_a?(String) != false || raise("Passed value for field obj.receivable_id is not the expected type, validation failed.") + obj.type.is_a?(Monite::ReceivableType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/based_on_transition_type.rb b/lib/monite/types/based_on_transition_type.rb new file mode 100644 index 0000000..3fae854 --- /dev/null +++ b/lib/monite/types/based_on_transition_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class BasedOnTransitionType + + INVOICE = "invoice" + CREDIT_NOTE = "credit_note" + + end +end \ No newline at end of file diff --git a/lib/monite/types/biz_objects_schema_input.rb b/lib/monite/types/biz_objects_schema_input.rb new file mode 100644 index 0000000..e7c0869 --- /dev/null +++ b/lib/monite/types/biz_objects_schema_input.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "root_schema_input" +require "ostruct" +require "json" + +module Monite + class BizObjectsSchemaInput + # @return [Array] List of objects + attr_reader :objects + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param objects [Array] List of objects + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BizObjectsSchemaInput] + def initialize(objects: OMIT, additional_properties: nil) + @objects = objects if objects != OMIT + @additional_properties = additional_properties + @_field_set = { "objects": objects }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of BizObjectsSchemaInput + # + # @param json_object [String] + # @return [Monite::BizObjectsSchemaInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + objects = parsed_json["objects"]&.map do | item | + item = item.to_json + Monite::RootSchemaInput.from_json(json_object: item) +end + new(objects: objects, additional_properties: struct) + end +# Serialize an instance of BizObjectsSchemaInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.objects&.is_a?(Array) != false || raise("Passed value for field obj.objects is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/biz_objects_schema_output.rb b/lib/monite/types/biz_objects_schema_output.rb new file mode 100644 index 0000000..4e6a826 --- /dev/null +++ b/lib/monite/types/biz_objects_schema_output.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "root_schema_output" +require "ostruct" +require "json" + +module Monite + class BizObjectsSchemaOutput + # @return [Array] List of objects + attr_reader :objects + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param objects [Array] List of objects + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BizObjectsSchemaOutput] + def initialize(objects: OMIT, additional_properties: nil) + @objects = objects if objects != OMIT + @additional_properties = additional_properties + @_field_set = { "objects": objects }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of BizObjectsSchemaOutput + # + # @param json_object [String] + # @return [Monite::BizObjectsSchemaOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + objects = parsed_json["objects"]&.map do | item | + item = item.to_json + Monite::RootSchemaOutput.from_json(json_object: item) +end + new(objects: objects, additional_properties: struct) + end +# Serialize an instance of BizObjectsSchemaOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.objects&.is_a?(Array) != false || raise("Passed value for field obj.objects is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/business_profile_input.rb b/lib/monite/types/business_profile_input.rb new file mode 100644 index 0000000..8185c90 --- /dev/null +++ b/lib/monite/types/business_profile_input.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require_relative "estimated_monthly_revenue" +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class BusinessProfileInput + # @return [String] Required for US entities. A free-form description of the products the entity +# sells (whether online or at offline retail stores) or the services it provides +# to its customers. + attr_reader :description_of_goods_or_services + # @return [Monite::EstimatedMonthlyRevenue] Required for US entities. The approximate revenue that the business generates +# per month. + attr_reader :estimated_monthly_revenue + # @return [String] The merchant category code of the entity. MCCs are used to classify businesses +# based on the goods or services they provide. + attr_reader :mcc + # @return [Array] Required for US entities. A list of primary countries where the business +# conducts its operations, such as selling products or providing services. Use +# two-letter country codes (ISO 3166-2 alpha-2). + attr_reader :operating_countries + # @return [String] The business's publicly available website. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description_of_goods_or_services [String] Required for US entities. A free-form description of the products the entity +# sells (whether online or at offline retail stores) or the services it provides +# to its customers. + # @param estimated_monthly_revenue [Monite::EstimatedMonthlyRevenue] Required for US entities. The approximate revenue that the business generates +# per month. + # @param mcc [String] The merchant category code of the entity. MCCs are used to classify businesses +# based on the goods or services they provide. + # @param operating_countries [Array] Required for US entities. A list of primary countries where the business +# conducts its operations, such as selling products or providing services. Use +# two-letter country codes (ISO 3166-2 alpha-2). + # @param url [String] The business's publicly available website. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BusinessProfileInput] + def initialize(description_of_goods_or_services: OMIT, estimated_monthly_revenue: OMIT, mcc: OMIT, operating_countries: OMIT, url: OMIT, additional_properties: nil) + @description_of_goods_or_services = description_of_goods_or_services if description_of_goods_or_services != OMIT + @estimated_monthly_revenue = estimated_monthly_revenue if estimated_monthly_revenue != OMIT + @mcc = mcc if mcc != OMIT + @operating_countries = operating_countries if operating_countries != OMIT + @url = url if url != OMIT + @additional_properties = additional_properties + @_field_set = { "description_of_goods_or_services": description_of_goods_or_services, "estimated_monthly_revenue": estimated_monthly_revenue, "mcc": mcc, "operating_countries": operating_countries, "url": url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of BusinessProfileInput + # + # @param json_object [String] + # @return [Monite::BusinessProfileInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description_of_goods_or_services = parsed_json["description_of_goods_or_services"] + unless parsed_json["estimated_monthly_revenue"].nil? + estimated_monthly_revenue = parsed_json["estimated_monthly_revenue"].to_json + estimated_monthly_revenue = Monite::EstimatedMonthlyRevenue.from_json(json_object: estimated_monthly_revenue) + else + estimated_monthly_revenue = nil + end + mcc = parsed_json["mcc"] + operating_countries = parsed_json["operating_countries"] + url = parsed_json["url"] + new( + description_of_goods_or_services: description_of_goods_or_services, + estimated_monthly_revenue: estimated_monthly_revenue, + mcc: mcc, + operating_countries: operating_countries, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of BusinessProfileInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description_of_goods_or_services&.is_a?(String) != false || raise("Passed value for field obj.description_of_goods_or_services is not the expected type, validation failed.") + obj.estimated_monthly_revenue.nil? || Monite::EstimatedMonthlyRevenue.validate_raw(obj: obj.estimated_monthly_revenue) + obj.mcc&.is_a?(String) != false || raise("Passed value for field obj.mcc is not the expected type, validation failed.") + obj.operating_countries&.is_a?(Array) != false || raise("Passed value for field obj.operating_countries is not the expected type, validation failed.") + obj.url&.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/business_profile_output.rb b/lib/monite/types/business_profile_output.rb new file mode 100644 index 0000000..cd8a425 --- /dev/null +++ b/lib/monite/types/business_profile_output.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require_relative "estimated_monthly_revenue" +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class BusinessProfileOutput + # @return [String] Required for US entities. A free-form description of the products the entity +# sells (whether online or at offline retail stores) or the services it provides +# to its customers. + attr_reader :description_of_goods_or_services + # @return [Monite::EstimatedMonthlyRevenue] Required for US entities. The approximate revenue that the business generates +# per month. + attr_reader :estimated_monthly_revenue + # @return [String] The merchant category code of the entity. MCCs are used to classify businesses +# based on the goods or services they provide. + attr_reader :mcc + # @return [Array] Required for US entities. A list of primary countries where the business +# conducts its operations, such as selling products or providing services. Use +# two-letter country codes (ISO 3166-2 alpha-2). + attr_reader :operating_countries + # @return [String] The business's publicly available website. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description_of_goods_or_services [String] Required for US entities. A free-form description of the products the entity +# sells (whether online or at offline retail stores) or the services it provides +# to its customers. + # @param estimated_monthly_revenue [Monite::EstimatedMonthlyRevenue] Required for US entities. The approximate revenue that the business generates +# per month. + # @param mcc [String] The merchant category code of the entity. MCCs are used to classify businesses +# based on the goods or services they provide. + # @param operating_countries [Array] Required for US entities. A list of primary countries where the business +# conducts its operations, such as selling products or providing services. Use +# two-letter country codes (ISO 3166-2 alpha-2). + # @param url [String] The business's publicly available website. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::BusinessProfileOutput] + def initialize(description_of_goods_or_services: OMIT, estimated_monthly_revenue: OMIT, mcc: OMIT, operating_countries: OMIT, url: OMIT, additional_properties: nil) + @description_of_goods_or_services = description_of_goods_or_services if description_of_goods_or_services != OMIT + @estimated_monthly_revenue = estimated_monthly_revenue if estimated_monthly_revenue != OMIT + @mcc = mcc if mcc != OMIT + @operating_countries = operating_countries if operating_countries != OMIT + @url = url if url != OMIT + @additional_properties = additional_properties + @_field_set = { "description_of_goods_or_services": description_of_goods_or_services, "estimated_monthly_revenue": estimated_monthly_revenue, "mcc": mcc, "operating_countries": operating_countries, "url": url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of BusinessProfileOutput + # + # @param json_object [String] + # @return [Monite::BusinessProfileOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description_of_goods_or_services = parsed_json["description_of_goods_or_services"] + unless parsed_json["estimated_monthly_revenue"].nil? + estimated_monthly_revenue = parsed_json["estimated_monthly_revenue"].to_json + estimated_monthly_revenue = Monite::EstimatedMonthlyRevenue.from_json(json_object: estimated_monthly_revenue) + else + estimated_monthly_revenue = nil + end + mcc = parsed_json["mcc"] + operating_countries = parsed_json["operating_countries"] + url = parsed_json["url"] + new( + description_of_goods_or_services: description_of_goods_or_services, + estimated_monthly_revenue: estimated_monthly_revenue, + mcc: mcc, + operating_countries: operating_countries, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of BusinessProfileOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description_of_goods_or_services&.is_a?(String) != false || raise("Passed value for field obj.description_of_goods_or_services is not the expected type, validation failed.") + obj.estimated_monthly_revenue.nil? || Monite::EstimatedMonthlyRevenue.validate_raw(obj: obj.estimated_monthly_revenue) + obj.mcc&.is_a?(String) != false || raise("Passed value for field obj.mcc is not the expected type, validation failed.") + obj.operating_countries&.is_a?(Array) != false || raise("Passed value for field obj.operating_countries is not the expected type, validation failed.") + obj.url&.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/button_theme.rb b/lib/monite/types/button_theme.rb new file mode 100644 index 0000000..6bdaa15 --- /dev/null +++ b/lib/monite/types/button_theme.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ButtonTheme + # @return [String] + attr_reader :primary_color + # @return [String] + attr_reader :primary_hover_color + # @return [String] + attr_reader :secondary_color + # @return [String] + attr_reader :secondary_hover_color + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param primary_color [String] + # @param primary_hover_color [String] + # @param secondary_color [String] + # @param secondary_hover_color [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ButtonTheme] + def initialize(primary_color: OMIT, primary_hover_color: OMIT, secondary_color: OMIT, secondary_hover_color: OMIT, additional_properties: nil) + @primary_color = primary_color if primary_color != OMIT + @primary_hover_color = primary_hover_color if primary_hover_color != OMIT + @secondary_color = secondary_color if secondary_color != OMIT + @secondary_hover_color = secondary_hover_color if secondary_hover_color != OMIT + @additional_properties = additional_properties + @_field_set = { "primary_color": primary_color, "primary_hover_color": primary_hover_color, "secondary_color": secondary_color, "secondary_hover_color": secondary_hover_color }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ButtonTheme + # + # @param json_object [String] + # @return [Monite::ButtonTheme] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + primary_color = parsed_json["primary_color"] + primary_hover_color = parsed_json["primary_hover_color"] + secondary_color = parsed_json["secondary_color"] + secondary_hover_color = parsed_json["secondary_hover_color"] + new( + primary_color: primary_color, + primary_hover_color: primary_hover_color, + secondary_color: secondary_color, + secondary_hover_color: secondary_hover_color, + additional_properties: struct + ) + end +# Serialize an instance of ButtonTheme to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.primary_color&.is_a?(String) != false || raise("Passed value for field obj.primary_color is not the expected type, validation failed.") + obj.primary_hover_color&.is_a?(String) != false || raise("Passed value for field obj.primary_hover_color is not the expected type, validation failed.") + obj.secondary_color&.is_a?(String) != false || raise("Passed value for field obj.secondary_color is not the expected type, validation failed.") + obj.secondary_hover_color&.is_a?(String) != false || raise("Passed value for field obj.secondary_hover_color is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/card_theme.rb b/lib/monite/types/card_theme.rb new file mode 100644 index 0000000..1a7eb3d --- /dev/null +++ b/lib/monite/types/card_theme.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class CardTheme + # @return [String] + attr_reader :background_color + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param background_color [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CardTheme] + def initialize(background_color: OMIT, additional_properties: nil) + @background_color = background_color if background_color != OMIT + @additional_properties = additional_properties + @_field_set = { "background_color": background_color }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CardTheme + # + # @param json_object [String] + # @return [Monite::CardTheme] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + background_color = parsed_json["background_color"] + new(background_color: background_color, additional_properties: struct) + end +# Serialize an instance of CardTheme to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.background_color&.is_a?(String) != false || raise("Passed value for field obj.background_color is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/comment_cursor_fields.rb b/lib/monite/types/comment_cursor_fields.rb new file mode 100644 index 0000000..ed9cff5 --- /dev/null +++ b/lib/monite/types/comment_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + COMMENT_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/comment_resource.rb b/lib/monite/types/comment_resource.rb new file mode 100644 index 0000000..eaba236 --- /dev/null +++ b/lib/monite/types/comment_resource.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "status_enum" +require "ostruct" +require "json" + +module Monite + class CommentResource + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :created_by_entity_user_id + # @return [String] + attr_reader :entity_id + # @return [String] + attr_reader :object_id + # @return [String] + attr_reader :object_type + # @return [String] + attr_reader :reply_to_entity_user_id + # @return [Monite::StatusEnum] + attr_reader :status + # @return [String] + attr_reader :text + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param created_by_entity_user_id [String] + # @param entity_id [String] + # @param object_id [String] + # @param object_type [String] + # @param reply_to_entity_user_id [String] + # @param status [Monite::StatusEnum] + # @param text [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CommentResource] + def initialize(id:, created_at: OMIT, updated_at: OMIT, created_by_entity_user_id:, entity_id:, object_id:, object_type:, reply_to_entity_user_id: OMIT, status:, text:, additional_properties: nil) + @id = id + @created_at = created_at if created_at != OMIT + @updated_at = updated_at if updated_at != OMIT + @created_by_entity_user_id = created_by_entity_user_id + @entity_id = entity_id + @object_id = object_id + @object_type = object_type + @reply_to_entity_user_id = reply_to_entity_user_id if reply_to_entity_user_id != OMIT + @status = status + @text = text + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_by_entity_user_id": created_by_entity_user_id, "entity_id": entity_id, "object_id": object_id, "object_type": object_type, "reply_to_entity_user_id": reply_to_entity_user_id, "status": status, "text": text }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CommentResource + # + # @param json_object [String] + # @return [Monite::CommentResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + entity_id = parsed_json["entity_id"] + object_id = parsed_json["object_id"] + object_type = parsed_json["object_type"] + reply_to_entity_user_id = parsed_json["reply_to_entity_user_id"] + status = parsed_json["status"] + text = parsed_json["text"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_by_entity_user_id: created_by_entity_user_id, + entity_id: entity_id, + object_id: object_id, + object_type: object_type, + reply_to_entity_user_id: reply_to_entity_user_id, + status: status, + text: text, + additional_properties: struct + ) + end +# Serialize an instance of CommentResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_by_entity_user_id.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.object_id.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.object_type.is_a?(String) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.reply_to_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.reply_to_entity_user_id is not the expected type, validation failed.") + obj.status.is_a?(Monite::StatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/comment_resource_list.rb b/lib/monite/types/comment_resource_list.rb new file mode 100644 index 0000000..46252fd --- /dev/null +++ b/lib/monite/types/comment_resource_list.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "comment_resource" +require "ostruct" +require "json" + +module Monite + class CommentResourceList + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CommentResourceList] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CommentResourceList + # + # @param json_object [String] + # @return [Monite::CommentResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CommentResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of CommentResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/common_schema_input.rb b/lib/monite/types/common_schema_input.rb new file mode 100644 index 0000000..4ded9be --- /dev/null +++ b/lib/monite/types/common_schema_input.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "action_schema" +require "ostruct" +require "json" + +module Monite + class CommonSchemaInput + # @return [Array] List of actions + attr_reader :actions + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param actions [Array] List of actions + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CommonSchemaInput] + def initialize(actions: OMIT, additional_properties: nil) + @actions = actions if actions != OMIT + @additional_properties = additional_properties + @_field_set = { "actions": actions }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CommonSchemaInput + # + # @param json_object [String] + # @return [Monite::CommonSchemaInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + actions = parsed_json["actions"]&.map do | item | + item = item.to_json + Monite::ActionSchema.from_json(json_object: item) +end + new(actions: actions, additional_properties: struct) + end +# Serialize an instance of CommonSchemaInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.actions&.is_a?(Array) != false || raise("Passed value for field obj.actions is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/common_schema_output.rb b/lib/monite/types/common_schema_output.rb new file mode 100644 index 0000000..4bf2c8e --- /dev/null +++ b/lib/monite/types/common_schema_output.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "action_schema" +require "ostruct" +require "json" + +module Monite + class CommonSchemaOutput + # @return [Array] List of actions + attr_reader :actions + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param actions [Array] List of actions + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CommonSchemaOutput] + def initialize(actions: OMIT, additional_properties: nil) + @actions = actions if actions != OMIT + @additional_properties = additional_properties + @_field_set = { "actions": actions }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CommonSchemaOutput + # + # @param json_object [String] + # @return [Monite::CommonSchemaOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + actions = parsed_json["actions"]&.map do | item | + item = item.to_json + Monite::ActionSchema.from_json(json_object: item) +end + new(actions: actions, additional_properties: struct) + end +# Serialize an instance of CommonSchemaOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.actions&.is_a?(Array) != false || raise("Passed value for field obj.actions is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/complete_refresh_verification_request.rb b/lib/monite/types/complete_refresh_verification_request.rb new file mode 100644 index 0000000..0aea6a1 --- /dev/null +++ b/lib/monite/types/complete_refresh_verification_request.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +require_relative "bank_account_verification_type" +require "ostruct" +require "json" + +module Monite + class CompleteRefreshVerificationRequest + # @return [Monite::BankAccountVerificationType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param type [Monite::BankAccountVerificationType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CompleteRefreshVerificationRequest] + def initialize(type:, additional_properties: nil) + @type = type + @additional_properties = additional_properties + @_field_set = { "type": type } + end +# Deserialize a JSON object to an instance of CompleteRefreshVerificationRequest + # + # @param json_object [String] + # @return [Monite::CompleteRefreshVerificationRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + type = parsed_json["type"] + new(type: type, additional_properties: struct) + end +# Serialize an instance of CompleteRefreshVerificationRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.type.is_a?(Monite::BankAccountVerificationType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/complete_refresh_verification_response.rb b/lib/monite/types/complete_refresh_verification_response.rb new file mode 100644 index 0000000..5c6deb1 --- /dev/null +++ b/lib/monite/types/complete_refresh_verification_response.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "bank_account_verifications" +require "ostruct" +require "json" + +module Monite + class CompleteRefreshVerificationResponse + # @return [Monite::BankAccountVerifications] + attr_reader :verifications + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param verifications [Monite::BankAccountVerifications] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CompleteRefreshVerificationResponse] + def initialize(verifications:, additional_properties: nil) + @verifications = verifications + @additional_properties = additional_properties + @_field_set = { "verifications": verifications } + end +# Deserialize a JSON object to an instance of CompleteRefreshVerificationResponse + # + # @param json_object [String] + # @return [Monite::CompleteRefreshVerificationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["verifications"].nil? + verifications = parsed_json["verifications"].to_json + verifications = Monite::BankAccountVerifications.from_json(json_object: verifications) + else + verifications = nil + end + new(verifications: verifications, additional_properties: struct) + end +# Serialize an instance of CompleteRefreshVerificationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::BankAccountVerifications.validate_raw(obj: obj.verifications) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/complete_verification_airwallex_plaid_request.rb b/lib/monite/types/complete_verification_airwallex_plaid_request.rb new file mode 100644 index 0000000..1b57161 --- /dev/null +++ b/lib/monite/types/complete_verification_airwallex_plaid_request.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true +require_relative "airwallex_plaid_account" +require_relative "airwallex_plaid_institution" +require_relative "airwallex_mandate" +require "ostruct" +require "json" + +module Monite + class CompleteVerificationAirwallexPlaidRequest + # @return [Monite::AirwallexPlaidAccount] The bank account that was selected in the Plaid Modal + attr_reader :account + # @return [Monite::AirwallexPlaidInstitution] The financial institution that was selected in the Plaid Modal + attr_reader :institution + # @return [Monite::AirwallexMandate] + attr_reader :mandate + # @return [String] The Plaid Public Token + attr_reader :public_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param account [Monite::AirwallexPlaidAccount] The bank account that was selected in the Plaid Modal + # @param institution [Monite::AirwallexPlaidInstitution] The financial institution that was selected in the Plaid Modal + # @param mandate [Monite::AirwallexMandate] + # @param public_token [String] The Plaid Public Token + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CompleteVerificationAirwallexPlaidRequest] + def initialize(account:, institution:, mandate:, public_token:, additional_properties: nil) + @account = account + @institution = institution + @mandate = mandate + @public_token = public_token + @additional_properties = additional_properties + @_field_set = { "account": account, "institution": institution, "mandate": mandate, "public_token": public_token } + end +# Deserialize a JSON object to an instance of +# CompleteVerificationAirwallexPlaidRequest + # + # @param json_object [String] + # @return [Monite::CompleteVerificationAirwallexPlaidRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["account"].nil? + account = parsed_json["account"].to_json + account = Monite::AirwallexPlaidAccount.from_json(json_object: account) + else + account = nil + end + unless parsed_json["institution"].nil? + institution = parsed_json["institution"].to_json + institution = Monite::AirwallexPlaidInstitution.from_json(json_object: institution) + else + institution = nil + end + unless parsed_json["mandate"].nil? + mandate = parsed_json["mandate"].to_json + mandate = Monite::AirwallexMandate.from_json(json_object: mandate) + else + mandate = nil + end + public_token = parsed_json["public_token"] + new( + account: account, + institution: institution, + mandate: mandate, + public_token: public_token, + additional_properties: struct + ) + end +# Serialize an instance of CompleteVerificationAirwallexPlaidRequest to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::AirwallexPlaidAccount.validate_raw(obj: obj.account) + Monite::AirwallexPlaidInstitution.validate_raw(obj: obj.institution) + Monite::AirwallexMandate.validate_raw(obj: obj.mandate) + obj.public_token.is_a?(String) != false || raise("Passed value for field obj.public_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/complete_verification_request.rb b/lib/monite/types/complete_verification_request.rb new file mode 100644 index 0000000..a4c7482 --- /dev/null +++ b/lib/monite/types/complete_verification_request.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "complete_verification_airwallex_plaid_request" +require_relative "bank_account_verification_type" +require "ostruct" +require "json" + +module Monite + class CompleteVerificationRequest + # @return [Monite::CompleteVerificationAirwallexPlaidRequest] + attr_reader :airwallex_plaid + # @return [Monite::BankAccountVerificationType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param airwallex_plaid [Monite::CompleteVerificationAirwallexPlaidRequest] + # @param type [Monite::BankAccountVerificationType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CompleteVerificationRequest] + def initialize(airwallex_plaid:, type:, additional_properties: nil) + @airwallex_plaid = airwallex_plaid + @type = type + @additional_properties = additional_properties + @_field_set = { "airwallex_plaid": airwallex_plaid, "type": type } + end +# Deserialize a JSON object to an instance of CompleteVerificationRequest + # + # @param json_object [String] + # @return [Monite::CompleteVerificationRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["airwallex_plaid"].nil? + airwallex_plaid = parsed_json["airwallex_plaid"].to_json + airwallex_plaid = Monite::CompleteVerificationAirwallexPlaidRequest.from_json(json_object: airwallex_plaid) + else + airwallex_plaid = nil + end + type = parsed_json["type"] + new( + airwallex_plaid: airwallex_plaid, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of CompleteVerificationRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::CompleteVerificationAirwallexPlaidRequest.validate_raw(obj: obj.airwallex_plaid) + obj.type.is_a?(Monite::BankAccountVerificationType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/complete_verification_response.rb b/lib/monite/types/complete_verification_response.rb new file mode 100644 index 0000000..2a77c74 --- /dev/null +++ b/lib/monite/types/complete_verification_response.rb @@ -0,0 +1,164 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "currency_enum" +require_relative "bank_account_verifications" +require "ostruct" +require "json" + +module Monite + class CompleteVerificationResponse + # @return [String] Deprecated. Use bank_account_id instead. + attr_reader :id + # @return [String] Account holder's name + attr_reader :account_holder_name + # @return [String] Account number (required if IBAN is not provided) + attr_reader :account_number + # @return [String] + attr_reader :bank_account_id + # @return [String] The name of the entity`s bank account. + attr_reader :bank_name + # @return [String] The BIC of the entity`s bank account. + attr_reader :bic + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [String] + attr_reader :display_name + # @return [String] The IBAN of the entity`s bank account. + attr_reader :iban + # @return [Boolean] Marks if a bank account should be used by default for the currency. Only 1 can +# be True for each currency. + attr_reader :is_default + # @return [String] Routing number (US) + attr_reader :routing_number + # @return [String] Sort code (GB) + attr_reader :sort_code + # @return [Monite::BankAccountVerifications] + attr_reader :verifications + # @return [String] + attr_reader :was_created_by_user_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Deprecated. Use bank_account_id instead. + # @param account_holder_name [String] Account holder's name + # @param account_number [String] Account number (required if IBAN is not provided) + # @param bank_account_id [String] + # @param bank_name [String] The name of the entity`s bank account. + # @param bic [String] The BIC of the entity`s bank account. + # @param country [Monite::AllowedCountries] + # @param currency [Monite::CurrencyEnum] + # @param display_name [String] + # @param iban [String] The IBAN of the entity`s bank account. + # @param is_default [Boolean] Marks if a bank account should be used by default for the currency. Only 1 can +# be True for each currency. + # @param routing_number [String] Routing number (US) + # @param sort_code [String] Sort code (GB) + # @param verifications [Monite::BankAccountVerifications] + # @param was_created_by_user_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CompleteVerificationResponse] + def initialize(id:, account_holder_name: OMIT, account_number: OMIT, bank_account_id:, bank_name: OMIT, bic: OMIT, country: OMIT, currency: OMIT, display_name: OMIT, iban: OMIT, is_default:, routing_number: OMIT, sort_code: OMIT, verifications:, was_created_by_user_id: OMIT, additional_properties: nil) + @id = id + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bank_account_id = bank_account_id + @bank_name = bank_name if bank_name != OMIT + @bic = bic if bic != OMIT + @country = country if country != OMIT + @currency = currency if currency != OMIT + @display_name = display_name if display_name != OMIT + @iban = iban if iban != OMIT + @is_default = is_default + @routing_number = routing_number if routing_number != OMIT + @sort_code = sort_code if sort_code != OMIT + @verifications = verifications + @was_created_by_user_id = was_created_by_user_id if was_created_by_user_id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "account_holder_name": account_holder_name, "account_number": account_number, "bank_account_id": bank_account_id, "bank_name": bank_name, "bic": bic, "country": country, "currency": currency, "display_name": display_name, "iban": iban, "is_default": is_default, "routing_number": routing_number, "sort_code": sort_code, "verifications": verifications, "was_created_by_user_id": was_created_by_user_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CompleteVerificationResponse + # + # @param json_object [String] + # @return [Monite::CompleteVerificationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bank_account_id = parsed_json["bank_account_id"] + bank_name = parsed_json["bank_name"] + bic = parsed_json["bic"] + country = parsed_json["country"] + currency = parsed_json["currency"] + display_name = parsed_json["display_name"] + iban = parsed_json["iban"] + is_default = parsed_json["is_default"] + routing_number = parsed_json["routing_number"] + sort_code = parsed_json["sort_code"] + unless parsed_json["verifications"].nil? + verifications = parsed_json["verifications"].to_json + verifications = Monite::BankAccountVerifications.from_json(json_object: verifications) + else + verifications = nil + end + was_created_by_user_id = parsed_json["was_created_by_user_id"] + new( + id: id, + account_holder_name: account_holder_name, + account_number: account_number, + bank_account_id: bank_account_id, + bank_name: bank_name, + bic: bic, + country: country, + currency: currency, + display_name: display_name, + iban: iban, + is_default: is_default, + routing_number: routing_number, + sort_code: sort_code, + verifications: verifications, + was_created_by_user_id: was_created_by_user_id, + additional_properties: struct + ) + end +# Serialize an instance of CompleteVerificationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bank_account_id.is_a?(String) != false || raise("Passed value for field obj.bank_account_id is not the expected type, validation failed.") + obj.bank_name&.is_a?(String) != false || raise("Passed value for field obj.bank_name is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.display_name&.is_a?(String) != false || raise("Passed value for field obj.display_name is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.is_default.is_a?(Boolean) != false || raise("Passed value for field obj.is_default is not the expected type, validation failed.") + obj.routing_number&.is_a?(String) != false || raise("Passed value for field obj.routing_number is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + Monite::BankAccountVerifications.validate_raw(obj: obj.verifications) + obj.was_created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.was_created_by_user_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/connection_status.rb b/lib/monite/types/connection_status.rb new file mode 100644 index 0000000..3ab68ee --- /dev/null +++ b/lib/monite/types/connection_status.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + class ConnectionStatus + + CONNECTED = "connected" + DISCONNECTED = "disconnected" + DEAUTHORIZED = "deauthorized" + PENDING_AUTH = "pending_auth" + + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_address.rb b/lib/monite/types/counterpart_address.rb new file mode 100644 index 0000000..a3e9c99 --- /dev/null +++ b/lib/monite/types/counterpart_address.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# Address information. + class CounterpartAddress + # @return [String] City name. + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartAddress] + def initialize(city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartAddress + # + # @param json_object [String] + # @return [Monite::CounterpartAddress] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartAddress to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_address_resource_list.rb b/lib/monite/types/counterpart_address_resource_list.rb new file mode 100644 index 0000000..e2e78ef --- /dev/null +++ b/lib/monite/types/counterpart_address_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "counterpart_address_response_with_counterpart_id" +require "ostruct" +require "json" + +module Monite + class CounterpartAddressResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartAddressResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of CounterpartAddressResourceList + # + # @param json_object [String] + # @return [Monite::CounterpartAddressResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CounterpartAddressResponseWithCounterpartId.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of CounterpartAddressResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_address_response_with_counterpart_id.rb b/lib/monite/types/counterpart_address_response_with_counterpart_id.rb new file mode 100644 index 0000000..ad386e2 --- /dev/null +++ b/lib/monite/types/counterpart_address_response_with_counterpart_id.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# Address information. + class CounterpartAddressResponseWithCounterpartId + # @return [String] Unique ID of the address in the system + attr_reader :id + # @return [String] City name. + attr_reader :city + # @return [String] ID of the counterpart that owns the address. + attr_reader :counterpart_id + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the address in the system + # @param city [String] City name. + # @param counterpart_id [String] ID of the counterpart that owns the address. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + def initialize(id:, city:, counterpart_id:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @id = id + @city = city + @counterpart_id = counterpart_id + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "city": city, "counterpart_id": counterpart_id, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# CounterpartAddressResponseWithCounterpartId + # + # @param json_object [String] + # @return [Monite::CounterpartAddressResponseWithCounterpartId] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + city = parsed_json["city"] + counterpart_id = parsed_json["counterpart_id"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + id: id, + city: city, + counterpart_id: counterpart_id, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartAddressResponseWithCounterpartId to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_bank_account_resource_list.rb b/lib/monite/types/counterpart_bank_account_resource_list.rb new file mode 100644 index 0000000..2f68fd0 --- /dev/null +++ b/lib/monite/types/counterpart_bank_account_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "counterpart_bank_account_response" +require "ostruct" +require "json" + +module Monite + class CounterpartBankAccountResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartBankAccountResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of CounterpartBankAccountResourceList + # + # @param json_object [String] + # @return [Monite::CounterpartBankAccountResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CounterpartBankAccountResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of CounterpartBankAccountResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_bank_account_response.rb b/lib/monite/types/counterpart_bank_account_response.rb new file mode 100644 index 0000000..556900b --- /dev/null +++ b/lib/monite/types/counterpart_bank_account_response.rb @@ -0,0 +1,150 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite + class CounterpartBankAccountResponse + # @return [String] + attr_reader :id + # @return [String] The name of the person or business that owns this bank account. Required for US +# bank accounts to accept ACH payments. + attr_reader :account_holder_name + # @return [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + attr_reader :account_number + # @return [String] The BIC/SWIFT code of the bank. + attr_reader :bic + # @return [String] + attr_reader :counterpart_id + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [String] The IBAN of the bank account. + attr_reader :iban + # @return [Boolean] + attr_reader :is_default_for_currency + # @return [String] + attr_reader :name + # @return [Hash{String => Object}] Metadata for partner needs. + attr_reader :partner_metadata + # @return [String] The bank's routing transit number (RTN). Required for US bank accounts to accept +# ACH payments. US routing numbers consist of 9 digits. + attr_reader :routing_number + # @return [String] The bank's sort code. + attr_reader :sort_code + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required for US +# bank accounts to accept ACH payments. + # @param account_number [String] The bank account number. Required for US bank accounts to accept ACH payments. +# US account numbers contain 9 to 12 digits. UK account numbers typically contain +# 8 digits. + # @param bic [String] The BIC/SWIFT code of the bank. + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param currency [Monite::CurrencyEnum] + # @param iban [String] The IBAN of the bank account. + # @param is_default_for_currency [Boolean] + # @param name [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs. + # @param routing_number [String] The bank's routing transit number (RTN). Required for US bank accounts to accept +# ACH payments. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartBankAccountResponse] + def initialize(id:, account_holder_name: OMIT, account_number: OMIT, bic: OMIT, counterpart_id:, country:, currency:, iban: OMIT, is_default_for_currency: OMIT, name: OMIT, partner_metadata: OMIT, routing_number: OMIT, sort_code: OMIT, additional_properties: nil) + @id = id + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bic = bic if bic != OMIT + @counterpart_id = counterpart_id + @country = country + @currency = currency + @iban = iban if iban != OMIT + @is_default_for_currency = is_default_for_currency if is_default_for_currency != OMIT + @name = name if name != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @routing_number = routing_number if routing_number != OMIT + @sort_code = sort_code if sort_code != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "account_holder_name": account_holder_name, "account_number": account_number, "bic": bic, "counterpart_id": counterpart_id, "country": country, "currency": currency, "iban": iban, "is_default_for_currency": is_default_for_currency, "name": name, "partner_metadata": partner_metadata, "routing_number": routing_number, "sort_code": sort_code }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartBankAccountResponse + # + # @param json_object [String] + # @return [Monite::CounterpartBankAccountResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bic = parsed_json["bic"] + counterpart_id = parsed_json["counterpart_id"] + country = parsed_json["country"] + currency = parsed_json["currency"] + iban = parsed_json["iban"] + is_default_for_currency = parsed_json["is_default_for_currency"] + name = parsed_json["name"] + partner_metadata = parsed_json["partner_metadata"] + routing_number = parsed_json["routing_number"] + sort_code = parsed_json["sort_code"] + new( + id: id, + account_holder_name: account_holder_name, + account_number: account_number, + bic: bic, + counterpart_id: counterpart_id, + country: country, + currency: currency, + iban: iban, + is_default_for_currency: is_default_for_currency, + name: name, + partner_metadata: partner_metadata, + routing_number: routing_number, + sort_code: sort_code, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartBankAccountResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.is_default_for_currency&.is_a?(Boolean) != false || raise("Passed value for field obj.is_default_for_currency is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.routing_number&.is_a?(String) != false || raise("Passed value for field obj.routing_number is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_contact_response.rb b/lib/monite/types/counterpart_contact_response.rb new file mode 100644 index 0000000..66824aa --- /dev/null +++ b/lib/monite/types/counterpart_contact_response.rb @@ -0,0 +1,119 @@ +# frozen_string_literal: true +require_relative "counterpart_address" +require "ostruct" +require "json" + +module Monite +# The contact person for an organization. + class CounterpartContactResponse + # @return [String] + attr_reader :id + # @return [Monite::CounterpartAddress] The address of a contact person. + attr_reader :address + # @return [String] + attr_reader :counterpart_id + # @return [String] The email address of a contact person. + attr_reader :email + # @return [String] The first name of a contact person. + attr_reader :first_name + # @return [Boolean] + attr_reader :is_default + # @return [String] The last name of a contact person. + attr_reader :last_name + # @return [String] The phone number of a contact person + attr_reader :phone + # @return [String] The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param address [Monite::CounterpartAddress] The address of a contact person. + # @param counterpart_id [String] + # @param email [String] The email address of a contact person. + # @param first_name [String] The first name of a contact person. + # @param is_default [Boolean] + # @param last_name [String] The last name of a contact person. + # @param phone [String] The phone number of a contact person + # @param title [String] The title or honorific of a contact person. Examples: Mr., Ms., Dr., Prof. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartContactResponse] + def initialize(id:, address:, counterpart_id:, email: OMIT, first_name:, is_default:, last_name:, phone: OMIT, title: OMIT, additional_properties: nil) + @id = id + @address = address + @counterpart_id = counterpart_id + @email = email if email != OMIT + @first_name = first_name + @is_default = is_default + @last_name = last_name + @phone = phone if phone != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "address": address, "counterpart_id": counterpart_id, "email": email, "first_name": first_name, "is_default": is_default, "last_name": last_name, "phone": phone, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartContactResponse + # + # @param json_object [String] + # @return [Monite::CounterpartContactResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::CounterpartAddress.from_json(json_object: address) + else + address = nil + end + counterpart_id = parsed_json["counterpart_id"] + email = parsed_json["email"] + first_name = parsed_json["first_name"] + is_default = parsed_json["is_default"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + title = parsed_json["title"] + new( + id: id, + address: address, + counterpart_id: counterpart_id, + email: email, + first_name: first_name, + is_default: is_default, + last_name: last_name, + phone: phone, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartContactResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + Monite::CounterpartAddress.validate_raw(obj: obj.address) + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.is_default.is_a?(Boolean) != false || raise("Passed value for field obj.is_default is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_contacts_resource_list.rb b/lib/monite/types/counterpart_contacts_resource_list.rb new file mode 100644 index 0000000..292caf2 --- /dev/null +++ b/lib/monite/types/counterpart_contacts_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "counterpart_contact_response" +require "ostruct" +require "json" + +module Monite + class CounterpartContactsResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartContactsResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of CounterpartContactsResourceList + # + # @param json_object [String] + # @return [Monite::CounterpartContactsResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CounterpartContactResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of CounterpartContactsResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_create_payload.rb b/lib/monite/types/counterpart_create_payload.rb new file mode 100644 index 0000000..247cf47 --- /dev/null +++ b/lib/monite/types/counterpart_create_payload.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require "json" +require_relative "counterpart_organization_root_create_payload" +require_relative "counterpart_individual_root_create_payload" + +module Monite +# This schema is used to create new counterparts (either organizations or +# individuals). +# The counterpart type is specified by the `type` property. Depending on the +# `type`, +# you need to provide the data for either the `individual` or `organization` +# property. + class CounterpartCreatePayload + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::CounterpartCreatePayload] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of CounterpartCreatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "organization" + member = Monite::CounterpartOrganizationRootCreatePayload.from_json(json_object: json_object) + when "individual" + member = Monite::CounterpartIndividualRootCreatePayload.from_json(json_object: json_object) + else + member = Monite::CounterpartOrganizationRootCreatePayload.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "organization" + { **@member.to_json, type: @discriminant }.to_json + when "individual" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "organization" + Monite::CounterpartOrganizationRootCreatePayload.validate_raw(obj: obj) + when "individual" + Monite::CounterpartIndividualRootCreatePayload.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::CounterpartOrganizationRootCreatePayload] + # @return [Monite::CounterpartCreatePayload] + def self.organization(member:) + new(member: member, discriminant: "organization") + end + # @param member [Monite::CounterpartIndividualRootCreatePayload] + # @return [Monite::CounterpartCreatePayload] + def self.individual(member:) + new(member: member, discriminant: "individual") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_cursor_fields.rb b/lib/monite/types/counterpart_cursor_fields.rb new file mode 100644 index 0000000..1a3ec70 --- /dev/null +++ b/lib/monite/types/counterpart_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + COUNTERPART_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_individual_create_payload.rb b/lib/monite/types/counterpart_individual_create_payload.rb new file mode 100644 index 0000000..a9293be --- /dev/null +++ b/lib/monite/types/counterpart_individual_create_payload.rb @@ -0,0 +1,119 @@ +# frozen_string_literal: true +require_relative "counterpart_address" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class CounterpartIndividualCreatePayload + # @return [Monite::CounterpartAddress] The person's address. + attr_reader :address + # @return [String] The person's email address. + attr_reader :email + # @return [String] The person's first name. + attr_reader :first_name + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The person's last name. + attr_reader :last_name + # @return [String] The person's phone number. + attr_reader :phone + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + attr_reader :tag_ids + # @return [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address [Monite::CounterpartAddress] The person's address. + # @param email [String] The person's email address. + # @param first_name [String] The person's first name. + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param last_name [String] The person's last name. + # @param phone [String] The person's phone number. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + # @param title [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartIndividualCreatePayload] + def initialize(address:, email: OMIT, first_name:, is_customer:, is_vendor:, last_name:, phone: OMIT, tag_ids: OMIT, title: OMIT, additional_properties: nil) + @address = address + @email = email if email != OMIT + @first_name = first_name + @is_customer = is_customer + @is_vendor = is_vendor + @last_name = last_name + @phone = phone if phone != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "address": address, "email": email, "first_name": first_name, "is_customer": is_customer, "is_vendor": is_vendor, "last_name": last_name, "phone": phone, "tag_ids": tag_ids, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartIndividualCreatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartIndividualCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::CounterpartAddress.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + first_name = parsed_json["first_name"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + tag_ids = parsed_json["tag_ids"] + title = parsed_json["title"] + new( + address: address, + email: email, + first_name: first_name, + is_customer: is_customer, + is_vendor: is_vendor, + last_name: last_name, + phone: phone, + tag_ids: tag_ids, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartIndividualCreatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::CounterpartAddress.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.is_customer.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_individual_response.rb b/lib/monite/types/counterpart_individual_response.rb new file mode 100644 index 0000000..de91655 --- /dev/null +++ b/lib/monite/types/counterpart_individual_response.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true +require_relative "counterpart_tag_schema" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class CounterpartIndividualResponse + # @return [String] The person's email address. + attr_reader :email + # @return [String] The person's first name. + attr_reader :first_name + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The person's last name. + attr_reader :last_name + # @return [String] The person's phone number. + attr_reader :phone + # @return [Array] The list of tags for this counterpart. + attr_reader :tags + # @return [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The person's email address. + # @param first_name [String] The person's first name. + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param last_name [String] The person's last name. + # @param phone [String] The person's phone number. + # @param tags [Array] The list of tags for this counterpart. + # @param title [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartIndividualResponse] + def initialize(email: OMIT, first_name:, is_customer:, is_vendor:, last_name:, phone: OMIT, tags: OMIT, title: OMIT, additional_properties: nil) + @email = email if email != OMIT + @first_name = first_name + @is_customer = is_customer + @is_vendor = is_vendor + @last_name = last_name + @phone = phone if phone != OMIT + @tags = tags if tags != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "first_name": first_name, "is_customer": is_customer, "is_vendor": is_vendor, "last_name": last_name, "phone": phone, "tags": tags, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartIndividualResponse + # + # @param json_object [String] + # @return [Monite::CounterpartIndividualResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + first_name = parsed_json["first_name"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::CounterpartTagSchema.from_json(json_object: item) +end + title = parsed_json["title"] + new( + email: email, + first_name: first_name, + is_customer: is_customer, + is_vendor: is_vendor, + last_name: last_name, + phone: phone, + tags: tags, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartIndividualResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.is_customer.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_individual_root_create_payload.rb b/lib/monite/types/counterpart_individual_root_create_payload.rb new file mode 100644 index 0000000..6f9cd6c --- /dev/null +++ b/lib/monite/types/counterpart_individual_root_create_payload.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true +require_relative "counterpart_individual_create_payload" +require_relative "language_code_enum" +require "ostruct" +require "json" + +module Monite +# This schema is used to create counterparts that are individuals (natural +# persons). + class CounterpartIndividualRootCreatePayload + # @return [Monite::CounterpartIndividualCreatePayload] + attr_reader :individual + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + attr_reader :tax_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param individual [Monite::CounterpartIndividualCreatePayload] + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartIndividualRootCreatePayload] + def initialize(individual:, language: OMIT, reminders_enabled: OMIT, tax_id: OMIT, additional_properties: nil) + @individual = individual + @language = language if language != OMIT + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @additional_properties = additional_properties + @_field_set = { "individual": individual, "language": language, "reminders_enabled": reminders_enabled, "tax_id": tax_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# CounterpartIndividualRootCreatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartIndividualRootCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::CounterpartIndividualCreatePayload.from_json(json_object: individual) + else + individual = nil + end + language = parsed_json["language"] + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + new( + individual: individual, + language: language, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartIndividualRootCreatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::CounterpartIndividualCreatePayload.validate_raw(obj: obj.individual) + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_individual_root_response.rb b/lib/monite/types/counterpart_individual_root_response.rb new file mode 100644 index 0000000..aae812a --- /dev/null +++ b/lib/monite/types/counterpart_individual_root_response.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "counterpart_individual_response" +require_relative "language_code_enum" +require_relative "counterpart_type" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class CounterpartIndividualRootResponse + # @return [String] Unique ID of the counterpart. + attr_reader :id + # @return [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :created_at + # @return [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :updated_at + # @return [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + attr_reader :created_automatically + # @return [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + attr_reader :default_billing_address_id + # @return [String] ID of the shipping address. + attr_reader :default_shipping_address_id + # @return [String] Entity user ID of counterpart creator. + attr_reader :created_by_entity_user_id + # @return [Monite::CounterpartIndividualResponse] + attr_reader :individual + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. + attr_reader :tax_id + # @return [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the counterpart. + # @param created_at [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param updated_at [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param created_automatically [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + # @param default_billing_address_id [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + # @param default_shipping_address_id [String] ID of the shipping address. + # @param created_by_entity_user_id [String] Entity user ID of counterpart creator. + # @param individual [Monite::CounterpartIndividualResponse] + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. + # @param type [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartIndividualRootResponse] + def initialize(id:, created_at:, updated_at:, created_automatically: OMIT, default_billing_address_id: OMIT, default_shipping_address_id: OMIT, created_by_entity_user_id: OMIT, individual:, language: OMIT, reminders_enabled: OMIT, tax_id: OMIT, type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @created_automatically = created_automatically if created_automatically != OMIT + @default_billing_address_id = default_billing_address_id if default_billing_address_id != OMIT + @default_shipping_address_id = default_shipping_address_id if default_shipping_address_id != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @individual = individual + @language = language if language != OMIT + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_automatically": created_automatically, "default_billing_address_id": default_billing_address_id, "default_shipping_address_id": default_shipping_address_id, "created_by_entity_user_id": created_by_entity_user_id, "individual": individual, "language": language, "reminders_enabled": reminders_enabled, "tax_id": tax_id, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartIndividualRootResponse + # + # @param json_object [String] + # @return [Monite::CounterpartIndividualRootResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_automatically = parsed_json["created_automatically"] + default_billing_address_id = parsed_json["default_billing_address_id"] + default_shipping_address_id = parsed_json["default_shipping_address_id"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::CounterpartIndividualResponse.from_json(json_object: individual) + else + individual = nil + end + language = parsed_json["language"] + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_automatically: created_automatically, + default_billing_address_id: default_billing_address_id, + default_shipping_address_id: default_shipping_address_id, + created_by_entity_user_id: created_by_entity_user_id, + individual: individual, + language: language, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartIndividualRootResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_automatically&.is_a?(Boolean) != false || raise("Passed value for field obj.created_automatically is not the expected type, validation failed.") + obj.default_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_billing_address_id is not the expected type, validation failed.") + obj.default_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_shipping_address_id is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + Monite::CounterpartIndividualResponse.validate_raw(obj: obj.individual) + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.type.is_a?(Monite::CounterpartType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_individual_root_update_payload.rb b/lib/monite/types/counterpart_individual_root_update_payload.rb new file mode 100644 index 0000000..1adc559 --- /dev/null +++ b/lib/monite/types/counterpart_individual_root_update_payload.rb @@ -0,0 +1,110 @@ +# frozen_string_literal: true +require_relative "counterpart_individual_update_payload" +require_relative "language_code_enum" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class CounterpartIndividualRootUpdatePayload + # @return [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + attr_reader :default_billing_address_id + # @return [String] ID of the shipping address. + attr_reader :default_shipping_address_id + # @return [Monite::CounterpartIndividualUpdatePayload] + attr_reader :individual + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + attr_reader :tax_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param default_billing_address_id [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + # @param default_shipping_address_id [String] ID of the shipping address. + # @param individual [Monite::CounterpartIndividualUpdatePayload] + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartIndividualRootUpdatePayload] + def initialize(default_billing_address_id: OMIT, default_shipping_address_id: OMIT, individual:, language: OMIT, reminders_enabled: OMIT, tax_id: OMIT, additional_properties: nil) + @default_billing_address_id = default_billing_address_id if default_billing_address_id != OMIT + @default_shipping_address_id = default_shipping_address_id if default_shipping_address_id != OMIT + @individual = individual + @language = language if language != OMIT + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @additional_properties = additional_properties + @_field_set = { "default_billing_address_id": default_billing_address_id, "default_shipping_address_id": default_shipping_address_id, "individual": individual, "language": language, "reminders_enabled": reminders_enabled, "tax_id": tax_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# CounterpartIndividualRootUpdatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartIndividualRootUpdatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + default_billing_address_id = parsed_json["default_billing_address_id"] + default_shipping_address_id = parsed_json["default_shipping_address_id"] + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::CounterpartIndividualUpdatePayload.from_json(json_object: individual) + else + individual = nil + end + language = parsed_json["language"] + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + new( + default_billing_address_id: default_billing_address_id, + default_shipping_address_id: default_shipping_address_id, + individual: individual, + language: language, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartIndividualRootUpdatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.default_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_billing_address_id is not the expected type, validation failed.") + obj.default_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_shipping_address_id is not the expected type, validation failed.") + Monite::CounterpartIndividualUpdatePayload.validate_raw(obj: obj.individual) + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_individual_update_payload.rb b/lib/monite/types/counterpart_individual_update_payload.rb new file mode 100644 index 0000000..0550a16 --- /dev/null +++ b/lib/monite/types/counterpart_individual_update_payload.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class CounterpartIndividualUpdatePayload + # @return [String] The person's email address. + attr_reader :email + # @return [String] The person's first name. + attr_reader :first_name + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The person's last name. + attr_reader :last_name + # @return [String] The person's phone number. + attr_reader :phone + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + attr_reader :tag_ids + # @return [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The person's email address. + # @param first_name [String] The person's first name. + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param last_name [String] The person's last name. + # @param phone [String] The person's phone number. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + # @param title [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartIndividualUpdatePayload] + def initialize(email: OMIT, first_name: OMIT, is_customer: OMIT, is_vendor: OMIT, last_name: OMIT, phone: OMIT, tag_ids: OMIT, title: OMIT, additional_properties: nil) + @email = email if email != OMIT + @first_name = first_name if first_name != OMIT + @is_customer = is_customer if is_customer != OMIT + @is_vendor = is_vendor if is_vendor != OMIT + @last_name = last_name if last_name != OMIT + @phone = phone if phone != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "first_name": first_name, "is_customer": is_customer, "is_vendor": is_vendor, "last_name": last_name, "phone": phone, "tag_ids": tag_ids, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartIndividualUpdatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartIndividualUpdatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + first_name = parsed_json["first_name"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + tag_ids = parsed_json["tag_ids"] + title = parsed_json["title"] + new( + email: email, + first_name: first_name, + is_customer: is_customer, + is_vendor: is_vendor, + last_name: last_name, + phone: phone, + tag_ids: tag_ids, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartIndividualUpdatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name&.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.is_customer&.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor&.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.last_name&.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_organization_create_payload.rb b/lib/monite/types/counterpart_organization_create_payload.rb new file mode 100644 index 0000000..05d4275 --- /dev/null +++ b/lib/monite/types/counterpart_organization_create_payload.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true +require_relative "counterpart_address" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class CounterpartOrganizationCreatePayload + # @return [Monite::CounterpartAddress] The address of the organization. + attr_reader :address + # @return [String] The email address of the organization + attr_reader :email + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The legal name of the organization. + attr_reader :legal_name + # @return [String] The phone number of the organization + attr_reader :phone + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + attr_reader :tag_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address [Monite::CounterpartAddress] The address of the organization. + # @param email [String] The email address of the organization + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param legal_name [String] The legal name of the organization. + # @param phone [String] The phone number of the organization + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartOrganizationCreatePayload] + def initialize(address:, email: OMIT, is_customer:, is_vendor:, legal_name:, phone: OMIT, tag_ids: OMIT, additional_properties: nil) + @address = address + @email = email if email != OMIT + @is_customer = is_customer + @is_vendor = is_vendor + @legal_name = legal_name + @phone = phone if phone != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @additional_properties = additional_properties + @_field_set = { "address": address, "email": email, "is_customer": is_customer, "is_vendor": is_vendor, "legal_name": legal_name, "phone": phone, "tag_ids": tag_ids }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartOrganizationCreatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartOrganizationCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::CounterpartAddress.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + legal_name = parsed_json["legal_name"] + phone = parsed_json["phone"] + tag_ids = parsed_json["tag_ids"] + new( + address: address, + email: email, + is_customer: is_customer, + is_vendor: is_vendor, + legal_name: legal_name, + phone: phone, + tag_ids: tag_ids, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartOrganizationCreatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::CounterpartAddress.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.is_customer.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_organization_response.rb b/lib/monite/types/counterpart_organization_response.rb new file mode 100644 index 0000000..3caa59c --- /dev/null +++ b/lib/monite/types/counterpart_organization_response.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true +require_relative "counterpart_tag_schema" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class CounterpartOrganizationResponse + # @return [String] The email address of the organization + attr_reader :email + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The legal name of the organization. + attr_reader :legal_name + # @return [String] The phone number of the organization + attr_reader :phone + # @return [Array] The list of tags for this counterpart. + attr_reader :tags + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The email address of the organization + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param legal_name [String] The legal name of the organization. + # @param phone [String] The phone number of the organization + # @param tags [Array] The list of tags for this counterpart. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartOrganizationResponse] + def initialize(email: OMIT, is_customer:, is_vendor:, legal_name:, phone: OMIT, tags: OMIT, additional_properties: nil) + @email = email if email != OMIT + @is_customer = is_customer + @is_vendor = is_vendor + @legal_name = legal_name + @phone = phone if phone != OMIT + @tags = tags if tags != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "is_customer": is_customer, "is_vendor": is_vendor, "legal_name": legal_name, "phone": phone, "tags": tags }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartOrganizationResponse + # + # @param json_object [String] + # @return [Monite::CounterpartOrganizationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + legal_name = parsed_json["legal_name"] + phone = parsed_json["phone"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::CounterpartTagSchema.from_json(json_object: item) +end + new( + email: email, + is_customer: is_customer, + is_vendor: is_vendor, + legal_name: legal_name, + phone: phone, + tags: tags, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartOrganizationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.is_customer.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_organization_root_create_payload.rb b/lib/monite/types/counterpart_organization_root_create_payload.rb new file mode 100644 index 0000000..576cb69 --- /dev/null +++ b/lib/monite/types/counterpart_organization_root_create_payload.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require_relative "language_code_enum" +require_relative "counterpart_organization_create_payload" +require "ostruct" +require "json" + +module Monite +# This schema is used to create counterparts that are organizations (juridical +# persons). + class CounterpartOrganizationRootCreatePayload + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Monite::CounterpartOrganizationCreatePayload] + attr_reader :organization + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + attr_reader :tax_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param organization [Monite::CounterpartOrganizationCreatePayload] + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartOrganizationRootCreatePayload] + def initialize(language: OMIT, organization:, reminders_enabled: OMIT, tax_id: OMIT, additional_properties: nil) + @language = language if language != OMIT + @organization = organization + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @additional_properties = additional_properties + @_field_set = { "language": language, "organization": organization, "reminders_enabled": reminders_enabled, "tax_id": tax_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# CounterpartOrganizationRootCreatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartOrganizationRootCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + language = parsed_json["language"] + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::CounterpartOrganizationCreatePayload.from_json(json_object: organization) + else + organization = nil + end + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + new( + language: language, + organization: organization, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartOrganizationRootCreatePayload to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + Monite::CounterpartOrganizationCreatePayload.validate_raw(obj: obj.organization) + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_organization_root_response.rb b/lib/monite/types/counterpart_organization_root_response.rb new file mode 100644 index 0000000..a19d345 --- /dev/null +++ b/lib/monite/types/counterpart_organization_root_response.rb @@ -0,0 +1,168 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "language_code_enum" +require_relative "counterpart_organization_response" +require_relative "counterpart_type" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class CounterpartOrganizationRootResponse + # @return [String] Unique ID of the counterpart. + attr_reader :id + # @return [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :created_at + # @return [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :updated_at + # @return [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + attr_reader :created_automatically + # @return [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + attr_reader :default_billing_address_id + # @return [String] ID of the shipping address. + attr_reader :default_shipping_address_id + # @return [String] Entity user ID of counterpart creator. + attr_reader :created_by_entity_user_id + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Monite::CounterpartOrganizationResponse] + attr_reader :organization + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. + attr_reader :tax_id + # @return [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the counterpart. + # @param created_at [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param updated_at [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param created_automatically [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + # @param default_billing_address_id [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + # @param default_shipping_address_id [String] ID of the shipping address. + # @param created_by_entity_user_id [String] Entity user ID of counterpart creator. + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param organization [Monite::CounterpartOrganizationResponse] + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. + # @param type [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartOrganizationRootResponse] + def initialize(id:, created_at:, updated_at:, created_automatically: OMIT, default_billing_address_id: OMIT, default_shipping_address_id: OMIT, created_by_entity_user_id: OMIT, language: OMIT, organization:, reminders_enabled: OMIT, tax_id: OMIT, type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @created_automatically = created_automatically if created_automatically != OMIT + @default_billing_address_id = default_billing_address_id if default_billing_address_id != OMIT + @default_shipping_address_id = default_shipping_address_id if default_shipping_address_id != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @language = language if language != OMIT + @organization = organization + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_automatically": created_automatically, "default_billing_address_id": default_billing_address_id, "default_shipping_address_id": default_shipping_address_id, "created_by_entity_user_id": created_by_entity_user_id, "language": language, "organization": organization, "reminders_enabled": reminders_enabled, "tax_id": tax_id, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartOrganizationRootResponse + # + # @param json_object [String] + # @return [Monite::CounterpartOrganizationRootResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_automatically = parsed_json["created_automatically"] + default_billing_address_id = parsed_json["default_billing_address_id"] + default_shipping_address_id = parsed_json["default_shipping_address_id"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + language = parsed_json["language"] + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::CounterpartOrganizationResponse.from_json(json_object: organization) + else + organization = nil + end + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_automatically: created_automatically, + default_billing_address_id: default_billing_address_id, + default_shipping_address_id: default_shipping_address_id, + created_by_entity_user_id: created_by_entity_user_id, + language: language, + organization: organization, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartOrganizationRootResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_automatically&.is_a?(Boolean) != false || raise("Passed value for field obj.created_automatically is not the expected type, validation failed.") + obj.default_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_billing_address_id is not the expected type, validation failed.") + obj.default_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_shipping_address_id is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + Monite::CounterpartOrganizationResponse.validate_raw(obj: obj.organization) + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.type.is_a?(Monite::CounterpartType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_organization_root_update_payload.rb b/lib/monite/types/counterpart_organization_root_update_payload.rb new file mode 100644 index 0000000..f348f35 --- /dev/null +++ b/lib/monite/types/counterpart_organization_root_update_payload.rb @@ -0,0 +1,111 @@ +# frozen_string_literal: true +require_relative "language_code_enum" +require_relative "counterpart_organization_update_payload" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class CounterpartOrganizationRootUpdatePayload + # @return [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + attr_reader :default_billing_address_id + # @return [String] ID of the shipping address. + attr_reader :default_shipping_address_id + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Monite::CounterpartOrganizationUpdatePayload] + attr_reader :organization + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + attr_reader :tax_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param default_billing_address_id [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + # @param default_shipping_address_id [String] ID of the shipping address. + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param organization [Monite::CounterpartOrganizationUpdatePayload] + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. For identification +# purposes, this field may be required for counterparts that are not +# VAT-registered. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartOrganizationRootUpdatePayload] + def initialize(default_billing_address_id: OMIT, default_shipping_address_id: OMIT, language: OMIT, organization:, reminders_enabled: OMIT, tax_id: OMIT, additional_properties: nil) + @default_billing_address_id = default_billing_address_id if default_billing_address_id != OMIT + @default_shipping_address_id = default_shipping_address_id if default_shipping_address_id != OMIT + @language = language if language != OMIT + @organization = organization + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @additional_properties = additional_properties + @_field_set = { "default_billing_address_id": default_billing_address_id, "default_shipping_address_id": default_shipping_address_id, "language": language, "organization": organization, "reminders_enabled": reminders_enabled, "tax_id": tax_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# CounterpartOrganizationRootUpdatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartOrganizationRootUpdatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + default_billing_address_id = parsed_json["default_billing_address_id"] + default_shipping_address_id = parsed_json["default_shipping_address_id"] + language = parsed_json["language"] + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::CounterpartOrganizationUpdatePayload.from_json(json_object: organization) + else + organization = nil + end + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + new( + default_billing_address_id: default_billing_address_id, + default_shipping_address_id: default_shipping_address_id, + language: language, + organization: organization, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartOrganizationRootUpdatePayload to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.default_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_billing_address_id is not the expected type, validation failed.") + obj.default_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_shipping_address_id is not the expected type, validation failed.") + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + Monite::CounterpartOrganizationUpdatePayload.validate_raw(obj: obj.organization) + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_organization_update_payload.rb b/lib/monite/types/counterpart_organization_update_payload.rb new file mode 100644 index 0000000..85e771b --- /dev/null +++ b/lib/monite/types/counterpart_organization_update_payload.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class CounterpartOrganizationUpdatePayload + # @return [String] The email address of the organization. + attr_reader :email + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The legal name of the organization. + attr_reader :legal_name + # @return [String] The phone number of the organization. + attr_reader :phone + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + attr_reader :tag_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The email address of the organization. + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param legal_name [String] The legal name of the organization. + # @param phone [String] The phone number of the organization. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this counterpart. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartOrganizationUpdatePayload] + def initialize(email: OMIT, is_customer: OMIT, is_vendor: OMIT, legal_name: OMIT, phone: OMIT, tag_ids: OMIT, additional_properties: nil) + @email = email if email != OMIT + @is_customer = is_customer if is_customer != OMIT + @is_vendor = is_vendor if is_vendor != OMIT + @legal_name = legal_name if legal_name != OMIT + @phone = phone if phone != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "is_customer": is_customer, "is_vendor": is_vendor, "legal_name": legal_name, "phone": phone, "tag_ids": tag_ids }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartOrganizationUpdatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartOrganizationUpdatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + legal_name = parsed_json["legal_name"] + phone = parsed_json["phone"] + tag_ids = parsed_json["tag_ids"] + new( + email: email, + is_customer: is_customer, + is_vendor: is_vendor, + legal_name: legal_name, + phone: phone, + tag_ids: tag_ids, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartOrganizationUpdatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.is_customer&.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor&.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.legal_name&.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_pagination_response.rb b/lib/monite/types/counterpart_pagination_response.rb new file mode 100644 index 0000000..e2e29b9 --- /dev/null +++ b/lib/monite/types/counterpart_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "counterpart_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of counterparts + class CounterpartPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartPaginationResponse + # + # @param json_object [String] + # @return [Monite::CounterpartPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CounterpartResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_address.rb b/lib/monite/types/counterpart_raw_address.rb new file mode 100644 index 0000000..66edb93 --- /dev/null +++ b/lib/monite/types/counterpart_raw_address.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# Address information. + class CounterpartRawAddress + # @return [String] City name. + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawAddress] + def initialize(city: OMIT, country: OMIT, line_1: OMIT, line_2: OMIT, postal_code: OMIT, state: OMIT, additional_properties: nil) + @city = city if city != OMIT + @country = country if country != OMIT + @line_1 = line_1 if line_1 != OMIT + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code if postal_code != OMIT + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawAddress + # + # @param json_object [String] + # @return [Monite::CounterpartRawAddress] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawAddress to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1&.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code&.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_address_update_request.rb b/lib/monite/types/counterpart_raw_address_update_request.rb new file mode 100644 index 0000000..aa91574 --- /dev/null +++ b/lib/monite/types/counterpart_raw_address_update_request.rb @@ -0,0 +1,95 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# Address information. + class CounterpartRawAddressUpdateRequest + # @return [String] City name. + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawAddressUpdateRequest] + def initialize(city: OMIT, country: OMIT, line_1: OMIT, line_2: OMIT, postal_code: OMIT, state: OMIT, additional_properties: nil) + @city = city if city != OMIT + @country = country if country != OMIT + @line_1 = line_1 if line_1 != OMIT + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code if postal_code != OMIT + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawAddressUpdateRequest + # + # @param json_object [String] + # @return [Monite::CounterpartRawAddressUpdateRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawAddressUpdateRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1&.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code&.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_bank_account.rb b/lib/monite/types/counterpart_raw_bank_account.rb new file mode 100644 index 0000000..edf14ac --- /dev/null +++ b/lib/monite/types/counterpart_raw_bank_account.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class CounterpartRawBankAccount + # @return [String] Vendor's bank account name. + attr_reader :account_holder_name + # @return [String] Vendor's bank account number, IBAN, or similar (if specified in the payable +# document). + attr_reader :account_number + # @return [String] SWIFT code (BIC) of the vendor's bank. + attr_reader :bic + # @return [String] required for non-GB bank accounts + attr_reader :iban + # @return [String] required for GB bank accounts + attr_reader :sort_code + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param account_holder_name [String] Vendor's bank account name. + # @param account_number [String] Vendor's bank account number, IBAN, or similar (if specified in the payable +# document). + # @param bic [String] SWIFT code (BIC) of the vendor's bank. + # @param iban [String] required for non-GB bank accounts + # @param sort_code [String] required for GB bank accounts + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawBankAccount] + def initialize(account_holder_name: OMIT, account_number: OMIT, bic: OMIT, iban: OMIT, sort_code: OMIT, additional_properties: nil) + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bic = bic if bic != OMIT + @iban = iban if iban != OMIT + @sort_code = sort_code if sort_code != OMIT + @additional_properties = additional_properties + @_field_set = { "account_holder_name": account_holder_name, "account_number": account_number, "bic": bic, "iban": iban, "sort_code": sort_code }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawBankAccount + # + # @param json_object [String] + # @return [Monite::CounterpartRawBankAccount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bic = parsed_json["bic"] + iban = parsed_json["iban"] + sort_code = parsed_json["sort_code"] + new( + account_holder_name: account_holder_name, + account_number: account_number, + bic: bic, + iban: iban, + sort_code: sort_code, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawBankAccount to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_bank_account_update_request.rb b/lib/monite/types/counterpart_raw_bank_account_update_request.rb new file mode 100644 index 0000000..a26a208 --- /dev/null +++ b/lib/monite/types/counterpart_raw_bank_account_update_request.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class CounterpartRawBankAccountUpdateRequest + # @return [String] Vendor's bank account name. + attr_reader :account_holder_name + # @return [String] Vendor's bank account number, IBAN, or similar (if specified in the payable +# document). + attr_reader :account_number + # @return [String] SWIFT code (BIC) of the vendor's bank. + attr_reader :bic + # @return [String] required for non-GB bank accounts + attr_reader :iban + # @return [String] required for GB bank accounts + attr_reader :sort_code + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param account_holder_name [String] Vendor's bank account name. + # @param account_number [String] Vendor's bank account number, IBAN, or similar (if specified in the payable +# document). + # @param bic [String] SWIFT code (BIC) of the vendor's bank. + # @param iban [String] required for non-GB bank accounts + # @param sort_code [String] required for GB bank accounts + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawBankAccountUpdateRequest] + def initialize(account_holder_name: OMIT, account_number: OMIT, bic: OMIT, iban: OMIT, sort_code: OMIT, additional_properties: nil) + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bic = bic if bic != OMIT + @iban = iban if iban != OMIT + @sort_code = sort_code if sort_code != OMIT + @additional_properties = additional_properties + @_field_set = { "account_holder_name": account_holder_name, "account_number": account_number, "bic": bic, "iban": iban, "sort_code": sort_code }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# CounterpartRawBankAccountUpdateRequest + # + # @param json_object [String] + # @return [Monite::CounterpartRawBankAccountUpdateRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bic = parsed_json["bic"] + iban = parsed_json["iban"] + sort_code = parsed_json["sort_code"] + new( + account_holder_name: account_holder_name, + account_number: account_number, + bic: bic, + iban: iban, + sort_code: sort_code, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawBankAccountUpdateRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_data.rb b/lib/monite/types/counterpart_raw_data.rb new file mode 100644 index 0000000..27da3ae --- /dev/null +++ b/lib/monite/types/counterpart_raw_data.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true +require_relative "counterpart_raw_address" +require_relative "counterpart_raw_bank_account" +require_relative "counterpart_raw_vat_id" +require "ostruct" +require "json" + +module Monite + class CounterpartRawData + # @return [Monite::CounterpartRawAddress] The address of the vendor or supplier. + attr_reader :address + # @return [Monite::CounterpartRawBankAccount] Object representing counterpart bank account. + attr_reader :bank_account + # @return [String] The email address of the organization + attr_reader :email + # @return [String] Vendor or supplier name. + attr_reader :name + # @return [String] The phone number of the organization + attr_reader :phone + # @return [String] The tax id of the counterpart. + attr_reader :tax_id + # @return [Monite::CounterpartRawVatId] VAT ID of the vendor or supplier which was used in the invoice. + attr_reader :vat_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address [Monite::CounterpartRawAddress] The address of the vendor or supplier. + # @param bank_account [Monite::CounterpartRawBankAccount] Object representing counterpart bank account. + # @param email [String] The email address of the organization + # @param name [String] Vendor or supplier name. + # @param phone [String] The phone number of the organization + # @param tax_id [String] The tax id of the counterpart. + # @param vat_id [Monite::CounterpartRawVatId] VAT ID of the vendor or supplier which was used in the invoice. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawData] + def initialize(address: OMIT, bank_account: OMIT, email: OMIT, name: OMIT, phone: OMIT, tax_id: OMIT, vat_id: OMIT, additional_properties: nil) + @address = address if address != OMIT + @bank_account = bank_account if bank_account != OMIT + @email = email if email != OMIT + @name = name if name != OMIT + @phone = phone if phone != OMIT + @tax_id = tax_id if tax_id != OMIT + @vat_id = vat_id if vat_id != OMIT + @additional_properties = additional_properties + @_field_set = { "address": address, "bank_account": bank_account, "email": email, "name": name, "phone": phone, "tax_id": tax_id, "vat_id": vat_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawData + # + # @param json_object [String] + # @return [Monite::CounterpartRawData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::CounterpartRawAddress.from_json(json_object: address) + else + address = nil + end + unless parsed_json["bank_account"].nil? + bank_account = parsed_json["bank_account"].to_json + bank_account = Monite::CounterpartRawBankAccount.from_json(json_object: bank_account) + else + bank_account = nil + end + email = parsed_json["email"] + name = parsed_json["name"] + phone = parsed_json["phone"] + tax_id = parsed_json["tax_id"] + unless parsed_json["vat_id"].nil? + vat_id = parsed_json["vat_id"].to_json + vat_id = Monite::CounterpartRawVatId.from_json(json_object: vat_id) + else + vat_id = nil + end + new( + address: address, + bank_account: bank_account, + email: email, + name: name, + phone: phone, + tax_id: tax_id, + vat_id: vat_id, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.address.nil? || Monite::CounterpartRawAddress.validate_raw(obj: obj.address) + obj.bank_account.nil? || Monite::CounterpartRawBankAccount.validate_raw(obj: obj.bank_account) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.vat_id.nil? || Monite::CounterpartRawVatId.validate_raw(obj: obj.vat_id) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_data_update_request.rb b/lib/monite/types/counterpart_raw_data_update_request.rb new file mode 100644 index 0000000..028c987 --- /dev/null +++ b/lib/monite/types/counterpart_raw_data_update_request.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true +require_relative "counterpart_raw_address_update_request" +require_relative "counterpart_raw_bank_account_update_request" +require_relative "counterpart_raw_vat_id_update_request" +require "ostruct" +require "json" + +module Monite + class CounterpartRawDataUpdateRequest + # @return [Monite::CounterpartRawAddressUpdateRequest] The address of the vendor or supplier. + attr_reader :address + # @return [Monite::CounterpartRawBankAccountUpdateRequest] Object representing counterpart bank account. + attr_reader :bank_account + # @return [String] The email address of the organization + attr_reader :email + # @return [String] Vendor or supplier name. + attr_reader :name + # @return [String] The phone number of the organization + attr_reader :phone + # @return [String] The tax id of the counterpart. + attr_reader :tax_id + # @return [Monite::CounterpartRawVatIdUpdateRequest] VAT ID of the vendor or supplier which was used in the invoice. + attr_reader :vat_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address [Monite::CounterpartRawAddressUpdateRequest] The address of the vendor or supplier. + # @param bank_account [Monite::CounterpartRawBankAccountUpdateRequest] Object representing counterpart bank account. + # @param email [String] The email address of the organization + # @param name [String] Vendor or supplier name. + # @param phone [String] The phone number of the organization + # @param tax_id [String] The tax id of the counterpart. + # @param vat_id [Monite::CounterpartRawVatIdUpdateRequest] VAT ID of the vendor or supplier which was used in the invoice. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawDataUpdateRequest] + def initialize(address: OMIT, bank_account: OMIT, email: OMIT, name: OMIT, phone: OMIT, tax_id: OMIT, vat_id: OMIT, additional_properties: nil) + @address = address if address != OMIT + @bank_account = bank_account if bank_account != OMIT + @email = email if email != OMIT + @name = name if name != OMIT + @phone = phone if phone != OMIT + @tax_id = tax_id if tax_id != OMIT + @vat_id = vat_id if vat_id != OMIT + @additional_properties = additional_properties + @_field_set = { "address": address, "bank_account": bank_account, "email": email, "name": name, "phone": phone, "tax_id": tax_id, "vat_id": vat_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawDataUpdateRequest + # + # @param json_object [String] + # @return [Monite::CounterpartRawDataUpdateRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::CounterpartRawAddressUpdateRequest.from_json(json_object: address) + else + address = nil + end + unless parsed_json["bank_account"].nil? + bank_account = parsed_json["bank_account"].to_json + bank_account = Monite::CounterpartRawBankAccountUpdateRequest.from_json(json_object: bank_account) + else + bank_account = nil + end + email = parsed_json["email"] + name = parsed_json["name"] + phone = parsed_json["phone"] + tax_id = parsed_json["tax_id"] + unless parsed_json["vat_id"].nil? + vat_id = parsed_json["vat_id"].to_json + vat_id = Monite::CounterpartRawVatIdUpdateRequest.from_json(json_object: vat_id) + else + vat_id = nil + end + new( + address: address, + bank_account: bank_account, + email: email, + name: name, + phone: phone, + tax_id: tax_id, + vat_id: vat_id, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawDataUpdateRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.address.nil? || Monite::CounterpartRawAddressUpdateRequest.validate_raw(obj: obj.address) + obj.bank_account.nil? || Monite::CounterpartRawBankAccountUpdateRequest.validate_raw(obj: obj.bank_account) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.vat_id.nil? || Monite::CounterpartRawVatIdUpdateRequest.validate_raw(obj: obj.vat_id) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_vat_id.rb b/lib/monite/types/counterpart_raw_vat_id.rb new file mode 100644 index 0000000..c7b655f --- /dev/null +++ b/lib/monite/types/counterpart_raw_vat_id.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class CounterpartRawVatId + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [String] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param country [Monite::AllowedCountries] + # @param type [String] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawVatId] + def initialize(country: OMIT, type: OMIT, value: OMIT, additional_properties: nil) + @country = country if country != OMIT + @type = type if type != OMIT + @value = value if value != OMIT + @additional_properties = additional_properties + @_field_set = { "country": country, "type": type, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawVatId + # + # @param json_object [String] + # @return [Monite::CounterpartRawVatId] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + country = parsed_json["country"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + country: country, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawVatId to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_raw_vat_id_update_request.rb b/lib/monite/types/counterpart_raw_vat_id_update_request.rb new file mode 100644 index 0000000..33773a6 --- /dev/null +++ b/lib/monite/types/counterpart_raw_vat_id_update_request.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class CounterpartRawVatIdUpdateRequest + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [String] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param country [Monite::AllowedCountries] + # @param type [String] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartRawVatIdUpdateRequest] + def initialize(country: OMIT, type: OMIT, value: OMIT, additional_properties: nil) + @country = country if country != OMIT + @type = type if type != OMIT + @value = value if value != OMIT + @additional_properties = additional_properties + @_field_set = { "country": country, "type": type, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartRawVatIdUpdateRequest + # + # @param json_object [String] + # @return [Monite::CounterpartRawVatIdUpdateRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + country = parsed_json["country"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + country: country, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartRawVatIdUpdateRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value&.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_response.rb b/lib/monite/types/counterpart_response.rb new file mode 100644 index 0000000..15d76ce --- /dev/null +++ b/lib/monite/types/counterpart_response.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "json" +require_relative "counterpart_individual_root_response" +require_relative "counterpart_organization_root_response" + +module Monite +# A Counterpart object contains information about an organization (juridical +# person) or +# individual (natural person) that provides goods and services to or buys them +# from an +# [SME](https://docs.monite.com/docs/glossary#sme). + class CounterpartResponse + + +# Deserialize a JSON object to an instance of CounterpartResponse + # + # @param json_object [String] + # @return [Monite::CounterpartResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::CounterpartIndividualRootResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::CounterpartIndividualRootResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::CounterpartOrganizationRootResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::CounterpartOrganizationRootResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::CounterpartIndividualRootResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::CounterpartOrganizationRootResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_tag_category.rb b/lib/monite/types/counterpart_tag_category.rb new file mode 100644 index 0000000..9593d7c --- /dev/null +++ b/lib/monite/types/counterpart_tag_category.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Monite + class CounterpartTagCategory + + DOCUMENT_TYPE = "document_type" + DEPARTMENT = "department" + PROJECT = "project" + COST_CENTER = "cost_center" + VENDOR_TYPE = "vendor_type" + PAYMENT_METHOD = "payment_method" + APPROVAL_STATUS = "approval_status" + + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_tag_schema.rb b/lib/monite/types/counterpart_tag_schema.rb new file mode 100644 index 0000000..53d21a0 --- /dev/null +++ b/lib/monite/types/counterpart_tag_schema.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "counterpart_tag_category" +require "ostruct" +require "json" + +module Monite +# Represents a user-defined tag that can be assigned to resources to filter them. + class CounterpartTagSchema + # @return [String] A unique ID of this tag. + attr_reader :id + # @return [DateTime] Date and time when the tag was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :created_at + # @return [DateTime] Date and time when the tag was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :updated_at + # @return [Monite::CounterpartTagCategory] The tag category. + attr_reader :category + # @return [String] ID of the user who created the tag. + attr_reader :created_by_entity_user_id + # @return [String] The tag description. + attr_reader :description + # @return [String] The tag name. + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of this tag. + # @param created_at [DateTime] Date and time when the tag was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param updated_at [DateTime] Date and time when the tag was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param category [Monite::CounterpartTagCategory] The tag category. + # @param created_by_entity_user_id [String] ID of the user who created the tag. + # @param description [String] The tag description. + # @param name [String] The tag name. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartTagSchema] + def initialize(id:, created_at:, updated_at:, category: OMIT, created_by_entity_user_id: OMIT, description: OMIT, name:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @category = category if category != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @description = description if description != OMIT + @name = name + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "category": category, "created_by_entity_user_id": created_by_entity_user_id, "description": description, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartTagSchema + # + # @param json_object [String] + # @return [Monite::CounterpartTagSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + category = parsed_json["category"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + description = parsed_json["description"] + name = parsed_json["name"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + category: category, + created_by_entity_user_id: created_by_entity_user_id, + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartTagSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.category&.is_a?(Monite::CounterpartTagCategory) != false || raise("Passed value for field obj.category is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_type.rb b/lib/monite/types/counterpart_type.rb new file mode 100644 index 0000000..9e4992e --- /dev/null +++ b/lib/monite/types/counterpart_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class CounterpartType + + INDIVIDUAL = "individual" + ORGANIZATION = "organization" + + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_update_payload.rb b/lib/monite/types/counterpart_update_payload.rb new file mode 100644 index 0000000..4c04e4f --- /dev/null +++ b/lib/monite/types/counterpart_update_payload.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true +require "json" +require_relative "counterpart_individual_root_update_payload" +require_relative "counterpart_organization_root_update_payload" + +module Monite +# This schema is used to update existing counterparts (organizations or +# individuals). + class CounterpartUpdatePayload + + +# Deserialize a JSON object to an instance of CounterpartUpdatePayload + # + # @param json_object [String] + # @return [Monite::CounterpartUpdatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::CounterpartIndividualRootUpdatePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::CounterpartIndividualRootUpdatePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::CounterpartOrganizationRootUpdatePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::CounterpartOrganizationRootUpdatePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::CounterpartIndividualRootUpdatePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::CounterpartOrganizationRootUpdatePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_vat_id_resource_list.rb b/lib/monite/types/counterpart_vat_id_resource_list.rb new file mode 100644 index 0000000..612d1b0 --- /dev/null +++ b/lib/monite/types/counterpart_vat_id_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "counterpart_vat_id_response" +require "ostruct" +require "json" + +module Monite + class CounterpartVatIdResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartVatIdResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of CounterpartVatIdResourceList + # + # @param json_object [String] + # @return [Monite::CounterpartVatIdResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CounterpartVatIdResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of CounterpartVatIdResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/counterpart_vat_id_response.rb b/lib/monite/types/counterpart_vat_id_response.rb new file mode 100644 index 0000000..1920e15 --- /dev/null +++ b/lib/monite/types/counterpart_vat_id_response.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "vat_id_type_enum" +require "ostruct" +require "json" + +module Monite + class CounterpartVatIdResponse + # @return [String] + attr_reader :id + # @return [String] + attr_reader :counterpart_id + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [Monite::VatIdTypeEnum] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CounterpartVatIdResponse] + def initialize(id:, counterpart_id:, country: OMIT, type: OMIT, value:, additional_properties: nil) + @id = id + @counterpart_id = counterpart_id + @country = country if country != OMIT + @type = type if type != OMIT + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "counterpart_id": counterpart_id, "country": country, "type": type, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CounterpartVatIdResponse + # + # @param json_object [String] + # @return [Monite::CounterpartVatIdResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + counterpart_id = parsed_json["counterpart_id"] + country = parsed_json["country"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + id: id, + counterpart_id: counterpart_id, + country: country, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of CounterpartVatIdResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.type&.is_a?(Monite::VatIdTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/create_export_task_response_schema.rb b/lib/monite/types/create_export_task_response_schema.rb new file mode 100644 index 0000000..f86c7df --- /dev/null +++ b/lib/monite/types/create_export_task_response_schema.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class CreateExportTaskResponseSchema + # @return [String] + attr_reader :id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreateExportTaskResponseSchema] + def initialize(id:, additional_properties: nil) + @id = id + @additional_properties = additional_properties + @_field_set = { "id": id } + end +# Deserialize a JSON object to an instance of CreateExportTaskResponseSchema + # + # @param json_object [String] + # @return [Monite::CreateExportTaskResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + new(id: id, additional_properties: struct) + end +# Serialize an instance of CreateExportTaskResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/create_onboarding_link_request.rb b/lib/monite/types/create_onboarding_link_request.rb new file mode 100644 index 0000000..ee221e0 --- /dev/null +++ b/lib/monite/types/create_onboarding_link_request.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require_relative "recipient" +require "ostruct" +require "json" + +module Monite + class CreateOnboardingLinkRequest + # @return [Monite::Recipient] + attr_reader :recipient + # @return [String] + attr_reader :refresh_url + # @return [String] + attr_reader :return_url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param recipient [Monite::Recipient] + # @param refresh_url [String] + # @param return_url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreateOnboardingLinkRequest] + def initialize(recipient:, refresh_url:, return_url:, additional_properties: nil) + @recipient = recipient + @refresh_url = refresh_url + @return_url = return_url + @additional_properties = additional_properties + @_field_set = { "recipient": recipient, "refresh_url": refresh_url, "return_url": return_url } + end +# Deserialize a JSON object to an instance of CreateOnboardingLinkRequest + # + # @param json_object [String] + # @return [Monite::CreateOnboardingLinkRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["recipient"].nil? + recipient = parsed_json["recipient"].to_json + recipient = Monite::Recipient.from_json(json_object: recipient) + else + recipient = nil + end + refresh_url = parsed_json["refresh_url"] + return_url = parsed_json["return_url"] + new( + recipient: recipient, + refresh_url: refresh_url, + return_url: return_url, + additional_properties: struct + ) + end +# Serialize an instance of CreateOnboardingLinkRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::Recipient.validate_raw(obj: obj.recipient) + obj.refresh_url.is_a?(String) != false || raise("Passed value for field obj.refresh_url is not the expected type, validation failed.") + obj.return_url.is_a?(String) != false || raise("Passed value for field obj.return_url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_cursor_fields.rb b/lib/monite/types/credit_note_cursor_fields.rb new file mode 100644 index 0000000..025ceea --- /dev/null +++ b/lib/monite/types/credit_note_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class CreditNoteCursorFields + + ID = "id" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_dimension_enum.rb b/lib/monite/types/credit_note_dimension_enum.rb new file mode 100644 index 0000000..340a516 --- /dev/null +++ b/lib/monite/types/credit_note_dimension_enum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite + class CreditNoteDimensionEnum + + CREATED_AT = "created_at" + STATUS = "status" + COUNTERPART_ID = "counterpart_id" + CURRENCY = "currency" + ISSUED_AT = "issued_at" + PROJECT_ID = "project_id" + + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_line_item_create_request.rb b/lib/monite/types/credit_note_line_item_create_request.rb new file mode 100644 index 0000000..20c3545 --- /dev/null +++ b/lib/monite/types/credit_note_line_item_create_request.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Schema for creating a new credit note line item. + class CreditNoteLineItemCreateRequest + # @return [String] Detailed description of the line item + attr_reader :description + # @return [String] Name or title of the line item + attr_reader :name + # @return [Float] Quantity of items + attr_reader :quantity + # @return [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :tax + # @return [String] Unit of measurement + attr_reader :unit + # @return [Integer] Price per unit in smallest currency unit (e.g. cents) + attr_reader :unit_price + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] Detailed description of the line item + # @param name [String] Name or title of the line item + # @param quantity [Float] Quantity of items + # @param tax [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param unit [String] Unit of measurement + # @param unit_price [Integer] Price per unit in smallest currency unit (e.g. cents) + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreditNoteLineItemCreateRequest] + def initialize(description: OMIT, name: OMIT, quantity: OMIT, tax: OMIT, unit: OMIT, unit_price: OMIT, additional_properties: nil) + @description = description if description != OMIT + @name = name if name != OMIT + @quantity = quantity if quantity != OMIT + @tax = tax if tax != OMIT + @unit = unit if unit != OMIT + @unit_price = unit_price if unit_price != OMIT + @additional_properties = additional_properties + @_field_set = { "description": description, "name": name, "quantity": quantity, "tax": tax, "unit": unit, "unit_price": unit_price }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CreditNoteLineItemCreateRequest + # + # @param json_object [String] + # @return [Monite::CreditNoteLineItemCreateRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + name = parsed_json["name"] + quantity = parsed_json["quantity"] + tax = parsed_json["tax"] + unit = parsed_json["unit"] + unit_price = parsed_json["unit_price"] + new( + description: description, + name: name, + quantity: quantity, + tax: tax, + unit: unit, + unit_price: unit_price, + additional_properties: struct + ) + end +# Serialize an instance of CreditNoteLineItemCreateRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.unit_price&.is_a?(Integer) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_line_item_cursor_fields.rb b/lib/monite/types/credit_note_line_item_cursor_fields.rb new file mode 100644 index 0000000..fdc9cc9 --- /dev/null +++ b/lib/monite/types/credit_note_line_item_cursor_fields.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite + class CreditNoteLineItemCursorFields + + ID = "id" + CREATED_AT = "created_at" + NAME = "name" + TOTAL = "total" + QUANTITY = "quantity" + UNIT_PRICE = "unit_price" + + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_line_item_pagination_response.rb b/lib/monite/types/credit_note_line_item_pagination_response.rb new file mode 100644 index 0000000..9b72e26 --- /dev/null +++ b/lib/monite/types/credit_note_line_item_pagination_response.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true +require_relative "credit_note_line_item_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of credit note line items. + class CreditNoteLineItemPaginationResponse + # @return [Array] List of credit note line items for the current page + attr_reader :data + # @return [String] Token to retrieve the next page of results + attr_reader :next_pagination_token + # @return [String] Token to retrieve the previous page of results + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] List of credit note line items for the current page + # @param next_pagination_token [String] Token to retrieve the next page of results + # @param prev_pagination_token [String] Token to retrieve the previous page of results + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreditNoteLineItemPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CreditNoteLineItemPaginationResponse + # + # @param json_object [String] + # @return [Monite::CreditNoteLineItemPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CreditNoteLineItemResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of CreditNoteLineItemPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_line_item_response.rb b/lib/monite/types/credit_note_line_item_response.rb new file mode 100644 index 0000000..3e7964c --- /dev/null +++ b/lib/monite/types/credit_note_line_item_response.rb @@ -0,0 +1,159 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite +# Schema for credit note line item response. Includes all fields that can be +# returned from the API. + class CreditNoteLineItemResponse + # @return [String] Unique identifier of the line item + attr_reader :id + # @return [DateTime] Timestamp when the line item was created + attr_reader :created_at + # @return [DateTime] Timestamp when the line item was last updated + attr_reader :updated_at + # @return [String] ID of the user who created the line item + attr_reader :created_by_user_id + # @return [String] ID of the parent credit note + attr_reader :credit_note_id + # @return [String] Detailed description of the line item + attr_reader :description + # @return [String] Name or title of the line item + attr_reader :name + # @return [Float] Quantity of items + attr_reader :quantity + # @return [Integer] Subtotal amount before tax + attr_reader :subtotal + # @return [Integer] Tax percentage + attr_reader :tax + # @return [Integer] Tax amount + attr_reader :tax_amount + # @return [Integer] Total amount including tax + attr_reader :total + # @return [String] Unit of measurement + attr_reader :unit + # @return [Integer] Price per unit in smallest currency unit + attr_reader :unit_price + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique identifier of the line item + # @param created_at [DateTime] Timestamp when the line item was created + # @param updated_at [DateTime] Timestamp when the line item was last updated + # @param created_by_user_id [String] ID of the user who created the line item + # @param credit_note_id [String] ID of the parent credit note + # @param description [String] Detailed description of the line item + # @param name [String] Name or title of the line item + # @param quantity [Float] Quantity of items + # @param subtotal [Integer] Subtotal amount before tax + # @param tax [Integer] Tax percentage + # @param tax_amount [Integer] Tax amount + # @param total [Integer] Total amount including tax + # @param unit [String] Unit of measurement + # @param unit_price [Integer] Price per unit in smallest currency unit + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreditNoteLineItemResponse] + def initialize(id:, created_at:, updated_at:, created_by_user_id: OMIT, credit_note_id:, description: OMIT, name: OMIT, quantity: OMIT, subtotal: OMIT, tax: OMIT, tax_amount: OMIT, total: OMIT, unit: OMIT, unit_price: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @created_by_user_id = created_by_user_id if created_by_user_id != OMIT + @credit_note_id = credit_note_id + @description = description if description != OMIT + @name = name if name != OMIT + @quantity = quantity if quantity != OMIT + @subtotal = subtotal if subtotal != OMIT + @tax = tax if tax != OMIT + @tax_amount = tax_amount if tax_amount != OMIT + @total = total if total != OMIT + @unit = unit if unit != OMIT + @unit_price = unit_price if unit_price != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_by_user_id": created_by_user_id, "credit_note_id": credit_note_id, "description": description, "name": name, "quantity": quantity, "subtotal": subtotal, "tax": tax, "tax_amount": tax_amount, "total": total, "unit": unit, "unit_price": unit_price }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CreditNoteLineItemResponse + # + # @param json_object [String] + # @return [Monite::CreditNoteLineItemResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_by_user_id = parsed_json["created_by_user_id"] + credit_note_id = parsed_json["credit_note_id"] + description = parsed_json["description"] + name = parsed_json["name"] + quantity = parsed_json["quantity"] + subtotal = parsed_json["subtotal"] + tax = parsed_json["tax"] + tax_amount = parsed_json["tax_amount"] + total = parsed_json["total"] + unit = parsed_json["unit"] + unit_price = parsed_json["unit_price"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_by_user_id: created_by_user_id, + credit_note_id: credit_note_id, + description: description, + name: name, + quantity: quantity, + subtotal: subtotal, + tax: tax, + tax_amount: tax_amount, + total: total, + unit: unit, + unit_price: unit_price, + additional_properties: struct + ) + end +# Serialize an instance of CreditNoteLineItemResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_user_id is not the expected type, validation failed.") + obj.credit_note_id.is_a?(String) != false || raise("Passed value for field obj.credit_note_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.tax_amount&.is_a?(Integer) != false || raise("Passed value for field obj.tax_amount is not the expected type, validation failed.") + obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.unit_price&.is_a?(Integer) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_metric_enum.rb b/lib/monite/types/credit_note_metric_enum.rb new file mode 100644 index 0000000..a9554a8 --- /dev/null +++ b/lib/monite/types/credit_note_metric_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class CreditNoteMetricEnum + + ID = "id" + TOTAL_AMOUNT = "total_amount" + + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_pagination_response.rb b/lib/monite/types/credit_note_pagination_response.rb new file mode 100644 index 0000000..faea7c2 --- /dev/null +++ b/lib/monite/types/credit_note_pagination_response.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true +require_relative "credit_note_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of credit notes. + class CreditNotePaginationResponse + # @return [Array] List of credit notes for the current page + attr_reader :data + # @return [String] Token to retrieve the next page of results + attr_reader :next_pagination_token + # @return [String] Token to retrieve the previous page of results + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] List of credit notes for the current page + # @param next_pagination_token [String] Token to retrieve the next page of results + # @param prev_pagination_token [String] Token to retrieve the previous page of results + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreditNotePaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CreditNotePaginationResponse + # + # @param json_object [String] + # @return [Monite::CreditNotePaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CreditNoteResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of CreditNotePaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_response.rb b/lib/monite/types/credit_note_response.rb new file mode 100644 index 0000000..dce251a --- /dev/null +++ b/lib/monite/types/credit_note_response.rb @@ -0,0 +1,295 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "currency_exchange_schema" +require_relative "tag_read_schema" +require "ostruct" +require "json" + +module Monite +# Schema for credit note response. Includes all fields that can be returned from +# the API. + class CreditNoteResponse + # @return [String] The unique identifier of the credit note + attr_reader :id + # @return [DateTime] Date and time when the credit note was created in the system + attr_reader :created_at + # @return [DateTime] Date and time of the last update to the credit note + attr_reader :updated_at + # @return [String] ID of the payable this credit note is based on + attr_reader :based_on + # @return [String] The document ID of the original payable that this credit note refers to + attr_reader :based_on_document_id + # @return [String] ID of the counterpart's address + attr_reader :counterpart_address_id + # @return [String] ID of the counterpart's bank account + attr_reader :counterpart_bank_account_id + # @return [String] ID of the counterpart + attr_reader :counterpart_id + # @return [String] ID of the counterpart's VAT registration + attr_reader :counterpart_vat_id_id + # @return [String] External system's user ID for the creator + attr_reader :created_by_external_user_id + # @return [String] Name of the external user who created the credit note + attr_reader :created_by_external_user_name + # @return [String] ID of the user who created the credit note + attr_reader :created_by_user_id + # @return [String] The currency code + attr_reader :currency + # @return [Monite::CurrencyExchangeSchema] + attr_reader :currency_exchange + # @return [String] Description of the credit note + attr_reader :description + # @return [String] The credit note's unique document number + attr_reader :document_id + # @return [String] The ID of the entity to which the credit note belongs + attr_reader :entity_id + # @return [String] The id of the credit note file stored in the file saver. + attr_reader :file_id + # @return [String] The URL of the credit note file stored in the file saver. + attr_reader :file_url + # @return [String] Date when the credit note was issued + attr_reader :issued_at + # @return [String] ID of the OCR processing request + attr_reader :ocr_request_id + # @return [String] Status of OCR processing + attr_reader :ocr_status + # @return [String] The origin or source system of the credit note + attr_reader :origin + # @return [String] ID of the associated project + attr_reader :project_id + # @return [String] Email address of the sender + attr_reader :sender + # @return [String] How the data was input (ocr/user_specified) + attr_reader :source_of_data + # @return [String] The current status of the credit note in its lifecycle + attr_reader :status + # @return [Integer] The subtotal amount before taxes + attr_reader :subtotal + # @return [Array] List of tags associated with this credit note + attr_reader :tags + # @return [Integer] The tax percentage + attr_reader :tax + # @return [Integer] The calculated tax amount + attr_reader :tax_amount + # @return [Integer] The total amount including taxes + attr_reader :total_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] The unique identifier of the credit note + # @param created_at [DateTime] Date and time when the credit note was created in the system + # @param updated_at [DateTime] Date and time of the last update to the credit note + # @param based_on [String] ID of the payable this credit note is based on + # @param based_on_document_id [String] The document ID of the original payable that this credit note refers to + # @param counterpart_address_id [String] ID of the counterpart's address + # @param counterpart_bank_account_id [String] ID of the counterpart's bank account + # @param counterpart_id [String] ID of the counterpart + # @param counterpart_vat_id_id [String] ID of the counterpart's VAT registration + # @param created_by_external_user_id [String] External system's user ID for the creator + # @param created_by_external_user_name [String] Name of the external user who created the credit note + # @param created_by_user_id [String] ID of the user who created the credit note + # @param currency [String] The currency code + # @param currency_exchange [Monite::CurrencyExchangeSchema] + # @param description [String] Description of the credit note + # @param document_id [String] The credit note's unique document number + # @param entity_id [String] The ID of the entity to which the credit note belongs + # @param file_id [String] The id of the credit note file stored in the file saver. + # @param file_url [String] The URL of the credit note file stored in the file saver. + # @param issued_at [String] Date when the credit note was issued + # @param ocr_request_id [String] ID of the OCR processing request + # @param ocr_status [String] Status of OCR processing + # @param origin [String] The origin or source system of the credit note + # @param project_id [String] ID of the associated project + # @param sender [String] Email address of the sender + # @param source_of_data [String] How the data was input (ocr/user_specified) + # @param status [String] The current status of the credit note in its lifecycle + # @param subtotal [Integer] The subtotal amount before taxes + # @param tags [Array] List of tags associated with this credit note + # @param tax [Integer] The tax percentage + # @param tax_amount [Integer] The calculated tax amount + # @param total_amount [Integer] The total amount including taxes + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreditNoteResponse] + def initialize(id:, created_at:, updated_at:, based_on: OMIT, based_on_document_id: OMIT, counterpart_address_id: OMIT, counterpart_bank_account_id: OMIT, counterpart_id: OMIT, counterpart_vat_id_id: OMIT, created_by_external_user_id: OMIT, created_by_external_user_name: OMIT, created_by_user_id: OMIT, currency: OMIT, currency_exchange: OMIT, description: OMIT, document_id: OMIT, entity_id:, file_id: OMIT, file_url: OMIT, issued_at: OMIT, ocr_request_id: OMIT, ocr_status: OMIT, origin:, project_id: OMIT, sender: OMIT, source_of_data:, status:, subtotal: OMIT, tags: OMIT, tax: OMIT, tax_amount: OMIT, total_amount: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @based_on = based_on if based_on != OMIT + @based_on_document_id = based_on_document_id if based_on_document_id != OMIT + @counterpart_address_id = counterpart_address_id if counterpart_address_id != OMIT + @counterpart_bank_account_id = counterpart_bank_account_id if counterpart_bank_account_id != OMIT + @counterpart_id = counterpart_id if counterpart_id != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @created_by_external_user_id = created_by_external_user_id if created_by_external_user_id != OMIT + @created_by_external_user_name = created_by_external_user_name if created_by_external_user_name != OMIT + @created_by_user_id = created_by_user_id if created_by_user_id != OMIT + @currency = currency if currency != OMIT + @currency_exchange = currency_exchange if currency_exchange != OMIT + @description = description if description != OMIT + @document_id = document_id if document_id != OMIT + @entity_id = entity_id + @file_id = file_id if file_id != OMIT + @file_url = file_url if file_url != OMIT + @issued_at = issued_at if issued_at != OMIT + @ocr_request_id = ocr_request_id if ocr_request_id != OMIT + @ocr_status = ocr_status if ocr_status != OMIT + @origin = origin + @project_id = project_id if project_id != OMIT + @sender = sender if sender != OMIT + @source_of_data = source_of_data + @status = status + @subtotal = subtotal if subtotal != OMIT + @tags = tags if tags != OMIT + @tax = tax if tax != OMIT + @tax_amount = tax_amount if tax_amount != OMIT + @total_amount = total_amount if total_amount != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "based_on": based_on, "based_on_document_id": based_on_document_id, "counterpart_address_id": counterpart_address_id, "counterpart_bank_account_id": counterpart_bank_account_id, "counterpart_id": counterpart_id, "counterpart_vat_id_id": counterpart_vat_id_id, "created_by_external_user_id": created_by_external_user_id, "created_by_external_user_name": created_by_external_user_name, "created_by_user_id": created_by_user_id, "currency": currency, "currency_exchange": currency_exchange, "description": description, "document_id": document_id, "entity_id": entity_id, "file_id": file_id, "file_url": file_url, "issued_at": issued_at, "ocr_request_id": ocr_request_id, "ocr_status": ocr_status, "origin": origin, "project_id": project_id, "sender": sender, "source_of_data": source_of_data, "status": status, "subtotal": subtotal, "tags": tags, "tax": tax, "tax_amount": tax_amount, "total_amount": total_amount }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CreditNoteResponse + # + # @param json_object [String] + # @return [Monite::CreditNoteResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + based_on = parsed_json["based_on"] + based_on_document_id = parsed_json["based_on_document_id"] + counterpart_address_id = parsed_json["counterpart_address_id"] + counterpart_bank_account_id = parsed_json["counterpart_bank_account_id"] + counterpart_id = parsed_json["counterpart_id"] + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + created_by_external_user_id = parsed_json["created_by_external_user_id"] + created_by_external_user_name = parsed_json["created_by_external_user_name"] + created_by_user_id = parsed_json["created_by_user_id"] + currency = parsed_json["currency"] + unless parsed_json["currency_exchange"].nil? + currency_exchange = parsed_json["currency_exchange"].to_json + currency_exchange = Monite::CurrencyExchangeSchema.from_json(json_object: currency_exchange) + else + currency_exchange = nil + end + description = parsed_json["description"] + document_id = parsed_json["document_id"] + entity_id = parsed_json["entity_id"] + file_id = parsed_json["file_id"] + file_url = parsed_json["file_url"] + issued_at = parsed_json["issued_at"] + ocr_request_id = parsed_json["ocr_request_id"] + ocr_status = parsed_json["ocr_status"] + origin = parsed_json["origin"] + project_id = parsed_json["project_id"] + sender = parsed_json["sender"] + source_of_data = parsed_json["source_of_data"] + status = parsed_json["status"] + subtotal = parsed_json["subtotal"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + tax = parsed_json["tax"] + tax_amount = parsed_json["tax_amount"] + total_amount = parsed_json["total_amount"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + based_on: based_on, + based_on_document_id: based_on_document_id, + counterpart_address_id: counterpart_address_id, + counterpart_bank_account_id: counterpart_bank_account_id, + counterpart_id: counterpart_id, + counterpart_vat_id_id: counterpart_vat_id_id, + created_by_external_user_id: created_by_external_user_id, + created_by_external_user_name: created_by_external_user_name, + created_by_user_id: created_by_user_id, + currency: currency, + currency_exchange: currency_exchange, + description: description, + document_id: document_id, + entity_id: entity_id, + file_id: file_id, + file_url: file_url, + issued_at: issued_at, + ocr_request_id: ocr_request_id, + ocr_status: ocr_status, + origin: origin, + project_id: project_id, + sender: sender, + source_of_data: source_of_data, + status: status, + subtotal: subtotal, + tags: tags, + tax: tax, + tax_amount: tax_amount, + total_amount: total_amount, + additional_properties: struct + ) + end +# Serialize an instance of CreditNoteResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.based_on&.is_a?(String) != false || raise("Passed value for field obj.based_on is not the expected type, validation failed.") + obj.based_on_document_id&.is_a?(String) != false || raise("Passed value for field obj.based_on_document_id is not the expected type, validation failed.") + obj.counterpart_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_address_id is not the expected type, validation failed.") + obj.counterpart_bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_bank_account_id is not the expected type, validation failed.") + obj.counterpart_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.created_by_external_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_external_user_id is not the expected type, validation failed.") + obj.created_by_external_user_name&.is_a?(String) != false || raise("Passed value for field obj.created_by_external_user_name is not the expected type, validation failed.") + obj.created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_user_id is not the expected type, validation failed.") + obj.currency&.is_a?(String) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.currency_exchange.nil? || Monite::CurrencyExchangeSchema.validate_raw(obj: obj.currency_exchange) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.file_id&.is_a?(String) != false || raise("Passed value for field obj.file_id is not the expected type, validation failed.") + obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") + obj.issued_at&.is_a?(String) != false || raise("Passed value for field obj.issued_at is not the expected type, validation failed.") + obj.ocr_request_id&.is_a?(String) != false || raise("Passed value for field obj.ocr_request_id is not the expected type, validation failed.") + obj.ocr_status&.is_a?(String) != false || raise("Passed value for field obj.ocr_status is not the expected type, validation failed.") + obj.origin.is_a?(String) != false || raise("Passed value for field obj.origin is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.sender&.is_a?(String) != false || raise("Passed value for field obj.sender is not the expected type, validation failed.") + obj.source_of_data.is_a?(String) != false || raise("Passed value for field obj.source_of_data is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.tax_amount&.is_a?(Integer) != false || raise("Passed value for field obj.tax_amount is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_response_payload.rb b/lib/monite/types/credit_note_response_payload.rb new file mode 100644 index 0000000..87de73c --- /dev/null +++ b/lib/monite/types/credit_note_response_payload.rb @@ -0,0 +1,509 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "receivables_representation_of_counterpart_address" +require_relative "receivable_counterpart_contact" +require_relative "receivable_counterpart_type" +require_relative "receivable_counterpart_vat_id_response" +require_relative "currency_enum" +require_relative "discount" +require_relative "credit_note_response_payload_entity" +require_relative "receivable_entity_address_schema" +require_relative "receivables_representation_of_entity_bank_account" +require_relative "receivable_entity_vat_id_response" +require_relative "language_code_enum" +require "date" +require_relative "response_item" +require_relative "credit_note_state_enum" +require_relative "tag_read_schema" +require_relative "total_vat_amount_item" +require_relative "vat_mode_enum" +require "ostruct" +require "json" + +module Monite + class CreditNoteResponsePayload + # @return [String] + attr_reader :id + # @return [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + attr_reader :updated_at + # @return [String] The unique ID of a previous document related to the receivable if applicable. + attr_reader :based_on + # @return [String] The unique document ID of a previous document related to the receivable if +# applicable. + attr_reader :based_on_document_id + # @return [String] The commercial terms of the receivable (e.g. The products must be delivered in X +# days). + attr_reader :commercial_condition_description + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address + # @return [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + attr_reader :counterpart_business_type + # @return [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + attr_reader :counterpart_contact + # @return [String] Unique ID of the counterpart. + attr_reader :counterpart_id + # @return [String] A legal name of a counterpart it is an organization or first and last name if it +# is an individual + attr_reader :counterpart_name + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address + # @return [String] The VAT/TAX ID of the counterpart. + attr_reader :counterpart_tax_id + # @return [Monite::ReceivableCounterpartType] The type of the counterpart. + attr_reader :counterpart_type + # @return [Monite::ReceivableCounterpartVatIdResponse] + attr_reader :counterpart_vat_id + # @return [Monite::CurrencyEnum] The currency used in the receivable. + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [Integer] Total price of the receivable with discounts before taxes [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :discounted_subtotal + # @return [String] The sequential code systematically assigned to invoices. + attr_reader :document_id + # @return [String] Optional field representing date until which invoice should be paid + attr_reader :due_date + # @return [Monite::CreditNoteResponsePayloadEntity] + attr_reader :entity + # @return [Monite::ReceivableEntityAddressSchema] + attr_reader :entity_address + # @return [Monite::ReceivablesRepresentationOfEntityBankAccount] + attr_reader :entity_bank_account + # @return [String] The entity user who created this document. + attr_reader :entity_user_id + # @return [Monite::ReceivableEntityVatIdResponse] + attr_reader :entity_vat_id + # @return [Monite::LanguageCodeEnum] The language of the customer-facing PDF file (`file_url`). The value matches the +# counterpart's `language` at the time when this PDF file was generated. + attr_reader :file_language + # @return [String] The receivable's PDF URL in the counterpart's default language. + attr_reader :file_url + # @return [DateTime] Optional field for the issue of the entry. + attr_reader :issue_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable. + attr_reader :memo + # @return [Monite::LanguageCodeEnum] The language of the entity's copy of the PDF file (`original_file_url`). The +# value matches the entity's `language` at the time when this PDF file was +# generated. + attr_reader :original_file_language + # @return [String] The receivable's PDF URL in the entity's default language. + attr_reader :original_file_url + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [String] Contain purchase order number. + attr_reader :purchase_order + # @return [Monite::CreditNoteStateEnum] The status of the Credit Note inside the receivable workflow. + attr_reader :status + # @return [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :subtotal + # @return [Array] The list of tags for this receivable. + attr_reader :tags + # @return [Integer] Total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Calculated as +# a subtotal + total_vat_amount. + attr_reader :total_amount + # @return [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :total_vat_amount + # @return [Array] List of total vat amount for each VAT, presented in receivable + attr_reader :total_vat_amounts + # @return [Integer] Total price of the receivable with tax withheld in minor units + attr_reader :total_withholding_tax + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + attr_reader :vat_mode + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + # @param based_on [String] The unique ID of a previous document related to the receivable if applicable. + # @param based_on_document_id [String] The unique document ID of a previous document related to the receivable if +# applicable. + # @param commercial_condition_description [String] The commercial terms of the receivable (e.g. The products must be delivered in X +# days). + # @param counterpart_billing_address [Monite::ReceivablesRepresentationOfCounterpartAddress] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_business_type [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + # @param counterpart_contact [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + # @param counterpart_id [String] Unique ID of the counterpart. + # @param counterpart_name [String] A legal name of a counterpart it is an organization or first and last name if it +# is an individual + # @param counterpart_shipping_address [Monite::ReceivablesRepresentationOfCounterpartAddress] Address where goods were shipped / where services were provided. + # @param counterpart_tax_id [String] The VAT/TAX ID of the counterpart. + # @param counterpart_type [Monite::ReceivableCounterpartType] The type of the counterpart. + # @param counterpart_vat_id [Monite::ReceivableCounterpartVatIdResponse] + # @param currency [Monite::CurrencyEnum] The currency used in the receivable. + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param discounted_subtotal [Integer] Total price of the receivable with discounts before taxes [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param document_id [String] The sequential code systematically assigned to invoices. + # @param due_date [String] Optional field representing date until which invoice should be paid + # @param entity [Monite::CreditNoteResponsePayloadEntity] + # @param entity_address [Monite::ReceivableEntityAddressSchema] + # @param entity_bank_account [Monite::ReceivablesRepresentationOfEntityBankAccount] + # @param entity_user_id [String] The entity user who created this document. + # @param entity_vat_id [Monite::ReceivableEntityVatIdResponse] + # @param file_language [Monite::LanguageCodeEnum] The language of the customer-facing PDF file (`file_url`). The value matches the +# counterpart's `language` at the time when this PDF file was generated. + # @param file_url [String] The receivable's PDF URL in the counterpart's default language. + # @param issue_date [DateTime] Optional field for the issue of the entry. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable. + # @param original_file_language [Monite::LanguageCodeEnum] The language of the entity's copy of the PDF file (`original_file_url`). The +# value matches the entity's `language` at the time when this PDF file was +# generated. + # @param original_file_url [String] The receivable's PDF URL in the entity's default language. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param project_id [String] A project related to current receivable + # @param purchase_order [String] Contain purchase order number. + # @param status [Monite::CreditNoteStateEnum] The status of the Credit Note inside the receivable workflow. + # @param subtotal [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param tags [Array] The list of tags for this receivable. + # @param total_amount [Integer] Total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Calculated as +# a subtotal + total_vat_amount. + # @param total_vat_amount [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param total_vat_amounts [Array] List of total vat amount for each VAT, presented in receivable + # @param total_withholding_tax [Integer] Total price of the receivable with tax withheld in minor units + # @param trade_name [String] Trade name of the entity + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CreditNoteResponsePayload] + def initialize(id:, created_at:, updated_at:, based_on: OMIT, based_on_document_id: OMIT, commercial_condition_description: OMIT, counterpart_billing_address: OMIT, counterpart_business_type: OMIT, counterpart_contact: OMIT, counterpart_id:, counterpart_name: OMIT, counterpart_shipping_address: OMIT, counterpart_tax_id: OMIT, counterpart_type:, counterpart_vat_id: OMIT, currency:, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, discounted_subtotal: OMIT, document_id: OMIT, due_date: OMIT, entity:, entity_address:, entity_bank_account: OMIT, entity_user_id: OMIT, entity_vat_id: OMIT, file_language:, file_url: OMIT, issue_date: OMIT, line_items:, memo: OMIT, original_file_language:, original_file_url: OMIT, partner_metadata: OMIT, project_id: OMIT, purchase_order: OMIT, status:, subtotal: OMIT, tags: OMIT, total_amount: OMIT, total_vat_amount:, total_vat_amounts: OMIT, total_withholding_tax: OMIT, trade_name: OMIT, vat_exempt: OMIT, vat_exemption_rationale: OMIT, vat_mode: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @based_on = based_on if based_on != OMIT + @based_on_document_id = based_on_document_id if based_on_document_id != OMIT + @commercial_condition_description = commercial_condition_description if commercial_condition_description != OMIT + @counterpart_billing_address = counterpart_billing_address if counterpart_billing_address != OMIT + @counterpart_business_type = counterpart_business_type if counterpart_business_type != OMIT + @counterpart_contact = counterpart_contact if counterpart_contact != OMIT + @counterpart_id = counterpart_id + @counterpart_name = counterpart_name if counterpart_name != OMIT + @counterpart_shipping_address = counterpart_shipping_address if counterpart_shipping_address != OMIT + @counterpart_tax_id = counterpart_tax_id if counterpart_tax_id != OMIT + @counterpart_type = counterpart_type + @counterpart_vat_id = counterpart_vat_id if counterpart_vat_id != OMIT + @currency = currency + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @discounted_subtotal = discounted_subtotal if discounted_subtotal != OMIT + @document_id = document_id if document_id != OMIT + @due_date = due_date if due_date != OMIT + @entity = entity + @entity_address = entity_address + @entity_bank_account = entity_bank_account if entity_bank_account != OMIT + @entity_user_id = entity_user_id if entity_user_id != OMIT + @entity_vat_id = entity_vat_id if entity_vat_id != OMIT + @file_language = file_language + @file_url = file_url if file_url != OMIT + @issue_date = issue_date if issue_date != OMIT + @line_items = line_items + @memo = memo if memo != OMIT + @original_file_language = original_file_language + @original_file_url = original_file_url if original_file_url != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @project_id = project_id if project_id != OMIT + @purchase_order = purchase_order if purchase_order != OMIT + @status = status + @subtotal = subtotal if subtotal != OMIT + @tags = tags if tags != OMIT + @total_amount = total_amount if total_amount != OMIT + @total_vat_amount = total_vat_amount + @total_vat_amounts = total_vat_amounts if total_vat_amounts != OMIT + @total_withholding_tax = total_withholding_tax if total_withholding_tax != OMIT + @trade_name = trade_name if trade_name != OMIT + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @vat_mode = vat_mode if vat_mode != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "based_on": based_on, "based_on_document_id": based_on_document_id, "commercial_condition_description": commercial_condition_description, "counterpart_billing_address": counterpart_billing_address, "counterpart_business_type": counterpart_business_type, "counterpart_contact": counterpart_contact, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, "counterpart_shipping_address": counterpart_shipping_address, "counterpart_tax_id": counterpart_tax_id, "counterpart_type": counterpart_type, "counterpart_vat_id": counterpart_vat_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "discounted_subtotal": discounted_subtotal, "document_id": document_id, "due_date": due_date, "entity": entity, "entity_address": entity_address, "entity_bank_account": entity_bank_account, "entity_user_id": entity_user_id, "entity_vat_id": entity_vat_id, "file_language": file_language, "file_url": file_url, "issue_date": issue_date, "line_items": line_items, "memo": memo, "original_file_language": original_file_language, "original_file_url": original_file_url, "partner_metadata": partner_metadata, "project_id": project_id, "purchase_order": purchase_order, "status": status, "subtotal": subtotal, "tags": tags, "total_amount": total_amount, "total_vat_amount": total_vat_amount, "total_vat_amounts": total_vat_amounts, "total_withholding_tax": total_withholding_tax, "trade_name": trade_name, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "vat_mode": vat_mode, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CreditNoteResponsePayload + # + # @param json_object [String] + # @return [Monite::CreditNoteResponsePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + based_on = parsed_json["based_on"] + based_on_document_id = parsed_json["based_on_document_id"] + commercial_condition_description = parsed_json["commercial_condition_description"] + unless parsed_json["counterpart_billing_address"].nil? + counterpart_billing_address = parsed_json["counterpart_billing_address"].to_json + counterpart_billing_address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: counterpart_billing_address) + else + counterpart_billing_address = nil + end + counterpart_business_type = parsed_json["counterpart_business_type"] + unless parsed_json["counterpart_contact"].nil? + counterpart_contact = parsed_json["counterpart_contact"].to_json + counterpart_contact = Monite::ReceivableCounterpartContact.from_json(json_object: counterpart_contact) + else + counterpart_contact = nil + end + counterpart_id = parsed_json["counterpart_id"] + counterpart_name = parsed_json["counterpart_name"] + unless parsed_json["counterpart_shipping_address"].nil? + counterpart_shipping_address = parsed_json["counterpart_shipping_address"].to_json + counterpart_shipping_address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: counterpart_shipping_address) + else + counterpart_shipping_address = nil + end + counterpart_tax_id = parsed_json["counterpart_tax_id"] + counterpart_type = parsed_json["counterpart_type"] + unless parsed_json["counterpart_vat_id"].nil? + counterpart_vat_id = parsed_json["counterpart_vat_id"].to_json + counterpart_vat_id = Monite::ReceivableCounterpartVatIdResponse.from_json(json_object: counterpart_vat_id) + else + counterpart_vat_id = nil + end + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + discounted_subtotal = parsed_json["discounted_subtotal"] + document_id = parsed_json["document_id"] + due_date = parsed_json["due_date"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::CreditNoteResponsePayloadEntity.from_json(json_object: entity) + else + entity = nil + end + unless parsed_json["entity_address"].nil? + entity_address = parsed_json["entity_address"].to_json + entity_address = Monite::ReceivableEntityAddressSchema.from_json(json_object: entity_address) + else + entity_address = nil + end + unless parsed_json["entity_bank_account"].nil? + entity_bank_account = parsed_json["entity_bank_account"].to_json + entity_bank_account = Monite::ReceivablesRepresentationOfEntityBankAccount.from_json(json_object: entity_bank_account) + else + entity_bank_account = nil + end + entity_user_id = parsed_json["entity_user_id"] + unless parsed_json["entity_vat_id"].nil? + entity_vat_id = parsed_json["entity_vat_id"].to_json + entity_vat_id = Monite::ReceivableEntityVatIdResponse.from_json(json_object: entity_vat_id) + else + entity_vat_id = nil + end + file_language = parsed_json["file_language"] + file_url = parsed_json["file_url"] + issue_date = unless parsed_json["issue_date"].nil? + DateTime.parse(parsed_json["issue_date"]) +else + nil +end + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::ResponseItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + original_file_language = parsed_json["original_file_language"] + original_file_url = parsed_json["original_file_url"] + partner_metadata = parsed_json["partner_metadata"] + project_id = parsed_json["project_id"] + purchase_order = parsed_json["purchase_order"] + status = parsed_json["status"] + subtotal = parsed_json["subtotal"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + total_amount = parsed_json["total_amount"] + total_vat_amount = parsed_json["total_vat_amount"] + total_vat_amounts = parsed_json["total_vat_amounts"]&.map do | item | + item = item.to_json + Monite::TotalVatAmountItem.from_json(json_object: item) +end + total_withholding_tax = parsed_json["total_withholding_tax"] + trade_name = parsed_json["trade_name"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + vat_mode = parsed_json["vat_mode"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + based_on: based_on, + based_on_document_id: based_on_document_id, + commercial_condition_description: commercial_condition_description, + counterpart_billing_address: counterpart_billing_address, + counterpart_business_type: counterpart_business_type, + counterpart_contact: counterpart_contact, + counterpart_id: counterpart_id, + counterpart_name: counterpart_name, + counterpart_shipping_address: counterpart_shipping_address, + counterpart_tax_id: counterpart_tax_id, + counterpart_type: counterpart_type, + counterpart_vat_id: counterpart_vat_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + discounted_subtotal: discounted_subtotal, + document_id: document_id, + due_date: due_date, + entity: entity, + entity_address: entity_address, + entity_bank_account: entity_bank_account, + entity_user_id: entity_user_id, + entity_vat_id: entity_vat_id, + file_language: file_language, + file_url: file_url, + issue_date: issue_date, + line_items: line_items, + memo: memo, + original_file_language: original_file_language, + original_file_url: original_file_url, + partner_metadata: partner_metadata, + project_id: project_id, + purchase_order: purchase_order, + status: status, + subtotal: subtotal, + tags: tags, + total_amount: total_amount, + total_vat_amount: total_vat_amount, + total_vat_amounts: total_vat_amounts, + total_withholding_tax: total_withholding_tax, + trade_name: trade_name, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + vat_mode: vat_mode, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of CreditNoteResponsePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.based_on&.is_a?(String) != false || raise("Passed value for field obj.based_on is not the expected type, validation failed.") + obj.based_on_document_id&.is_a?(String) != false || raise("Passed value for field obj.based_on_document_id is not the expected type, validation failed.") + obj.commercial_condition_description&.is_a?(String) != false || raise("Passed value for field obj.commercial_condition_description is not the expected type, validation failed.") + obj.counterpart_billing_address.nil? || Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.counterpart_billing_address) + obj.counterpart_business_type&.is_a?(String) != false || raise("Passed value for field obj.counterpart_business_type is not the expected type, validation failed.") + obj.counterpart_contact.nil? || Monite::ReceivableCounterpartContact.validate_raw(obj: obj.counterpart_contact) + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_name&.is_a?(String) != false || raise("Passed value for field obj.counterpart_name is not the expected type, validation failed.") + obj.counterpart_shipping_address.nil? || Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.counterpart_shipping_address) + obj.counterpart_tax_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_tax_id is not the expected type, validation failed.") + obj.counterpart_type.is_a?(Monite::ReceivableCounterpartType) != false || raise("Passed value for field obj.counterpart_type is not the expected type, validation failed.") + obj.counterpart_vat_id.nil? || Monite::ReceivableCounterpartVatIdResponse.validate_raw(obj: obj.counterpart_vat_id) + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.discounted_subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.discounted_subtotal is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.due_date&.is_a?(String) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.") + Monite::CreditNoteResponsePayloadEntity.validate_raw(obj: obj.entity) + Monite::ReceivableEntityAddressSchema.validate_raw(obj: obj.entity_address) + obj.entity_bank_account.nil? || Monite::ReceivablesRepresentationOfEntityBankAccount.validate_raw(obj: obj.entity_bank_account) + obj.entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.entity_user_id is not the expected type, validation failed.") + obj.entity_vat_id.nil? || Monite::ReceivableEntityVatIdResponse.validate_raw(obj: obj.entity_vat_id) + obj.file_language.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.file_language is not the expected type, validation failed.") + obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") + obj.issue_date&.is_a?(DateTime) != false || raise("Passed value for field obj.issue_date is not the expected type, validation failed.") + obj.line_items.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.original_file_language.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.original_file_language is not the expected type, validation failed.") + obj.original_file_url&.is_a?(String) != false || raise("Passed value for field obj.original_file_url is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.purchase_order&.is_a?(String) != false || raise("Passed value for field obj.purchase_order is not the expected type, validation failed.") + obj.status.is_a?(Monite::CreditNoteStateEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.total_vat_amount.is_a?(Integer) != false || raise("Passed value for field obj.total_vat_amount is not the expected type, validation failed.") + obj.total_vat_amounts&.is_a?(Array) != false || raise("Passed value for field obj.total_vat_amounts is not the expected type, validation failed.") + obj.total_withholding_tax&.is_a?(Integer) != false || raise("Passed value for field obj.total_withholding_tax is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.vat_mode&.is_a?(Monite::VatModeEnum) != false || raise("Passed value for field obj.vat_mode is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_response_payload_entity.rb b/lib/monite/types/credit_note_response_payload_entity.rb new file mode 100644 index 0000000..9d9a19e --- /dev/null +++ b/lib/monite/types/credit_note_response_payload_entity.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "json" +require_relative "receivable_entity_organization" +require_relative "receivable_entity_individual" + +module Monite + class CreditNoteResponsePayloadEntity + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::CreditNoteResponsePayloadEntity] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of CreditNoteResponsePayloadEntity + # + # @param json_object [String] + # @return [Monite::CreditNoteResponsePayloadEntity] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "organization" + member = Monite::ReceivableEntityOrganization.from_json(json_object: json_object) + when "individual" + member = Monite::ReceivableEntityIndividual.from_json(json_object: json_object) + else + member = Monite::ReceivableEntityOrganization.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "organization" + { **@member.to_json, type: @discriminant }.to_json + when "individual" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "organization" + Monite::ReceivableEntityOrganization.validate_raw(obj: obj) + when "individual" + Monite::ReceivableEntityIndividual.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::ReceivableEntityOrganization] + # @return [Monite::CreditNoteResponsePayloadEntity] + def self.organization(member:) + new(member: member, discriminant: "organization") + end + # @param member [Monite::ReceivableEntityIndividual] + # @return [Monite::CreditNoteResponsePayloadEntity] + def self.individual(member:) + new(member: member, discriminant: "individual") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/credit_note_state_enum.rb b/lib/monite/types/credit_note_state_enum.rb new file mode 100644 index 0000000..03782e6 --- /dev/null +++ b/lib/monite/types/credit_note_state_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class CreditNoteStateEnum + + DRAFT = "draft" + ISSUED = "issued" + DELETED = "deleted" + + end +end \ No newline at end of file diff --git a/lib/monite/types/currency_enum.rb b/lib/monite/types/currency_enum.rb new file mode 100644 index 0000000..b1710f6 --- /dev/null +++ b/lib/monite/types/currency_enum.rb @@ -0,0 +1,144 @@ +# frozen_string_literal: true + +module Monite + class CurrencyEnum + + AED = "AED" + AFN = "AFN" + ALL = "ALL" + AMD = "AMD" + ANG = "ANG" + AOA = "AOA" + ARS = "ARS" + AUD = "AUD" + AWG = "AWG" + AZN = "AZN" + BAM = "BAM" + BBD = "BBD" + BDT = "BDT" + BGN = "BGN" + BHD = "BHD" + BIF = "BIF" + BND = "BND" + BOB = "BOB" + BRL = "BRL" + BSD = "BSD" + BWP = "BWP" + BYN = "BYN" + BZD = "BZD" + CAD = "CAD" + CDF = "CDF" + CHF = "CHF" + CLP = "CLP" + CNY = "CNY" + COP = "COP" + CRC = "CRC" + CVE = "CVE" + CZK = "CZK" + DJF = "DJF" + DKK = "DKK" + DOP = "DOP" + DZD = "DZD" + EGP = "EGP" + ETB = "ETB" + EUR = "EUR" + FJD = "FJD" + GBP = "GBP" + GEL = "GEL" + GIP = "GIP" + GMD = "GMD" + GNF = "GNF" + GTQ = "GTQ" + GYD = "GYD" + HKD = "HKD" + HNL = "HNL" + HRK = "HRK" + HTG = "HTG" + HUF = "HUF" + IDR = "IDR" + ILS = "ILS" + INR = "INR" + ISK = "ISK" + JMD = "JMD" + JOD = "JOD" + JPY = "JPY" + KES = "KES" + KGS = "KGS" + KHR = "KHR" + KMF = "KMF" + KRW = "KRW" + KWD = "KWD" + KYD = "KYD" + KZT = "KZT" + LAK = "LAK" + LBP = "LBP" + LKR = "LKR" + LRD = "LRD" + LSL = "LSL" + MAD = "MAD" + MDL = "MDL" + MGA = "MGA" + MKD = "MKD" + MMK = "MMK" + MNT = "MNT" + MOP = "MOP" + MUR = "MUR" + MVR = "MVR" + MWK = "MWK" + MXN = "MXN" + MYR = "MYR" + MZN = "MZN" + NAD = "NAD" + NGN = "NGN" + NIO = "NIO" + NOK = "NOK" + NPR = "NPR" + NZD = "NZD" + OMR = "OMR" + PAB = "PAB" + PEN = "PEN" + PGK = "PGK" + PHP = "PHP" + PKR = "PKR" + PLN = "PLN" + PYG = "PYG" + QAR = "QAR" + RON = "RON" + RSD = "RSD" + RUB = "RUB" + RWF = "RWF" + SAR = "SAR" + SBD = "SBD" + SCR = "SCR" + SEK = "SEK" + SGD = "SGD" + SLL = "SLL" + SOS = "SOS" + SRD = "SRD" + SZL = "SZL" + THB = "THB" + TJS = "TJS" + TND = "TND" + TOP = "TOP" + TRY = "TRY" + TTD = "TTD" + TWD = "TWD" + TZS = "TZS" + UAH = "UAH" + UGX = "UGX" + USD = "USD" + UYU = "UYU" + UZS = "UZS" + VND = "VND" + VUV = "VUV" + WST = "WST" + XAF = "XAF" + XCD = "XCD" + XOF = "XOF" + XPF = "XPF" + YER = "YER" + ZAR = "ZAR" + ZMW = "ZMW" + + end +end \ No newline at end of file diff --git a/lib/monite/types/currency_exchange_schema.rb b/lib/monite/types/currency_exchange_schema.rb new file mode 100644 index 0000000..2ad2e52 --- /dev/null +++ b/lib/monite/types/currency_exchange_schema.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class CurrencyExchangeSchema + # @return [String] + attr_reader :default_currency_code + # @return [Float] + attr_reader :rate + # @return [Float] + attr_reader :total + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param default_currency_code [String] + # @param rate [Float] + # @param total [Float] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CurrencyExchangeSchema] + def initialize(default_currency_code:, rate:, total:, additional_properties: nil) + @default_currency_code = default_currency_code + @rate = rate + @total = total + @additional_properties = additional_properties + @_field_set = { "default_currency_code": default_currency_code, "rate": rate, "total": total } + end +# Deserialize a JSON object to an instance of CurrencyExchangeSchema + # + # @param json_object [String] + # @return [Monite::CurrencyExchangeSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + default_currency_code = parsed_json["default_currency_code"] + rate = parsed_json["rate"] + total = parsed_json["total"] + new( + default_currency_code: default_currency_code, + rate: rate, + total: total, + additional_properties: struct + ) + end +# Serialize an instance of CurrencyExchangeSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.default_currency_code.is_a?(String) != false || raise("Passed value for field obj.default_currency_code is not the expected type, validation failed.") + obj.rate.is_a?(Float) != false || raise("Passed value for field obj.rate is not the expected type, validation failed.") + obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/currency_exchange_schema_2.rb b/lib/monite/types/currency_exchange_schema_2.rb new file mode 100644 index 0000000..225ea98 --- /dev/null +++ b/lib/monite/types/currency_exchange_schema_2.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class CurrencyExchangeSchema2 + # @return [String] + attr_reader :default_currency_code + # @return [Float] + attr_reader :rate + # @return [Float] + attr_reader :total + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param default_currency_code [String] + # @param rate [Float] + # @param total [Float] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CurrencyExchangeSchema2] + def initialize(default_currency_code:, rate:, total:, additional_properties: nil) + @default_currency_code = default_currency_code + @rate = rate + @total = total + @additional_properties = additional_properties + @_field_set = { "default_currency_code": default_currency_code, "rate": rate, "total": total } + end +# Deserialize a JSON object to an instance of CurrencyExchangeSchema2 + # + # @param json_object [String] + # @return [Monite::CurrencyExchangeSchema2] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + default_currency_code = parsed_json["default_currency_code"] + rate = parsed_json["rate"] + total = parsed_json["total"] + new( + default_currency_code: default_currency_code, + rate: rate, + total: total, + additional_properties: struct + ) + end +# Serialize an instance of CurrencyExchangeSchema2 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.default_currency_code.is_a?(String) != false || raise("Passed value for field obj.default_currency_code is not the expected type, validation failed.") + obj.rate.is_a?(Float) != false || raise("Passed value for field obj.rate is not the expected type, validation failed.") + obj.total.is_a?(Float) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/currency_settings_input.rb b/lib/monite/types/currency_settings_input.rb new file mode 100644 index 0000000..6ae81c7 --- /dev/null +++ b/lib/monite/types/currency_settings_input.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "exchange_rate" +require "ostruct" +require "json" + +module Monite + class CurrencySettingsInput + # @return [Monite::CurrencyEnum] + attr_reader :default + # @return [Array] + attr_reader :exchange_rates + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param default [Monite::CurrencyEnum] + # @param exchange_rates [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CurrencySettingsInput] + def initialize(default:, exchange_rates: OMIT, additional_properties: nil) + @default = default + @exchange_rates = exchange_rates if exchange_rates != OMIT + @additional_properties = additional_properties + @_field_set = { "default": default, "exchange_rates": exchange_rates }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CurrencySettingsInput + # + # @param json_object [String] + # @return [Monite::CurrencySettingsInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + default = parsed_json["default"] + exchange_rates = parsed_json["exchange_rates"]&.map do | item | + item = item.to_json + Monite::ExchangeRate.from_json(json_object: item) +end + new( + default: default, + exchange_rates: exchange_rates, + additional_properties: struct + ) + end +# Serialize an instance of CurrencySettingsInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.default.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.default is not the expected type, validation failed.") + obj.exchange_rates&.is_a?(Array) != false || raise("Passed value for field obj.exchange_rates is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/currency_settings_output.rb b/lib/monite/types/currency_settings_output.rb new file mode 100644 index 0000000..2058efc --- /dev/null +++ b/lib/monite/types/currency_settings_output.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "exchange_rate" +require "ostruct" +require "json" + +module Monite + class CurrencySettingsOutput + # @return [Monite::CurrencyEnum] + attr_reader :default + # @return [Array] + attr_reader :exchange_rates + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param default [Monite::CurrencyEnum] + # @param exchange_rates [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CurrencySettingsOutput] + def initialize(default:, exchange_rates: OMIT, additional_properties: nil) + @default = default + @exchange_rates = exchange_rates if exchange_rates != OMIT + @additional_properties = additional_properties + @_field_set = { "default": default, "exchange_rates": exchange_rates }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CurrencySettingsOutput + # + # @param json_object [String] + # @return [Monite::CurrencySettingsOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + default = parsed_json["default"] + exchange_rates = parsed_json["exchange_rates"]&.map do | item | + item = item.to_json + Monite::ExchangeRate.from_json(json_object: item) +end + new( + default: default, + exchange_rates: exchange_rates, + additional_properties: struct + ) + end +# Serialize an instance of CurrencySettingsOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.default.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.default is not the expected type, validation failed.") + obj.exchange_rates&.is_a?(Array) != false || raise("Passed value for field obj.exchange_rates is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/custom_template_data_schema.rb b/lib/monite/types/custom_template_data_schema.rb new file mode 100644 index 0000000..ce2adb9 --- /dev/null +++ b/lib/monite/types/custom_template_data_schema.rb @@ -0,0 +1,120 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class CustomTemplateDataSchema + # @return [String] ID of email template + attr_reader :id + # @return [DateTime] Template created date and time + attr_reader :created_at + # @return [DateTime] Template updated date and time + attr_reader :updated_at + # @return [String] Jinja2 compatible email body template + attr_reader :body_template + # @return [Boolean] Is default template + attr_reader :is_default + # @return [String] Lowercase ISO code of language + attr_reader :language + # @return [String] Name of the template + attr_reader :name + # @return [String] Jinja2 compatible email subject template + attr_reader :subject_template + # @return [String] Document type of content + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of email template + # @param created_at [DateTime] Template created date and time + # @param updated_at [DateTime] Template updated date and time + # @param body_template [String] Jinja2 compatible email body template + # @param is_default [Boolean] Is default template + # @param language [String] Lowercase ISO code of language + # @param name [String] Name of the template + # @param subject_template [String] Jinja2 compatible email subject template + # @param type [String] Document type of content + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CustomTemplateDataSchema] + def initialize(id:, created_at:, updated_at:, body_template:, is_default:, language:, name:, subject_template:, type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @body_template = body_template + @is_default = is_default + @language = language + @name = name + @subject_template = subject_template + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "body_template": body_template, "is_default": is_default, "language": language, "name": name, "subject_template": subject_template, "type": type } + end +# Deserialize a JSON object to an instance of CustomTemplateDataSchema + # + # @param json_object [String] + # @return [Monite::CustomTemplateDataSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + body_template = parsed_json["body_template"] + is_default = parsed_json["is_default"] + language = parsed_json["language"] + name = parsed_json["name"] + subject_template = parsed_json["subject_template"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + body_template: body_template, + is_default: is_default, + language: language, + name: name, + subject_template: subject_template, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of CustomTemplateDataSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.body_template.is_a?(String) != false || raise("Passed value for field obj.body_template is not the expected type, validation failed.") + obj.is_default.is_a?(Boolean) != false || raise("Passed value for field obj.is_default is not the expected type, validation failed.") + obj.language.is_a?(String) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.subject_template.is_a?(String) != false || raise("Passed value for field obj.subject_template is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/custom_templates_cursor_fields.rb b/lib/monite/types/custom_templates_cursor_fields.rb new file mode 100644 index 0000000..e036542 --- /dev/null +++ b/lib/monite/types/custom_templates_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class CustomTemplatesCursorFields + + TYPE = "type" + NAME = "name" + + end +end \ No newline at end of file diff --git a/lib/monite/types/custom_templates_pagination_response.rb b/lib/monite/types/custom_templates_pagination_response.rb new file mode 100644 index 0000000..e3f524c --- /dev/null +++ b/lib/monite/types/custom_templates_pagination_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "custom_template_data_schema" +require "ostruct" +require "json" + +module Monite + class CustomTemplatesPaginationResponse + # @return [Array] All user-defined email templates + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] All user-defined email templates + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::CustomTemplatesPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of CustomTemplatesPaginationResponse + # + # @param json_object [String] + # @return [Monite::CustomTemplatesPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::CustomTemplateDataSchema.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of CustomTemplatesPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/data_export_cursor_fields.rb b/lib/monite/types/data_export_cursor_fields.rb new file mode 100644 index 0000000..1c9aad1 --- /dev/null +++ b/lib/monite/types/data_export_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + DATA_EXPORT_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/date_dimension_breakdown_enum.rb b/lib/monite/types/date_dimension_breakdown_enum.rb new file mode 100644 index 0000000..29fdb9a --- /dev/null +++ b/lib/monite/types/date_dimension_breakdown_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class DateDimensionBreakdownEnum + + DAILY = "daily" + WEEKLY = "weekly" + MONTHLY = "monthly" + QUARTERLY = "quarterly" + YEARLY = "yearly" + + end +end \ No newline at end of file diff --git a/lib/monite/types/day_of_month.rb b/lib/monite/types/day_of_month.rb new file mode 100644 index 0000000..330936e --- /dev/null +++ b/lib/monite/types/day_of_month.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class DayOfMonth + + FIRST_DAY = "first_day" + LAST_DAY = "last_day" + + end +end \ No newline at end of file diff --git a/lib/monite/types/default_ledger_account_i_ds.rb b/lib/monite/types/default_ledger_account_i_ds.rb new file mode 100644 index 0000000..eb02201 --- /dev/null +++ b/lib/monite/types/default_ledger_account_i_ds.rb @@ -0,0 +1,71 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class DefaultLedgerAccountIDs + # @return [String] ID of the ledger account to which all payment records will be pushed. Changing +# this value affects only future data pushes and does not affect payment records +# that already exist in the accounting system. + attr_reader :payments + # @return [String] ID of the ledger account to which products without a `ledger_account_id` +# specified will be pushed. Changing this value affects only future data pushes +# and does not affect products that already exist in the accounting system. + attr_reader :products + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param payments [String] ID of the ledger account to which all payment records will be pushed. Changing +# this value affects only future data pushes and does not affect payment records +# that already exist in the accounting system. + # @param products [String] ID of the ledger account to which products without a `ledger_account_id` +# specified will be pushed. Changing this value affects only future data pushes +# and does not affect products that already exist in the accounting system. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DefaultLedgerAccountIDs] + def initialize(payments: OMIT, products: OMIT, additional_properties: nil) + @payments = payments if payments != OMIT + @products = products if products != OMIT + @additional_properties = additional_properties + @_field_set = { "payments": payments, "products": products }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DefaultLedgerAccountIDs + # + # @param json_object [String] + # @return [Monite::DefaultLedgerAccountIDs] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + payments = parsed_json["payments"] + products = parsed_json["products"] + new( + payments: payments, + products: products, + additional_properties: struct + ) + end +# Serialize an instance of DefaultLedgerAccountIDs to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.payments&.is_a?(String) != false || raise("Passed value for field obj.payments is not the expected type, validation failed.") + obj.products&.is_a?(String) != false || raise("Passed value for field obj.products is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/discount.rb b/lib/monite/types/discount.rb new file mode 100644 index 0000000..594017f --- /dev/null +++ b/lib/monite/types/discount.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true +require_relative "discount_type" +require "ostruct" +require "json" + +module Monite + class Discount + # @return [Integer] The actual discount of the product in [minor +# units](https://docs.monite.com/references/currencies#minor-units) if type field +# equals amount, else in percent minor units + attr_reader :amount + # @return [Monite::DiscountType] The field specifies whether to use product currency or %. + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param amount [Integer] The actual discount of the product in [minor +# units](https://docs.monite.com/references/currencies#minor-units) if type field +# equals amount, else in percent minor units + # @param type [Monite::DiscountType] The field specifies whether to use product currency or %. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Discount] + def initialize(amount:, type:, additional_properties: nil) + @amount = amount + @type = type + @additional_properties = additional_properties + @_field_set = { "amount": amount, "type": type } + end +# Deserialize a JSON object to an instance of Discount + # + # @param json_object [String] + # @return [Monite::Discount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + amount = parsed_json["amount"] + type = parsed_json["type"] + new( + amount: amount, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of Discount to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.amount.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.type.is_a?(Monite::DiscountType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/discount_type.rb b/lib/monite/types/discount_type.rb new file mode 100644 index 0000000..ca06ac6 --- /dev/null +++ b/lib/monite/types/discount_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class DiscountType + + AMOUNT = "amount" + PERCENTAGE = "percentage" + + end +end \ No newline at end of file diff --git a/lib/monite/types/dns_record.rb b/lib/monite/types/dns_record.rb new file mode 100644 index 0000000..36e65a8 --- /dev/null +++ b/lib/monite/types/dns_record.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require_relative "dns_record_purpose" +require_relative "dns_record_type" +require "ostruct" +require "json" + +module Monite + class DnsRecord + # @return [Boolean] + attr_reader :is_active + # @return [String] + attr_reader :name + # @return [Monite::DnsRecordPurpose] Purpose of specific entry to distinguish between various TXT entries. + attr_reader :record_purpose + # @return [Monite::DnsRecordType] + attr_reader :record_type + # @return [String] Field reflecting validation status by Mailgun. + attr_reader :valid + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param is_active [Boolean] + # @param name [String] + # @param record_purpose [Monite::DnsRecordPurpose] Purpose of specific entry to distinguish between various TXT entries. + # @param record_type [Monite::DnsRecordType] + # @param valid [String] Field reflecting validation status by Mailgun. + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DnsRecord] + def initialize(is_active:, name: OMIT, record_purpose: OMIT, record_type:, valid:, value:, additional_properties: nil) + @is_active = is_active + @name = name if name != OMIT + @record_purpose = record_purpose if record_purpose != OMIT + @record_type = record_type + @valid = valid + @value = value + @additional_properties = additional_properties + @_field_set = { "is_active": is_active, "name": name, "record_purpose": record_purpose, "record_type": record_type, "valid": valid, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DnsRecord + # + # @param json_object [String] + # @return [Monite::DnsRecord] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + is_active = parsed_json["is_active"] + name = parsed_json["name"] + record_purpose = parsed_json["record_purpose"] + record_type = parsed_json["record_type"] + valid = parsed_json["valid"] + value = parsed_json["value"] + new( + is_active: is_active, + name: name, + record_purpose: record_purpose, + record_type: record_type, + valid: valid, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of DnsRecord to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.is_active.is_a?(Boolean) != false || raise("Passed value for field obj.is_active is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.record_purpose&.is_a?(Monite::DnsRecordPurpose) != false || raise("Passed value for field obj.record_purpose is not the expected type, validation failed.") + obj.record_type.is_a?(Monite::DnsRecordType) != false || raise("Passed value for field obj.record_type is not the expected type, validation failed.") + obj.valid.is_a?(String) != false || raise("Passed value for field obj.valid is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/dns_record_purpose.rb b/lib/monite/types/dns_record_purpose.rb new file mode 100644 index 0000000..313d1c1 --- /dev/null +++ b/lib/monite/types/dns_record_purpose.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class DnsRecordPurpose + + DKIM = "DKIM" + SPF = "SPF" + + end +end \ No newline at end of file diff --git a/lib/monite/types/dns_record_type.rb b/lib/monite/types/dns_record_type.rb new file mode 100644 index 0000000..f01a4ec --- /dev/null +++ b/lib/monite/types/dns_record_type.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class DnsRecordType + + TXT = "TXT" + MX = "MX" + CNAME = "CNAME" + + end +end \ No newline at end of file diff --git a/lib/monite/types/dns_records.rb b/lib/monite/types/dns_records.rb new file mode 100644 index 0000000..d245558 --- /dev/null +++ b/lib/monite/types/dns_records.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true +require_relative "dns_record" +require "ostruct" +require "json" + +module Monite + class DnsRecords + # @return [Array] Set of DNS settings required by Mailgun for domain verification before emails +# receiving is possible. + attr_reader :receiving_dns_records + # @return [Array] Set of DNS settings required by Mailgun for domain verification before emails +# sending is possible. + attr_reader :sending_dns_records + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param receiving_dns_records [Array] Set of DNS settings required by Mailgun for domain verification before emails +# receiving is possible. + # @param sending_dns_records [Array] Set of DNS settings required by Mailgun for domain verification before emails +# sending is possible. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DnsRecords] + def initialize(receiving_dns_records:, sending_dns_records:, additional_properties: nil) + @receiving_dns_records = receiving_dns_records + @sending_dns_records = sending_dns_records + @additional_properties = additional_properties + @_field_set = { "receiving_dns_records": receiving_dns_records, "sending_dns_records": sending_dns_records } + end +# Deserialize a JSON object to an instance of DnsRecords + # + # @param json_object [String] + # @return [Monite::DnsRecords] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + receiving_dns_records = parsed_json["receiving_dns_records"]&.map do | item | + item = item.to_json + Monite::DnsRecord.from_json(json_object: item) +end + sending_dns_records = parsed_json["sending_dns_records"]&.map do | item | + item = item.to_json + Monite::DnsRecord.from_json(json_object: item) +end + new( + receiving_dns_records: receiving_dns_records, + sending_dns_records: sending_dns_records, + additional_properties: struct + ) + end +# Serialize an instance of DnsRecords to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.receiving_dns_records.is_a?(Array) != false || raise("Passed value for field obj.receiving_dns_records is not the expected type, validation failed.") + obj.sending_dns_records.is_a?(Array) != false || raise("Passed value for field obj.sending_dns_records is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/document_export_response_schema.rb b/lib/monite/types/document_export_response_schema.rb new file mode 100644 index 0000000..1449cac --- /dev/null +++ b/lib/monite/types/document_export_response_schema.rb @@ -0,0 +1,129 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class DocumentExportResponseSchema + # @return [String] + attr_reader :id + # @return [Integer] + attr_reader :count + # @return [String] + attr_reader :created_by_entity_user_id + # @return [DateTime] + attr_reader :end_datetime + # @return [String] + attr_reader :entity_id + # @return [String] + attr_reader :format + # @return [String] + attr_reader :language + # @return [String] + attr_reader :source_url + # @return [DateTime] + attr_reader :start_datetime + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param count [Integer] + # @param created_by_entity_user_id [String] + # @param end_datetime [DateTime] + # @param entity_id [String] + # @param format [String] + # @param language [String] + # @param source_url [String] + # @param start_datetime [DateTime] + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DocumentExportResponseSchema] + def initialize(id:, count:, created_by_entity_user_id: OMIT, end_datetime: OMIT, entity_id:, format:, language:, source_url: OMIT, start_datetime: OMIT, status:, additional_properties: nil) + @id = id + @count = count + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @end_datetime = end_datetime if end_datetime != OMIT + @entity_id = entity_id + @format = format + @language = language + @source_url = source_url if source_url != OMIT + @start_datetime = start_datetime if start_datetime != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "count": count, "created_by_entity_user_id": created_by_entity_user_id, "end_datetime": end_datetime, "entity_id": entity_id, "format": format, "language": language, "source_url": source_url, "start_datetime": start_datetime, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DocumentExportResponseSchema + # + # @param json_object [String] + # @return [Monite::DocumentExportResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + count = parsed_json["count"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + end_datetime = unless parsed_json["end_datetime"].nil? + DateTime.parse(parsed_json["end_datetime"]) +else + nil +end + entity_id = parsed_json["entity_id"] + format = parsed_json["format"] + language = parsed_json["language"] + source_url = parsed_json["source_url"] + start_datetime = unless parsed_json["start_datetime"].nil? + DateTime.parse(parsed_json["start_datetime"]) +else + nil +end + status = parsed_json["status"] + new( + id: id, + count: count, + created_by_entity_user_id: created_by_entity_user_id, + end_datetime: end_datetime, + entity_id: entity_id, + format: format, + language: language, + source_url: source_url, + start_datetime: start_datetime, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of DocumentExportResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.count.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.end_datetime&.is_a?(DateTime) != false || raise("Passed value for field obj.end_datetime is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.format.is_a?(String) != false || raise("Passed value for field obj.format is not the expected type, validation failed.") + obj.language.is_a?(String) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.source_url&.is_a?(String) != false || raise("Passed value for field obj.source_url is not the expected type, validation failed.") + obj.start_datetime&.is_a?(DateTime) != false || raise("Passed value for field obj.start_datetime is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/document_i_ds_settings.rb b/lib/monite/types/document_i_ds_settings.rb new file mode 100644 index 0000000..d97bd96 --- /dev/null +++ b/lib/monite/types/document_i_ds_settings.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require_relative "document_type_prefix" +require_relative "document_id_separators" +require "ostruct" +require "json" + +module Monite + class DocumentIDsSettings + # @return [Monite::DocumentTypePrefix] Prefixes for each document_type. + attr_reader :document_type_prefix + # @return [Boolean] Optionally add 4-digit of the current year. + attr_reader :include_date + # @return [Integer] Minimal size of number in document ID Number will be left padded with zeros if +# less. + attr_reader :min_digits + # @return [String] Optional prefix. Does not substitute document_type prefix. + attr_reader :prefix + # @return [Monite::DocumentIdSeparators] Which character should separate each part of the document_id. + attr_reader :separator + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param document_type_prefix [Monite::DocumentTypePrefix] Prefixes for each document_type. + # @param include_date [Boolean] Optionally add 4-digit of the current year. + # @param min_digits [Integer] Minimal size of number in document ID Number will be left padded with zeros if +# less. + # @param prefix [String] Optional prefix. Does not substitute document_type prefix. + # @param separator [Monite::DocumentIdSeparators] Which character should separate each part of the document_id. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DocumentIDsSettings] + def initialize(document_type_prefix: OMIT, include_date: OMIT, min_digits: OMIT, prefix: OMIT, separator: OMIT, additional_properties: nil) + @document_type_prefix = document_type_prefix if document_type_prefix != OMIT + @include_date = include_date if include_date != OMIT + @min_digits = min_digits if min_digits != OMIT + @prefix = prefix if prefix != OMIT + @separator = separator if separator != OMIT + @additional_properties = additional_properties + @_field_set = { "document_type_prefix": document_type_prefix, "include_date": include_date, "min_digits": min_digits, "prefix": prefix, "separator": separator }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DocumentIDsSettings + # + # @param json_object [String] + # @return [Monite::DocumentIDsSettings] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["document_type_prefix"].nil? + document_type_prefix = parsed_json["document_type_prefix"].to_json + document_type_prefix = Monite::DocumentTypePrefix.from_json(json_object: document_type_prefix) + else + document_type_prefix = nil + end + include_date = parsed_json["include_date"] + min_digits = parsed_json["min_digits"] + prefix = parsed_json["prefix"] + separator = parsed_json["separator"] + new( + document_type_prefix: document_type_prefix, + include_date: include_date, + min_digits: min_digits, + prefix: prefix, + separator: separator, + additional_properties: struct + ) + end +# Serialize an instance of DocumentIDsSettings to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.document_type_prefix.nil? || Monite::DocumentTypePrefix.validate_raw(obj: obj.document_type_prefix) + obj.include_date&.is_a?(Boolean) != false || raise("Passed value for field obj.include_date is not the expected type, validation failed.") + obj.min_digits&.is_a?(Integer) != false || raise("Passed value for field obj.min_digits is not the expected type, validation failed.") + obj.prefix&.is_a?(String) != false || raise("Passed value for field obj.prefix is not the expected type, validation failed.") + obj.separator&.is_a?(Monite::DocumentIdSeparators) != false || raise("Passed value for field obj.separator is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/document_i_ds_settings_next_number.rb b/lib/monite/types/document_i_ds_settings_next_number.rb new file mode 100644 index 0000000..7b45138 --- /dev/null +++ b/lib/monite/types/document_i_ds_settings_next_number.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class DocumentIDsSettingsNextNumber + # @return [Integer] + attr_reader :credit_note + # @return [Integer] + attr_reader :invoice + # @return [Integer] + attr_reader :purchase_order + # @return [Integer] + attr_reader :quote + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param credit_note [Integer] + # @param invoice [Integer] + # @param purchase_order [Integer] + # @param quote [Integer] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DocumentIDsSettingsNextNumber] + def initialize(credit_note: OMIT, invoice: OMIT, purchase_order: OMIT, quote: OMIT, additional_properties: nil) + @credit_note = credit_note if credit_note != OMIT + @invoice = invoice if invoice != OMIT + @purchase_order = purchase_order if purchase_order != OMIT + @quote = quote if quote != OMIT + @additional_properties = additional_properties + @_field_set = { "credit_note": credit_note, "invoice": invoice, "purchase_order": purchase_order, "quote": quote }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DocumentIDsSettingsNextNumber + # + # @param json_object [String] + # @return [Monite::DocumentIDsSettingsNextNumber] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + credit_note = parsed_json["credit_note"] + invoice = parsed_json["invoice"] + purchase_order = parsed_json["purchase_order"] + quote = parsed_json["quote"] + new( + credit_note: credit_note, + invoice: invoice, + purchase_order: purchase_order, + quote: quote, + additional_properties: struct + ) + end +# Serialize an instance of DocumentIDsSettingsNextNumber to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.credit_note&.is_a?(Integer) != false || raise("Passed value for field obj.credit_note is not the expected type, validation failed.") + obj.invoice&.is_a?(Integer) != false || raise("Passed value for field obj.invoice is not the expected type, validation failed.") + obj.purchase_order&.is_a?(Integer) != false || raise("Passed value for field obj.purchase_order is not the expected type, validation failed.") + obj.quote&.is_a?(Integer) != false || raise("Passed value for field obj.quote is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/document_i_ds_settings_request.rb b/lib/monite/types/document_i_ds_settings_request.rb new file mode 100644 index 0000000..2d36a7a --- /dev/null +++ b/lib/monite/types/document_i_ds_settings_request.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true +require_relative "document_type_prefix" +require_relative "document_i_ds_settings_next_number" +require_relative "document_id_separators" +require "ostruct" +require "json" + +module Monite + class DocumentIDsSettingsRequest + # @return [Monite::DocumentTypePrefix] Prefixes for each document_type. + attr_reader :document_type_prefix + # @return [Boolean] Optionally add 4-digit of the current year. + attr_reader :include_date + # @return [Integer] Minimal size of number in document ID Number will be left padded with zeros if +# less. + attr_reader :min_digits + # @return [Monite::DocumentIDsSettingsNextNumber] Write-only field. Changes which number will be issued next. Can't be less than +# the last issued document number. + attr_reader :next_number + # @return [String] Optional prefix. Does not substitute document_type prefix. + attr_reader :prefix + # @return [Monite::DocumentIdSeparators] Which character should separate each part of the document_id. + attr_reader :separator + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param document_type_prefix [Monite::DocumentTypePrefix] Prefixes for each document_type. + # @param include_date [Boolean] Optionally add 4-digit of the current year. + # @param min_digits [Integer] Minimal size of number in document ID Number will be left padded with zeros if +# less. + # @param next_number [Monite::DocumentIDsSettingsNextNumber] Write-only field. Changes which number will be issued next. Can't be less than +# the last issued document number. + # @param prefix [String] Optional prefix. Does not substitute document_type prefix. + # @param separator [Monite::DocumentIdSeparators] Which character should separate each part of the document_id. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DocumentIDsSettingsRequest] + def initialize(document_type_prefix: OMIT, include_date: OMIT, min_digits: OMIT, next_number: OMIT, prefix: OMIT, separator: OMIT, additional_properties: nil) + @document_type_prefix = document_type_prefix if document_type_prefix != OMIT + @include_date = include_date if include_date != OMIT + @min_digits = min_digits if min_digits != OMIT + @next_number = next_number if next_number != OMIT + @prefix = prefix if prefix != OMIT + @separator = separator if separator != OMIT + @additional_properties = additional_properties + @_field_set = { "document_type_prefix": document_type_prefix, "include_date": include_date, "min_digits": min_digits, "next_number": next_number, "prefix": prefix, "separator": separator }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DocumentIDsSettingsRequest + # + # @param json_object [String] + # @return [Monite::DocumentIDsSettingsRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["document_type_prefix"].nil? + document_type_prefix = parsed_json["document_type_prefix"].to_json + document_type_prefix = Monite::DocumentTypePrefix.from_json(json_object: document_type_prefix) + else + document_type_prefix = nil + end + include_date = parsed_json["include_date"] + min_digits = parsed_json["min_digits"] + unless parsed_json["next_number"].nil? + next_number = parsed_json["next_number"].to_json + next_number = Monite::DocumentIDsSettingsNextNumber.from_json(json_object: next_number) + else + next_number = nil + end + prefix = parsed_json["prefix"] + separator = parsed_json["separator"] + new( + document_type_prefix: document_type_prefix, + include_date: include_date, + min_digits: min_digits, + next_number: next_number, + prefix: prefix, + separator: separator, + additional_properties: struct + ) + end +# Serialize an instance of DocumentIDsSettingsRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.document_type_prefix.nil? || Monite::DocumentTypePrefix.validate_raw(obj: obj.document_type_prefix) + obj.include_date&.is_a?(Boolean) != false || raise("Passed value for field obj.include_date is not the expected type, validation failed.") + obj.min_digits&.is_a?(Integer) != false || raise("Passed value for field obj.min_digits is not the expected type, validation failed.") + obj.next_number.nil? || Monite::DocumentIDsSettingsNextNumber.validate_raw(obj: obj.next_number) + obj.prefix&.is_a?(String) != false || raise("Passed value for field obj.prefix is not the expected type, validation failed.") + obj.separator&.is_a?(Monite::DocumentIdSeparators) != false || raise("Passed value for field obj.separator is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/document_id_separators.rb b/lib/monite/types/document_id_separators.rb new file mode 100644 index 0000000..b10c222 --- /dev/null +++ b/lib/monite/types/document_id_separators.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class DocumentIdSeparators + + SLASH = "/" + HYPHEN = "-" + PIPE = "|" + DOT = "." + EMPTY = "" + + end +end \ No newline at end of file diff --git a/lib/monite/types/document_object_type_request_enum.rb b/lib/monite/types/document_object_type_request_enum.rb new file mode 100644 index 0000000..d6e1ef6 --- /dev/null +++ b/lib/monite/types/document_object_type_request_enum.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Monite + class DocumentObjectTypeRequestEnum + + RECEIVABLES_QUOTE = "receivables_quote" + RECEIVABLES_INVOICE = "receivables_invoice" + RECEIVABLES_PAID_INVOICE = "receivables_paid_invoice" + RECEIVABLES_CREDIT_NOTE = "receivables_credit_note" + RECEIVABLES_DISCOUNT_REMINDER = "receivables_discount_reminder" + RECEIVABLES_FINAL_REMINDER = "receivables_final_reminder" + PAYABLES_PURCHASE_ORDER = "payables_purchase_order" + PAYABLES_NOTIFY_APPROVER = "payables_notify_approver" + PAYABLES_NOTIFY_PAYER = "payables_notify_payer" + + end +end \ No newline at end of file diff --git a/lib/monite/types/document_type_enum.rb b/lib/monite/types/document_type_enum.rb new file mode 100644 index 0000000..c62886d --- /dev/null +++ b/lib/monite/types/document_type_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Monite + class DocumentTypeEnum + + QUOTE = "quote" + INVOICE = "invoice" + CREDIT_NOTE = "credit_note" + DISCOUNT_REMINDER = "discount_reminder" + FINAL_REMINDER = "final_reminder" + PAYABLES_PURCHASE_ORDER = "payables_purchase_order" + OVERDUE_REMINDER = "overdue_reminder" + + end +end \ No newline at end of file diff --git a/lib/monite/types/document_type_prefix.rb b/lib/monite/types/document_type_prefix.rb new file mode 100644 index 0000000..c9cdf7e --- /dev/null +++ b/lib/monite/types/document_type_prefix.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class DocumentTypePrefix + # @return [String] + attr_reader :credit_note + # @return [String] + attr_reader :invoice + # @return [String] + attr_reader :purchase_order + # @return [String] + attr_reader :quote + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param credit_note [String] + # @param invoice [String] + # @param purchase_order [String] + # @param quote [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DocumentTypePrefix] + def initialize(credit_note: OMIT, invoice: OMIT, purchase_order: OMIT, quote: OMIT, additional_properties: nil) + @credit_note = credit_note if credit_note != OMIT + @invoice = invoice if invoice != OMIT + @purchase_order = purchase_order if purchase_order != OMIT + @quote = quote if quote != OMIT + @additional_properties = additional_properties + @_field_set = { "credit_note": credit_note, "invoice": invoice, "purchase_order": purchase_order, "quote": quote }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DocumentTypePrefix + # + # @param json_object [String] + # @return [Monite::DocumentTypePrefix] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + credit_note = parsed_json["credit_note"] + invoice = parsed_json["invoice"] + purchase_order = parsed_json["purchase_order"] + quote = parsed_json["quote"] + new( + credit_note: credit_note, + invoice: invoice, + purchase_order: purchase_order, + quote: quote, + additional_properties: struct + ) + end +# Serialize an instance of DocumentTypePrefix to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.credit_note&.is_a?(String) != false || raise("Passed value for field obj.credit_note is not the expected type, validation failed.") + obj.invoice&.is_a?(String) != false || raise("Passed value for field obj.invoice is not the expected type, validation failed.") + obj.purchase_order&.is_a?(String) != false || raise("Passed value for field obj.purchase_order is not the expected type, validation failed.") + obj.quote&.is_a?(String) != false || raise("Passed value for field obj.quote is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/domain_list_response.rb b/lib/monite/types/domain_list_response.rb new file mode 100644 index 0000000..dc8be35 --- /dev/null +++ b/lib/monite/types/domain_list_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "domain_response" +require "ostruct" +require "json" + +module Monite + class DomainListResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DomainListResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of DomainListResponse + # + # @param json_object [String] + # @return [Monite::DomainListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::DomainResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of DomainListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/domain_response.rb b/lib/monite/types/domain_response.rb new file mode 100644 index 0000000..005693d --- /dev/null +++ b/lib/monite/types/domain_response.rb @@ -0,0 +1,102 @@ +# frozen_string_literal: true +require_relative "domain_response_dns_records" +require "date" +require "ostruct" +require "json" + +module Monite + class DomainResponse + # @return [String] Entry UUID + attr_reader :id + # @return [String] A dedicated IP address assigned to this mailbox and used to send outgoing email. + attr_reader :dedicated_ip + # @return [Monite::DomainResponseDnsRecords] + attr_reader :dns_records + # @return [String] The domain name. + attr_reader :domain + # @return [DateTime] The time the domain was updated for the last time + attr_reader :last_updated_at + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Entry UUID + # @param dedicated_ip [String] A dedicated IP address assigned to this mailbox and used to send outgoing email. + # @param dns_records [Monite::DomainResponseDnsRecords] + # @param domain [String] The domain name. + # @param last_updated_at [DateTime] The time the domain was updated for the last time + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::DomainResponse] + def initialize(id:, dedicated_ip: OMIT, dns_records:, domain:, last_updated_at: OMIT, status:, additional_properties: nil) + @id = id + @dedicated_ip = dedicated_ip if dedicated_ip != OMIT + @dns_records = dns_records + @domain = domain + @last_updated_at = last_updated_at if last_updated_at != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "dedicated_ip": dedicated_ip, "dns_records": dns_records, "domain": domain, "last_updated_at": last_updated_at, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of DomainResponse + # + # @param json_object [String] + # @return [Monite::DomainResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + dedicated_ip = parsed_json["dedicated_ip"] + unless parsed_json["dns_records"].nil? + dns_records = parsed_json["dns_records"].to_json + dns_records = Monite::DomainResponseDnsRecords.from_json(json_object: dns_records) + else + dns_records = nil + end + domain = parsed_json["domain"] + last_updated_at = unless parsed_json["last_updated_at"].nil? + DateTime.parse(parsed_json["last_updated_at"]) +else + nil +end + status = parsed_json["status"] + new( + id: id, + dedicated_ip: dedicated_ip, + dns_records: dns_records, + domain: domain, + last_updated_at: last_updated_at, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of DomainResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.dedicated_ip&.is_a?(String) != false || raise("Passed value for field obj.dedicated_ip is not the expected type, validation failed.") + Monite::DomainResponseDnsRecords.validate_raw(obj: obj.dns_records) + obj.domain.is_a?(String) != false || raise("Passed value for field obj.domain is not the expected type, validation failed.") + obj.last_updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.last_updated_at is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/domain_response_dns_records.rb b/lib/monite/types/domain_response_dns_records.rb new file mode 100644 index 0000000..be6067e --- /dev/null +++ b/lib/monite/types/domain_response_dns_records.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require "json" +require_relative "dns_records" + +module Monite + class DomainResponseDnsRecords + + +# Deserialize a JSON object to an instance of DomainResponseDnsRecords + # + # @param json_object [String] + # @return [Monite::DomainResponseDnsRecords] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::DnsRecords.validate_raw(obj: struct) + unless struct.nil? + return Monite::DnsRecords.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::DnsRecords.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/e_invoicing_retrieve_list_data.rb b/lib/monite/types/e_invoicing_retrieve_list_data.rb new file mode 100644 index 0000000..7560e3b --- /dev/null +++ b/lib/monite/types/e_invoicing_retrieve_list_data.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "einvoicing_connection_response" +require "ostruct" +require "json" + +module Monite + class EInvoicingRetrieveListData + # @return [Array] List of connections for the current page + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] List of connections for the current page + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EInvoicingRetrieveListData] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of EInvoicingRetrieveListData + # + # @param json_object [String] + # @return [Monite::EInvoicingRetrieveListData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::EinvoicingConnectionResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of EInvoicingRetrieveListData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/einvoice_schema_type_enum.rb b/lib/monite/types/einvoice_schema_type_enum.rb new file mode 100644 index 0000000..c317f73 --- /dev/null +++ b/lib/monite/types/einvoice_schema_type_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class EinvoiceSchemaTypeEnum + + DE_VAT = "DE:VAT" + NL_KVK = "NL:KVK" + NL_VAT = "NL:VAT" + BE_VAT = "BE:VAT" + BE_EN = "BE:EN" + + end +end \ No newline at end of file diff --git a/lib/monite/types/einvoicing_address.rb b/lib/monite/types/einvoicing_address.rb new file mode 100644 index 0000000..a8c5b6e --- /dev/null +++ b/lib/monite/types/einvoicing_address.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require_relative "allowed_einvoicing_country_codes" +require "ostruct" +require "json" + +module Monite + class EinvoicingAddress + # @return [String] Street address line 1 + attr_reader :address_line_1 + # @return [String] Street address line 2 + attr_reader :address_line_2 + # @return [String] City name + attr_reader :city + # @return [Monite::AllowedEinvoicingCountryCodes] Country name + attr_reader :country + # @return [String] Postal/ZIP code + attr_reader :postal_code + # @return [String] State/Province/County + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address_line_1 [String] Street address line 1 + # @param address_line_2 [String] Street address line 2 + # @param city [String] City name + # @param country [Monite::AllowedEinvoicingCountryCodes] Country name + # @param postal_code [String] Postal/ZIP code + # @param state [String] State/Province/County + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EinvoicingAddress] + def initialize(address_line_1:, address_line_2: OMIT, city:, country:, postal_code:, state: OMIT, additional_properties: nil) + @address_line_1 = address_line_1 + @address_line_2 = address_line_2 if address_line_2 != OMIT + @city = city + @country = country + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "address_line1": address_line_1, "address_line2": address_line_2, "city": city, "country": country, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EinvoicingAddress + # + # @param json_object [String] + # @return [Monite::EinvoicingAddress] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + address_line_1 = parsed_json["address_line1"] + address_line_2 = parsed_json["address_line2"] + city = parsed_json["city"] + country = parsed_json["country"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + address_line_1: address_line_1, + address_line_2: address_line_2, + city: city, + country: country, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of EinvoicingAddress to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.address_line_1.is_a?(String) != false || raise("Passed value for field obj.address_line_1 is not the expected type, validation failed.") + obj.address_line_2&.is_a?(String) != false || raise("Passed value for field obj.address_line_2 is not the expected type, validation failed.") + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedEinvoicingCountryCodes) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/einvoicing_connection_response.rb b/lib/monite/types/einvoicing_connection_response.rb new file mode 100644 index 0000000..8e251eb --- /dev/null +++ b/lib/monite/types/einvoicing_connection_response.rb @@ -0,0 +1,132 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "einvoicing_address" +require_relative "einvoicing_network_credentials_response" +require "ostruct" +require "json" + +module Monite + class EinvoicingConnectionResponse + # @return [String] + attr_reader :id + # @return [DateTime] Date of Integration + attr_reader :created_at + # @return [DateTime] Last update of Integration + attr_reader :updated_at + # @return [Monite::EinvoicingAddress] Integration Address + attr_reader :address + # @return [Array] List of credentials + attr_reader :credentials + # @return [String] ID of the entity + attr_reader :entity_id + # @return [String] Legal name of the Entity + attr_reader :legal_name + # @return [String] ID assigned by integration partner + attr_reader :provider_id + # @return [String] Current status of the integration + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Date of Integration + # @param updated_at [DateTime] Last update of Integration + # @param address [Monite::EinvoicingAddress] Integration Address + # @param credentials [Array] List of credentials + # @param entity_id [String] ID of the entity + # @param legal_name [String] Legal name of the Entity + # @param provider_id [String] ID assigned by integration partner + # @param status [String] Current status of the integration + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EinvoicingConnectionResponse] + def initialize(id:, created_at:, updated_at:, address:, credentials:, entity_id:, legal_name:, provider_id: OMIT, status:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @address = address + @credentials = credentials + @entity_id = entity_id + @legal_name = legal_name + @provider_id = provider_id if provider_id != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "address": address, "credentials": credentials, "entity_id": entity_id, "legal_name": legal_name, "provider_id": provider_id, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EinvoicingConnectionResponse + # + # @param json_object [String] + # @return [Monite::EinvoicingConnectionResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::EinvoicingAddress.from_json(json_object: address) + else + address = nil + end + credentials = parsed_json["credentials"]&.map do | item | + item = item.to_json + Monite::EinvoicingNetworkCredentialsResponse.from_json(json_object: item) +end + entity_id = parsed_json["entity_id"] + legal_name = parsed_json["legal_name"] + provider_id = parsed_json["provider_id"] + status = parsed_json["status"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + address: address, + credentials: credentials, + entity_id: entity_id, + legal_name: legal_name, + provider_id: provider_id, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of EinvoicingConnectionResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + Monite::EinvoicingAddress.validate_raw(obj: obj.address) + obj.credentials.is_a?(Array) != false || raise("Passed value for field obj.credentials is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.provider_id&.is_a?(String) != false || raise("Passed value for field obj.provider_id is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/einvoicing_network_credentials_response.rb b/lib/monite/types/einvoicing_network_credentials_response.rb new file mode 100644 index 0000000..3ee234f --- /dev/null +++ b/lib/monite/types/einvoicing_network_credentials_response.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "einvoice_schema_type_enum" +require "ostruct" +require "json" + +module Monite + class EinvoicingNetworkCredentialsResponse + # @return [String] ID of the credentials + attr_reader :id + # @return [DateTime] Date of credential + attr_reader :created_at + # @return [DateTime] Last update of credential + attr_reader :updated_at + # @return [String] ID of the Einvoicing connection + attr_reader :einvoicing_connection_id + # @return [String] Network participant identifier + attr_reader :network_credentials_identifier + # @return [Monite::EinvoiceSchemaTypeEnum] Network scheme identifier + attr_reader :network_credentials_schema + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of the credentials + # @param created_at [DateTime] Date of credential + # @param updated_at [DateTime] Last update of credential + # @param einvoicing_connection_id [String] ID of the Einvoicing connection + # @param network_credentials_identifier [String] Network participant identifier + # @param network_credentials_schema [Monite::EinvoiceSchemaTypeEnum] Network scheme identifier + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EinvoicingNetworkCredentialsResponse] + def initialize(id:, created_at:, updated_at:, einvoicing_connection_id:, network_credentials_identifier:, network_credentials_schema:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @einvoicing_connection_id = einvoicing_connection_id + @network_credentials_identifier = network_credentials_identifier + @network_credentials_schema = network_credentials_schema + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "einvoicing_connection_id": einvoicing_connection_id, "network_credentials_identifier": network_credentials_identifier, "network_credentials_schema": network_credentials_schema } + end +# Deserialize a JSON object to an instance of EinvoicingNetworkCredentialsResponse + # + # @param json_object [String] + # @return [Monite::EinvoicingNetworkCredentialsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + einvoicing_connection_id = parsed_json["einvoicing_connection_id"] + network_credentials_identifier = parsed_json["network_credentials_identifier"] + network_credentials_schema = parsed_json["network_credentials_schema"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + einvoicing_connection_id: einvoicing_connection_id, + network_credentials_identifier: network_credentials_identifier, + network_credentials_schema: network_credentials_schema, + additional_properties: struct + ) + end +# Serialize an instance of EinvoicingNetworkCredentialsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.einvoicing_connection_id.is_a?(String) != false || raise("Passed value for field obj.einvoicing_connection_id is not the expected type, validation failed.") + obj.network_credentials_identifier.is_a?(String) != false || raise("Passed value for field obj.network_credentials_identifier is not the expected type, validation failed.") + obj.network_credentials_schema.is_a?(Monite::EinvoiceSchemaTypeEnum) != false || raise("Passed value for field obj.network_credentials_schema is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_address_response_schema.rb b/lib/monite/types/entity_address_response_schema.rb new file mode 100644 index 0000000..83b4920 --- /dev/null +++ b/lib/monite/types/entity_address_response_schema.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# A schema represents address info of the entity + class EntityAddressResponseSchema + # @return [String] A city (a full name) where the entity is registered + attr_reader :city + # @return [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + attr_reader :country + # @return [String] A street where the entity is registered + attr_reader :line_1 + # @return [String] An alternative street used by the entity + attr_reader :line_2 + # @return [String] A postal code of the address where the entity is registered + attr_reader :postal_code + # @return [String] A state in a country where the entity is registered + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] A city (a full name) where the entity is registered + # @param country [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + # @param line_1 [String] A street where the entity is registered + # @param line_2 [String] An alternative street used by the entity + # @param postal_code [String] A postal code of the address where the entity is registered + # @param state [String] A state in a country where the entity is registered + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityAddressResponseSchema] + def initialize(city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityAddressResponseSchema + # + # @param json_object [String] + # @return [Monite::EntityAddressResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of EntityAddressResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_address_schema.rb b/lib/monite/types/entity_address_schema.rb new file mode 100644 index 0000000..390862d --- /dev/null +++ b/lib/monite/types/entity_address_schema.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# A schema represents address info of the entity + class EntityAddressSchema + # @return [String] A city (a full name) where the entity is registered + attr_reader :city + # @return [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + attr_reader :country + # @return [String] A street where the entity is registered + attr_reader :line_1 + # @return [String] An alternative street used by the entity + attr_reader :line_2 + # @return [String] A postal code of the address where the entity is registered + attr_reader :postal_code + # @return [String] State, county, province, prefecture, region, or similar component of the +# entity's address. For US entities, `state` is required and must be a two-letter +# [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for +# example, NY or CA. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] A city (a full name) where the entity is registered + # @param country [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + # @param line_1 [String] A street where the entity is registered + # @param line_2 [String] An alternative street used by the entity + # @param postal_code [String] A postal code of the address where the entity is registered + # @param state [String] State, county, province, prefecture, region, or similar component of the +# entity's address. For US entities, `state` is required and must be a two-letter +# [USPS state abbreviation](https://pe.usps.com/text/pub28/28apb.htm), for +# example, NY or CA. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityAddressSchema] + def initialize(city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityAddressSchema + # + # @param json_object [String] + # @return [Monite::EntityAddressSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of EntityAddressSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_bank_account_pagination_response.rb b/lib/monite/types/entity_bank_account_pagination_response.rb new file mode 100644 index 0000000..af97e60 --- /dev/null +++ b/lib/monite/types/entity_bank_account_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "entity_bank_account_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of an entity's bank accounts. + class EntityBankAccountPaginationResponse + # @return [Array] A list of an entity's bank accounts. + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A list of an entity's bank accounts. + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityBankAccountPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityBankAccountPaginationResponse + # + # @param json_object [String] + # @return [Monite::EntityBankAccountPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::EntityBankAccountResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of EntityBankAccountPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_bank_account_response.rb b/lib/monite/types/entity_bank_account_response.rb new file mode 100644 index 0000000..66d2868 --- /dev/null +++ b/lib/monite/types/entity_bank_account_response.rb @@ -0,0 +1,161 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite +# Represents a bank account owned by an entity. + class EntityBankAccountResponse + # @return [String] Unique ID of the bank account. + attr_reader :id + # @return [String] The name of the person or business that owns this bank account. Required if the +# account currency is GBP or USD. + attr_reader :account_holder_name + # @return [String] The bank account number. Required if the account currency is GBP or USD. UK +# account numbers typically contain 8 digits. US bank account numbers contain 9 to +# 12 digits. + attr_reader :account_number + # @return [String] The bank name. + attr_reader :bank_name + # @return [String] The SWIFT/BIC code of the bank. + attr_reader :bic + # @return [Monite::AllowedCountries] The country in which the bank account is registered, repsesented as a two-letter +# country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [Monite::CurrencyEnum] The currency of the bank account, represented as a three-letter ISO [currency +# code](https://docs.monite.com/references/currencies). + attr_reader :currency + # @return [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. + attr_reader :display_name + # @return [String] The IBAN of the bank account. Required if the account currency is EUR. + attr_reader :iban + # @return [Boolean] Indicates whether this bank account is the default one for its currency. + attr_reader :is_default_for_currency + # @return [String] The bank's routing transit number (RTN) or branch code. Required if the account +# currency is USD. US routing numbers consist of 9 digits. + attr_reader :routing_number + # @return [String] The bank's sort code. Required if the account currency is GBP. + attr_reader :sort_code + # @return [String] ID of the entity user who added this bank account, or `null` if it was added +# using a partner access token. + attr_reader :was_created_by_user_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the bank account. + # @param account_holder_name [String] The name of the person or business that owns this bank account. Required if the +# account currency is GBP or USD. + # @param account_number [String] The bank account number. Required if the account currency is GBP or USD. UK +# account numbers typically contain 8 digits. US bank account numbers contain 9 to +# 12 digits. + # @param bank_name [String] The bank name. + # @param bic [String] The SWIFT/BIC code of the bank. + # @param country [Monite::AllowedCountries] The country in which the bank account is registered, repsesented as a two-letter +# country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param currency [Monite::CurrencyEnum] The currency of the bank account, represented as a three-letter ISO [currency +# code](https://docs.monite.com/references/currencies). + # @param display_name [String] User-defined name of this bank account, such as 'Primary account' or 'Savings +# account'. + # @param iban [String] The IBAN of the bank account. Required if the account currency is EUR. + # @param is_default_for_currency [Boolean] Indicates whether this bank account is the default one for its currency. + # @param routing_number [String] The bank's routing transit number (RTN) or branch code. Required if the account +# currency is USD. US routing numbers consist of 9 digits. + # @param sort_code [String] The bank's sort code. Required if the account currency is GBP. + # @param was_created_by_user_id [String] ID of the entity user who added this bank account, or `null` if it was added +# using a partner access token. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityBankAccountResponse] + def initialize(id:, account_holder_name: OMIT, account_number: OMIT, bank_name: OMIT, bic: OMIT, country: OMIT, currency: OMIT, display_name: OMIT, iban: OMIT, is_default_for_currency: OMIT, routing_number: OMIT, sort_code: OMIT, was_created_by_user_id: OMIT, additional_properties: nil) + @id = id + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bank_name = bank_name if bank_name != OMIT + @bic = bic if bic != OMIT + @country = country if country != OMIT + @currency = currency if currency != OMIT + @display_name = display_name if display_name != OMIT + @iban = iban if iban != OMIT + @is_default_for_currency = is_default_for_currency if is_default_for_currency != OMIT + @routing_number = routing_number if routing_number != OMIT + @sort_code = sort_code if sort_code != OMIT + @was_created_by_user_id = was_created_by_user_id if was_created_by_user_id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "account_holder_name": account_holder_name, "account_number": account_number, "bank_name": bank_name, "bic": bic, "country": country, "currency": currency, "display_name": display_name, "iban": iban, "is_default_for_currency": is_default_for_currency, "routing_number": routing_number, "sort_code": sort_code, "was_created_by_user_id": was_created_by_user_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityBankAccountResponse + # + # @param json_object [String] + # @return [Monite::EntityBankAccountResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bank_name = parsed_json["bank_name"] + bic = parsed_json["bic"] + country = parsed_json["country"] + currency = parsed_json["currency"] + display_name = parsed_json["display_name"] + iban = parsed_json["iban"] + is_default_for_currency = parsed_json["is_default_for_currency"] + routing_number = parsed_json["routing_number"] + sort_code = parsed_json["sort_code"] + was_created_by_user_id = parsed_json["was_created_by_user_id"] + new( + id: id, + account_holder_name: account_holder_name, + account_number: account_number, + bank_name: bank_name, + bic: bic, + country: country, + currency: currency, + display_name: display_name, + iban: iban, + is_default_for_currency: is_default_for_currency, + routing_number: routing_number, + sort_code: sort_code, + was_created_by_user_id: was_created_by_user_id, + additional_properties: struct + ) + end +# Serialize an instance of EntityBankAccountResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bank_name&.is_a?(String) != false || raise("Passed value for field obj.bank_name is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.display_name&.is_a?(String) != false || raise("Passed value for field obj.display_name is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.is_default_for_currency&.is_a?(Boolean) != false || raise("Passed value for field obj.is_default_for_currency is not the expected type, validation failed.") + obj.routing_number&.is_a?(String) != false || raise("Passed value for field obj.routing_number is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + obj.was_created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.was_created_by_user_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_business_structure.rb b/lib/monite/types/entity_business_structure.rb new file mode 100644 index 0000000..d8cd0cf --- /dev/null +++ b/lib/monite/types/entity_business_structure.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Monite + class EntityBusinessStructure + + INCORPORATED_PARTNERSHIP = "incorporated_partnership" + UNINCORPORATED_PARTNERSHIP = "unincorporated_partnership" + PUBLIC_CORPORATION = "public_corporation" + PRIVATE_CORPORATION = "private_corporation" + SOLE_PROPRIETORSHIP = "sole_proprietorship" + SINGLE_MEMBER_LLC = "single_member_llc" + MULTI_MEMBER_LLC = "multi_member_llc" + PRIVATE_PARTNERSHIP = "private_partnership" + UNINCORPORATED_ASSOCIATION = "unincorporated_association" + PUBLIC_PARTNERSHIP = "public_partnership" + + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_cursor_fields.rb b/lib/monite/types/entity_cursor_fields.rb new file mode 100644 index 0000000..aba0000 --- /dev/null +++ b/lib/monite/types/entity_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class EntityCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_individual_response.rb b/lib/monite/types/entity_individual_response.rb new file mode 100644 index 0000000..cf05d19 --- /dev/null +++ b/lib/monite/types/entity_individual_response.rb @@ -0,0 +1,157 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "entity_address_response_schema" +require_relative "individual_response_schema" +require_relative "file_schema_3" +require_relative "entity_status_enum" +require "ostruct" +require "json" + +module Monite + class EntityIndividualResponse + # @return [String] UUID entity ID + attr_reader :id + # @return [DateTime] UTC datetime + attr_reader :created_at + # @return [DateTime] UTC datetime + attr_reader :updated_at + # @return [Monite::EntityAddressResponseSchema] An address description of the entity + attr_reader :address + # @return [String] An official email address of the entity + attr_reader :email + # @return [Monite::IndividualResponseSchema] A set of metadata describing an individual + attr_reader :individual + # @return [Monite::FileSchema3] A logo image of the entity + attr_reader :logo + # @return [String] A phone number of the entity + attr_reader :phone + # @return [Monite::EntityStatusEnum] record status, 'active' by default + attr_reader :status + # @return [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] UUID entity ID + # @param created_at [DateTime] UTC datetime + # @param updated_at [DateTime] UTC datetime + # @param address [Monite::EntityAddressResponseSchema] An address description of the entity + # @param email [String] An official email address of the entity + # @param individual [Monite::IndividualResponseSchema] A set of metadata describing an individual + # @param logo [Monite::FileSchema3] A logo image of the entity + # @param phone [String] A phone number of the entity + # @param status [Monite::EntityStatusEnum] record status, 'active' by default + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityIndividualResponse] + def initialize(id:, created_at:, updated_at:, address:, email: OMIT, individual:, logo: OMIT, phone: OMIT, status:, tax_id: OMIT, website: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @address = address + @email = email if email != OMIT + @individual = individual + @logo = logo if logo != OMIT + @phone = phone if phone != OMIT + @status = status + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "address": address, "email": email, "individual": individual, "logo": logo, "phone": phone, "status": status, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityIndividualResponse + # + # @param json_object [String] + # @return [Monite::EntityIndividualResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::EntityAddressResponseSchema.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::IndividualResponseSchema.from_json(json_object: individual) + else + individual = nil + end + unless parsed_json["logo"].nil? + logo = parsed_json["logo"].to_json + logo = Monite::FileSchema3.from_json(json_object: logo) + else + logo = nil + end + phone = parsed_json["phone"] + status = parsed_json["status"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + address: address, + email: email, + individual: individual, + logo: logo, + phone: phone, + status: status, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of EntityIndividualResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + Monite::EntityAddressResponseSchema.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + Monite::IndividualResponseSchema.validate_raw(obj: obj.individual) + obj.logo.nil? || Monite::FileSchema3.validate_raw(obj: obj.logo) + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.status.is_a?(Monite::EntityStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_onboarding_data_response.rb b/lib/monite/types/entity_onboarding_data_response.rb new file mode 100644 index 0000000..d5df201 --- /dev/null +++ b/lib/monite/types/entity_onboarding_data_response.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true +require_relative "business_profile_output" +require_relative "ownership_declaration_output" +require_relative "terms_of_service_acceptance_output" +require "ostruct" +require "json" + +module Monite + class EntityOnboardingDataResponse + # @return [Monite::BusinessProfileOutput] Business information about the entity. + attr_reader :business_profile + # @return [Monite::OwnershipDeclarationOutput] Used to attest that the beneficial owner information provided is both current +# and correct. + attr_reader :ownership_declaration + # @return [Monite::TermsOfServiceAcceptanceOutput] Details on the entity's acceptance of the service agreement. + attr_reader :tos_acceptance + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param business_profile [Monite::BusinessProfileOutput] Business information about the entity. + # @param ownership_declaration [Monite::OwnershipDeclarationOutput] Used to attest that the beneficial owner information provided is both current +# and correct. + # @param tos_acceptance [Monite::TermsOfServiceAcceptanceOutput] Details on the entity's acceptance of the service agreement. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityOnboardingDataResponse] + def initialize(business_profile: OMIT, ownership_declaration: OMIT, tos_acceptance: OMIT, additional_properties: nil) + @business_profile = business_profile if business_profile != OMIT + @ownership_declaration = ownership_declaration if ownership_declaration != OMIT + @tos_acceptance = tos_acceptance if tos_acceptance != OMIT + @additional_properties = additional_properties + @_field_set = { "business_profile": business_profile, "ownership_declaration": ownership_declaration, "tos_acceptance": tos_acceptance }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityOnboardingDataResponse + # + # @param json_object [String] + # @return [Monite::EntityOnboardingDataResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["business_profile"].nil? + business_profile = parsed_json["business_profile"].to_json + business_profile = Monite::BusinessProfileOutput.from_json(json_object: business_profile) + else + business_profile = nil + end + unless parsed_json["ownership_declaration"].nil? + ownership_declaration = parsed_json["ownership_declaration"].to_json + ownership_declaration = Monite::OwnershipDeclarationOutput.from_json(json_object: ownership_declaration) + else + ownership_declaration = nil + end + unless parsed_json["tos_acceptance"].nil? + tos_acceptance = parsed_json["tos_acceptance"].to_json + tos_acceptance = Monite::TermsOfServiceAcceptanceOutput.from_json(json_object: tos_acceptance) + else + tos_acceptance = nil + end + new( + business_profile: business_profile, + ownership_declaration: ownership_declaration, + tos_acceptance: tos_acceptance, + additional_properties: struct + ) + end +# Serialize an instance of EntityOnboardingDataResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.business_profile.nil? || Monite::BusinessProfileOutput.validate_raw(obj: obj.business_profile) + obj.ownership_declaration.nil? || Monite::OwnershipDeclarationOutput.validate_raw(obj: obj.ownership_declaration) + obj.tos_acceptance.nil? || Monite::TermsOfServiceAcceptanceOutput.validate_raw(obj: obj.tos_acceptance) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_onboarding_documents.rb b/lib/monite/types/entity_onboarding_documents.rb new file mode 100644 index 0000000..27431c0 --- /dev/null +++ b/lib/monite/types/entity_onboarding_documents.rb @@ -0,0 +1,126 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class EntityOnboardingDocuments + # @return [String] + attr_reader :verification_document_front + # @return [String] + attr_reader :verification_document_back + # @return [String] + attr_reader :additional_verification_document_front + # @return [String] + attr_reader :additional_verification_document_back + # @return [Array] + attr_reader :bank_account_ownership_verification + # @return [Array] + attr_reader :company_license + # @return [Array] + attr_reader :company_memorandum_of_association + # @return [Array] + attr_reader :company_ministerial_decree + # @return [Array] + attr_reader :company_registration_verification + # @return [Array] + attr_reader :company_tax_id_verification + # @return [Array] + attr_reader :proof_of_registration + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param verification_document_front [String] + # @param verification_document_back [String] + # @param additional_verification_document_front [String] + # @param additional_verification_document_back [String] + # @param bank_account_ownership_verification [Array] + # @param company_license [Array] + # @param company_memorandum_of_association [Array] + # @param company_ministerial_decree [Array] + # @param company_registration_verification [Array] + # @param company_tax_id_verification [Array] + # @param proof_of_registration [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityOnboardingDocuments] + def initialize(verification_document_front: OMIT, verification_document_back: OMIT, additional_verification_document_front: OMIT, additional_verification_document_back: OMIT, bank_account_ownership_verification: OMIT, company_license: OMIT, company_memorandum_of_association: OMIT, company_ministerial_decree: OMIT, company_registration_verification: OMIT, company_tax_id_verification: OMIT, proof_of_registration: OMIT, additional_properties: nil) + @verification_document_front = verification_document_front if verification_document_front != OMIT + @verification_document_back = verification_document_back if verification_document_back != OMIT + @additional_verification_document_front = additional_verification_document_front if additional_verification_document_front != OMIT + @additional_verification_document_back = additional_verification_document_back if additional_verification_document_back != OMIT + @bank_account_ownership_verification = bank_account_ownership_verification if bank_account_ownership_verification != OMIT + @company_license = company_license if company_license != OMIT + @company_memorandum_of_association = company_memorandum_of_association if company_memorandum_of_association != OMIT + @company_ministerial_decree = company_ministerial_decree if company_ministerial_decree != OMIT + @company_registration_verification = company_registration_verification if company_registration_verification != OMIT + @company_tax_id_verification = company_tax_id_verification if company_tax_id_verification != OMIT + @proof_of_registration = proof_of_registration if proof_of_registration != OMIT + @additional_properties = additional_properties + @_field_set = { "verification_document_front": verification_document_front, "verification_document_back": verification_document_back, "additional_verification_document_front": additional_verification_document_front, "additional_verification_document_back": additional_verification_document_back, "bank_account_ownership_verification": bank_account_ownership_verification, "company_license": company_license, "company_memorandum_of_association": company_memorandum_of_association, "company_ministerial_decree": company_ministerial_decree, "company_registration_verification": company_registration_verification, "company_tax_id_verification": company_tax_id_verification, "proof_of_registration": proof_of_registration }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityOnboardingDocuments + # + # @param json_object [String] + # @return [Monite::EntityOnboardingDocuments] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + verification_document_front = parsed_json["verification_document_front"] + verification_document_back = parsed_json["verification_document_back"] + additional_verification_document_front = parsed_json["additional_verification_document_front"] + additional_verification_document_back = parsed_json["additional_verification_document_back"] + bank_account_ownership_verification = parsed_json["bank_account_ownership_verification"] + company_license = parsed_json["company_license"] + company_memorandum_of_association = parsed_json["company_memorandum_of_association"] + company_ministerial_decree = parsed_json["company_ministerial_decree"] + company_registration_verification = parsed_json["company_registration_verification"] + company_tax_id_verification = parsed_json["company_tax_id_verification"] + proof_of_registration = parsed_json["proof_of_registration"] + new( + verification_document_front: verification_document_front, + verification_document_back: verification_document_back, + additional_verification_document_front: additional_verification_document_front, + additional_verification_document_back: additional_verification_document_back, + bank_account_ownership_verification: bank_account_ownership_verification, + company_license: company_license, + company_memorandum_of_association: company_memorandum_of_association, + company_ministerial_decree: company_ministerial_decree, + company_registration_verification: company_registration_verification, + company_tax_id_verification: company_tax_id_verification, + proof_of_registration: proof_of_registration, + additional_properties: struct + ) + end +# Serialize an instance of EntityOnboardingDocuments to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.verification_document_front&.is_a?(String) != false || raise("Passed value for field obj.verification_document_front is not the expected type, validation failed.") + obj.verification_document_back&.is_a?(String) != false || raise("Passed value for field obj.verification_document_back is not the expected type, validation failed.") + obj.additional_verification_document_front&.is_a?(String) != false || raise("Passed value for field obj.additional_verification_document_front is not the expected type, validation failed.") + obj.additional_verification_document_back&.is_a?(String) != false || raise("Passed value for field obj.additional_verification_document_back is not the expected type, validation failed.") + obj.bank_account_ownership_verification&.is_a?(Array) != false || raise("Passed value for field obj.bank_account_ownership_verification is not the expected type, validation failed.") + obj.company_license&.is_a?(Array) != false || raise("Passed value for field obj.company_license is not the expected type, validation failed.") + obj.company_memorandum_of_association&.is_a?(Array) != false || raise("Passed value for field obj.company_memorandum_of_association is not the expected type, validation failed.") + obj.company_ministerial_decree&.is_a?(Array) != false || raise("Passed value for field obj.company_ministerial_decree is not the expected type, validation failed.") + obj.company_registration_verification&.is_a?(Array) != false || raise("Passed value for field obj.company_registration_verification is not the expected type, validation failed.") + obj.company_tax_id_verification&.is_a?(Array) != false || raise("Passed value for field obj.company_tax_id_verification is not the expected type, validation failed.") + obj.proof_of_registration&.is_a?(Array) != false || raise("Passed value for field obj.proof_of_registration is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_organization_response.rb b/lib/monite/types/entity_organization_response.rb new file mode 100644 index 0000000..f8c071f --- /dev/null +++ b/lib/monite/types/entity_organization_response.rb @@ -0,0 +1,157 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "entity_address_response_schema" +require_relative "file_schema_3" +require_relative "organization_response_schema" +require_relative "entity_status_enum" +require "ostruct" +require "json" + +module Monite + class EntityOrganizationResponse + # @return [String] UUID entity ID + attr_reader :id + # @return [DateTime] UTC datetime + attr_reader :created_at + # @return [DateTime] UTC datetime + attr_reader :updated_at + # @return [Monite::EntityAddressResponseSchema] An address description of the entity + attr_reader :address + # @return [String] An official email address of the entity + attr_reader :email + # @return [Monite::FileSchema3] A logo image of the entity + attr_reader :logo + # @return [Monite::OrganizationResponseSchema] A set of metadata describing an organization + attr_reader :organization + # @return [String] A phone number of the entity + attr_reader :phone + # @return [Monite::EntityStatusEnum] record status, 'active' by default + attr_reader :status + # @return [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] UUID entity ID + # @param created_at [DateTime] UTC datetime + # @param updated_at [DateTime] UTC datetime + # @param address [Monite::EntityAddressResponseSchema] An address description of the entity + # @param email [String] An official email address of the entity + # @param logo [Monite::FileSchema3] A logo image of the entity + # @param organization [Monite::OrganizationResponseSchema] A set of metadata describing an organization + # @param phone [String] A phone number of the entity + # @param status [Monite::EntityStatusEnum] record status, 'active' by default + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityOrganizationResponse] + def initialize(id:, created_at:, updated_at:, address:, email: OMIT, logo: OMIT, organization:, phone: OMIT, status:, tax_id: OMIT, website: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @address = address + @email = email if email != OMIT + @logo = logo if logo != OMIT + @organization = organization + @phone = phone if phone != OMIT + @status = status + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "address": address, "email": email, "logo": logo, "organization": organization, "phone": phone, "status": status, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityOrganizationResponse + # + # @param json_object [String] + # @return [Monite::EntityOrganizationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::EntityAddressResponseSchema.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + unless parsed_json["logo"].nil? + logo = parsed_json["logo"].to_json + logo = Monite::FileSchema3.from_json(json_object: logo) + else + logo = nil + end + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::OrganizationResponseSchema.from_json(json_object: organization) + else + organization = nil + end + phone = parsed_json["phone"] + status = parsed_json["status"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + address: address, + email: email, + logo: logo, + organization: organization, + phone: phone, + status: status, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of EntityOrganizationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + Monite::EntityAddressResponseSchema.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.logo.nil? || Monite::FileSchema3.validate_raw(obj: obj.logo) + Monite::OrganizationResponseSchema.validate_raw(obj: obj.organization) + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.status.is_a?(Monite::EntityStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_pagination_response.rb b/lib/monite/types/entity_pagination_response.rb new file mode 100644 index 0000000..c14c8ce --- /dev/null +++ b/lib/monite/types/entity_pagination_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "entity_response" +require "ostruct" +require "json" + +module Monite + class EntityPaginationResponse + # @return [Array] A set of entities of different types returned per page + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A set of entities of different types returned per page + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityPaginationResponse] + def initialize(data:, prev_pagination_token: OMIT, next_pagination_token: OMIT, additional_properties: nil) + @data = data + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "prev_pagination_token": prev_pagination_token, "next_pagination_token": next_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityPaginationResponse + # + # @param json_object [String] + # @return [Monite::EntityPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::EntityResponse.from_json(json_object: item) +end + prev_pagination_token = parsed_json["prev_pagination_token"] + next_pagination_token = parsed_json["next_pagination_token"] + new( + data: data, + prev_pagination_token: prev_pagination_token, + next_pagination_token: next_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of EntityPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_response.rb b/lib/monite/types/entity_response.rb new file mode 100644 index 0000000..0d5cd7a --- /dev/null +++ b/lib/monite/types/entity_response.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true +require "json" +require_relative "entity_individual_response" +require_relative "entity_organization_response" + +module Monite +# A schema for a response after creation of an entity of different types + class EntityResponse + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::EntityResponse] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of EntityResponse + # + # @param json_object [String] + # @return [Monite::EntityResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "individual" + member = Monite::EntityIndividualResponse.from_json(json_object: json_object) + when "organization" + member = Monite::EntityOrganizationResponse.from_json(json_object: json_object) + else + member = Monite::EntityIndividualResponse.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "individual" + { **@member.to_json, type: @discriminant }.to_json + when "organization" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "individual" + Monite::EntityIndividualResponse.validate_raw(obj: obj) + when "organization" + Monite::EntityOrganizationResponse.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::EntityIndividualResponse] + # @return [Monite::EntityResponse] + def self.individual(member:) + new(member: member, discriminant: "individual") + end + # @param member [Monite::EntityOrganizationResponse] + # @return [Monite::EntityResponse] + def self.organization(member:) + new(member: member, discriminant: "organization") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_status_enum.rb b/lib/monite/types/entity_status_enum.rb new file mode 100644 index 0000000..c810276 --- /dev/null +++ b/lib/monite/types/entity_status_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class EntityStatusEnum + + ACTIVE = "active" + INACTIVE = "inactive" + DELETED = "deleted" + + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_type_enum.rb b/lib/monite/types/entity_type_enum.rb new file mode 100644 index 0000000..57e42ff --- /dev/null +++ b/lib/monite/types/entity_type_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class EntityTypeEnum + + INDIVIDUAL = "individual" + ORGANIZATION = "organization" + + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_user_cursor_fields.rb b/lib/monite/types/entity_user_cursor_fields.rb new file mode 100644 index 0000000..01054c8 --- /dev/null +++ b/lib/monite/types/entity_user_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + ENTITY_USER_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/entity_user_pagination_response.rb b/lib/monite/types/entity_user_pagination_response.rb new file mode 100644 index 0000000..ef44cda --- /dev/null +++ b/lib/monite/types/entity_user_pagination_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "entity_user_response" +require "ostruct" +require "json" + +module Monite + class EntityUserPaginationResponse + # @return [Array] array of records + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] array of records + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityUserPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityUserPaginationResponse + # + # @param json_object [String] + # @return [Monite::EntityUserPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::EntityUserResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of EntityUserPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_user_response.rb b/lib/monite/types/entity_user_response.rb new file mode 100644 index 0000000..bb015e6 --- /dev/null +++ b/lib/monite/types/entity_user_response.rb @@ -0,0 +1,137 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "status_enum" +require "ostruct" +require "json" + +module Monite + class EntityUserResponse + # @return [String] UUID entity user ID + attr_reader :id + # @return [DateTime] UTC datetime + attr_reader :created_at + # @return [DateTime] UTC datetime + attr_reader :updated_at + # @return [String] An entity user business email + attr_reader :email + # @return [String] First name + attr_reader :first_name + # @return [String] Last name + attr_reader :last_name + # @return [String] Login + attr_reader :login + # @return [String] An entity user phone number in the international format + attr_reader :phone + # @return [String] UUID role ID + attr_reader :role_id + # @return [Monite::StatusEnum] record status, 'active' by default + attr_reader :status + # @return [String] + attr_reader :userpic_file_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] UUID entity user ID + # @param created_at [DateTime] UTC datetime + # @param updated_at [DateTime] UTC datetime + # @param email [String] An entity user business email + # @param first_name [String] First name + # @param last_name [String] Last name + # @param login [String] Login + # @param phone [String] An entity user phone number in the international format + # @param role_id [String] UUID role ID + # @param status [Monite::StatusEnum] record status, 'active' by default + # @param userpic_file_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityUserResponse] + def initialize(id:, created_at:, updated_at:, email: OMIT, first_name: OMIT, last_name: OMIT, login:, phone: OMIT, role_id:, status:, userpic_file_id: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @email = email if email != OMIT + @first_name = first_name if first_name != OMIT + @last_name = last_name if last_name != OMIT + @login = login + @phone = phone if phone != OMIT + @role_id = role_id + @status = status + @userpic_file_id = userpic_file_id if userpic_file_id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "email": email, "first_name": first_name, "last_name": last_name, "login": login, "phone": phone, "role_id": role_id, "status": status, "userpic_file_id": userpic_file_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityUserResponse + # + # @param json_object [String] + # @return [Monite::EntityUserResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + email = parsed_json["email"] + first_name = parsed_json["first_name"] + last_name = parsed_json["last_name"] + login = parsed_json["login"] + phone = parsed_json["phone"] + role_id = parsed_json["role_id"] + status = parsed_json["status"] + userpic_file_id = parsed_json["userpic_file_id"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + email: email, + first_name: first_name, + last_name: last_name, + login: login, + phone: phone, + role_id: role_id, + status: status, + userpic_file_id: userpic_file_id, + additional_properties: struct + ) + end +# Serialize an instance of EntityUserResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name&.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.last_name&.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.login.is_a?(String) != false || raise("Passed value for field obj.login is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.role_id.is_a?(String) != false || raise("Passed value for field obj.role_id is not the expected type, validation failed.") + obj.status.is_a?(Monite::StatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.userpic_file_id&.is_a?(String) != false || raise("Passed value for field obj.userpic_file_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_vat_id_resource_list.rb b/lib/monite/types/entity_vat_id_resource_list.rb new file mode 100644 index 0000000..583fbe0 --- /dev/null +++ b/lib/monite/types/entity_vat_id_resource_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "entity_vat_id_response" +require "ostruct" +require "json" + +module Monite + class EntityVatIdResourceList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityVatIdResourceList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of EntityVatIdResourceList + # + # @param json_object [String] + # @return [Monite::EntityVatIdResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::EntityVatIdResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of EntityVatIdResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/entity_vat_id_response.rb b/lib/monite/types/entity_vat_id_response.rb new file mode 100644 index 0000000..588a0b9 --- /dev/null +++ b/lib/monite/types/entity_vat_id_response.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "vat_id_type_enum" +require "ostruct" +require "json" + +module Monite + class EntityVatIdResponse + # @return [String] + attr_reader :id + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [String] + attr_reader :entity_id + # @return [Monite::VatIdTypeEnum] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param country [Monite::AllowedCountries] + # @param entity_id [String] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EntityVatIdResponse] + def initialize(id:, country:, entity_id:, type: OMIT, value:, additional_properties: nil) + @id = id + @country = country + @entity_id = entity_id + @type = type if type != OMIT + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "country": country, "entity_id": entity_id, "type": type, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EntityVatIdResponse + # + # @param json_object [String] + # @return [Monite::EntityVatIdResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + country = parsed_json["country"] + entity_id = parsed_json["entity_id"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + id: id, + country: country, + entity_id: entity_id, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of EntityVatIdResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.type&.is_a?(Monite::VatIdTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/error_schema.rb b/lib/monite/types/error_schema.rb new file mode 100644 index 0000000..4ea2118 --- /dev/null +++ b/lib/monite/types/error_schema.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ErrorSchema + # @return [String] + attr_reader :message + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param message [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ErrorSchema] + def initialize(message:, additional_properties: nil) + @message = message + @additional_properties = additional_properties + @_field_set = { "message": message } + end +# Deserialize a JSON object to an instance of ErrorSchema + # + # @param json_object [String] + # @return [Monite::ErrorSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + message = parsed_json["message"] + new(message: message, additional_properties: struct) + end +# Serialize an instance of ErrorSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/error_schema_2.rb b/lib/monite/types/error_schema_2.rb new file mode 100644 index 0000000..6b2e87f --- /dev/null +++ b/lib/monite/types/error_schema_2.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ErrorSchema2 + # @return [String] + attr_reader :message + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param message [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ErrorSchema2] + def initialize(message:, additional_properties: nil) + @message = message + @additional_properties = additional_properties + @_field_set = { "message": message } + end +# Deserialize a JSON object to an instance of ErrorSchema2 + # + # @param json_object [String] + # @return [Monite::ErrorSchema2] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + message = parsed_json["message"] + new(message: message, additional_properties: struct) + end +# Serialize an instance of ErrorSchema2 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/error_schema_response.rb b/lib/monite/types/error_schema_response.rb new file mode 100644 index 0000000..1a6b027 --- /dev/null +++ b/lib/monite/types/error_schema_response.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "error_schema" +require "ostruct" +require "json" + +module Monite + class ErrorSchemaResponse + # @return [Monite::ErrorSchema] + attr_reader :error + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param error [Monite::ErrorSchema] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ErrorSchemaResponse] + def initialize(error:, additional_properties: nil) + @error = error + @additional_properties = additional_properties + @_field_set = { "error": error } + end +# Deserialize a JSON object to an instance of ErrorSchemaResponse + # + # @param json_object [String] + # @return [Monite::ErrorSchemaResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["error"].nil? + error = parsed_json["error"].to_json + error = Monite::ErrorSchema.from_json(json_object: error) + else + error = nil + end + new(error: error, additional_properties: struct) + end +# Serialize an instance of ErrorSchemaResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::ErrorSchema.validate_raw(obj: obj.error) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/error_schema_response_2.rb b/lib/monite/types/error_schema_response_2.rb new file mode 100644 index 0000000..b5a7292 --- /dev/null +++ b/lib/monite/types/error_schema_response_2.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "error_schema_2" +require "ostruct" +require "json" + +module Monite + class ErrorSchemaResponse2 + # @return [Monite::ErrorSchema2] + attr_reader :error + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param error [Monite::ErrorSchema2] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ErrorSchemaResponse2] + def initialize(error:, additional_properties: nil) + @error = error + @additional_properties = additional_properties + @_field_set = { "error": error } + end +# Deserialize a JSON object to an instance of ErrorSchemaResponse2 + # + # @param json_object [String] + # @return [Monite::ErrorSchemaResponse2] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["error"].nil? + error = parsed_json["error"].to_json + error = Monite::ErrorSchema2.from_json(json_object: error) + else + error = nil + end + new(error: error, additional_properties: struct) + end +# Serialize an instance of ErrorSchemaResponse2 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::ErrorSchema2.validate_raw(obj: obj.error) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/estimated_monthly_revenue.rb b/lib/monite/types/estimated_monthly_revenue.rb new file mode 100644 index 0000000..16f4d71 --- /dev/null +++ b/lib/monite/types/estimated_monthly_revenue.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite + class EstimatedMonthlyRevenue + # @return [Integer] The amount of the monthly revenue, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :amount + # @return [Monite::CurrencyEnum] [Currency code](https://docs.monite.com/references/currencies) of the revenue. + attr_reader :currency + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param amount [Integer] The amount of the monthly revenue, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param currency [Monite::CurrencyEnum] [Currency code](https://docs.monite.com/references/currencies) of the revenue. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EstimatedMonthlyRevenue] + def initialize(amount: OMIT, currency: OMIT, additional_properties: nil) + @amount = amount if amount != OMIT + @currency = currency if currency != OMIT + @additional_properties = additional_properties + @_field_set = { "amount": amount, "currency": currency }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EstimatedMonthlyRevenue + # + # @param json_object [String] + # @return [Monite::EstimatedMonthlyRevenue] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + amount = parsed_json["amount"] + currency = parsed_json["currency"] + new( + amount: amount, + currency: currency, + additional_properties: struct + ) + end +# Serialize an instance of EstimatedMonthlyRevenue to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.amount&.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/event_cursor_fields.rb b/lib/monite/types/event_cursor_fields.rb new file mode 100644 index 0000000..5d6d606 --- /dev/null +++ b/lib/monite/types/event_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class EventCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/event_pagination_resource.rb b/lib/monite/types/event_pagination_resource.rb new file mode 100644 index 0000000..e257508 --- /dev/null +++ b/lib/monite/types/event_pagination_resource.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "event_resource" +require "ostruct" +require "json" + +module Monite + class EventPaginationResource + # @return [Array] A set of events returned per page + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A set of events returned per page + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EventPaginationResource] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EventPaginationResource + # + # @param json_object [String] + # @return [Monite::EventPaginationResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::EventResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of EventPaginationResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/event_resource.rb b/lib/monite/types/event_resource.rb new file mode 100644 index 0000000..21d00f4 --- /dev/null +++ b/lib/monite/types/event_resource.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true +require "date" +require_relative "webhook_object_type" +require "ostruct" +require "json" + +module Monite + class EventResource + # @return [String] + attr_reader :id + # @return [DateTime] The timestamp that was generated at the time of making the database transaction +# that has initially caused the event + attr_reader :created_at + # @return [String] + attr_reader :action + # @return [String] + attr_reader :api_version + # @return [String] + attr_reader :description + # @return [String] + attr_reader :entity_id + # @return [Object] + attr_reader :object + # @return [Monite::WebhookObjectType] + attr_reader :object_type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] The timestamp that was generated at the time of making the database transaction +# that has initially caused the event + # @param action [String] + # @param api_version [String] + # @param description [String] + # @param entity_id [String] + # @param object [Object] + # @param object_type [Monite::WebhookObjectType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EventResource] + def initialize(id:, created_at: OMIT, action:, api_version: OMIT, description:, entity_id:, object: OMIT, object_type:, additional_properties: nil) + @id = id + @created_at = created_at if created_at != OMIT + @action = action + @api_version = api_version if api_version != OMIT + @description = description + @entity_id = entity_id + @object = object if object != OMIT + @object_type = object_type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "action": action, "api_version": api_version, "description": description, "entity_id": entity_id, "object": object, "object_type": object_type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EventResource + # + # @param json_object [String] + # @return [Monite::EventResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + action = parsed_json["action"] + api_version = parsed_json["api_version"] + description = parsed_json["description"] + entity_id = parsed_json["entity_id"] + object = parsed_json["object"] + object_type = parsed_json["object_type"] + new( + id: id, + created_at: created_at, + action: action, + api_version: api_version, + description: description, + entity_id: entity_id, + object: object, + object_type: object_type, + additional_properties: struct + ) + end +# Serialize an instance of EventResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + obj.api_version&.is_a?(String) != false || raise("Passed value for field obj.api_version is not the expected type, validation failed.") + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.object&.is_a?(Object) != false || raise("Passed value for field obj.object is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::WebhookObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/event_resource_for_webhook_client.rb b/lib/monite/types/event_resource_for_webhook_client.rb new file mode 100644 index 0000000..b8b4a18 --- /dev/null +++ b/lib/monite/types/event_resource_for_webhook_client.rb @@ -0,0 +1,120 @@ +# frozen_string_literal: true +require "date" +require_relative "webhook_object_type" +require "ostruct" +require "json" + +module Monite + class EventResourceForWebhookClient + # @return [String] + attr_reader :id + # @return [DateTime] The timestamp that was generated at the time of making the database transaction +# that has initially caused the event + attr_reader :created_at + # @return [String] + attr_reader :action + # @return [String] + attr_reader :api_version + # @return [String] + attr_reader :description + # @return [String] + attr_reader :entity_id + # @return [Object] + attr_reader :object + # @return [Monite::WebhookObjectType] + attr_reader :object_type + # @return [String] + attr_reader :webhook_subscription_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] The timestamp that was generated at the time of making the database transaction +# that has initially caused the event + # @param action [String] + # @param api_version [String] + # @param description [String] + # @param entity_id [String] + # @param object [Object] + # @param object_type [Monite::WebhookObjectType] + # @param webhook_subscription_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::EventResourceForWebhookClient] + def initialize(id:, created_at: OMIT, action:, api_version: OMIT, description:, entity_id:, object: OMIT, object_type:, webhook_subscription_id:, additional_properties: nil) + @id = id + @created_at = created_at if created_at != OMIT + @action = action + @api_version = api_version if api_version != OMIT + @description = description + @entity_id = entity_id + @object = object if object != OMIT + @object_type = object_type + @webhook_subscription_id = webhook_subscription_id + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "action": action, "api_version": api_version, "description": description, "entity_id": entity_id, "object": object, "object_type": object_type, "webhook_subscription_id": webhook_subscription_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of EventResourceForWebhookClient + # + # @param json_object [String] + # @return [Monite::EventResourceForWebhookClient] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + action = parsed_json["action"] + api_version = parsed_json["api_version"] + description = parsed_json["description"] + entity_id = parsed_json["entity_id"] + object = parsed_json["object"] + object_type = parsed_json["object_type"] + webhook_subscription_id = parsed_json["webhook_subscription_id"] + new( + id: id, + created_at: created_at, + action: action, + api_version: api_version, + description: description, + entity_id: entity_id, + object: object, + object_type: object_type, + webhook_subscription_id: webhook_subscription_id, + additional_properties: struct + ) + end +# Serialize an instance of EventResourceForWebhookClient to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.action.is_a?(String) != false || raise("Passed value for field obj.action is not the expected type, validation failed.") + obj.api_version&.is_a?(String) != false || raise("Passed value for field obj.api_version is not the expected type, validation failed.") + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.object&.is_a?(Object) != false || raise("Passed value for field obj.object is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::WebhookObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.webhook_subscription_id.is_a?(String) != false || raise("Passed value for field obj.webhook_subscription_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/exchange_rate.rb b/lib/monite/types/exchange_rate.rb new file mode 100644 index 0000000..b096d0d --- /dev/null +++ b/lib/monite/types/exchange_rate.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite + class ExchangeRate + # @return [Monite::CurrencyEnum] + attr_reader :base + # @return [Monite::CurrencyEnum] + attr_reader :to + # @return [Float] + attr_reader :rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param base [Monite::CurrencyEnum] + # @param to [Monite::CurrencyEnum] + # @param rate [Float] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ExchangeRate] + def initialize(base:, to:, rate:, additional_properties: nil) + @base = base + @to = to + @rate = rate + @additional_properties = additional_properties + @_field_set = { "base": base, "to": to, "rate": rate } + end +# Deserialize a JSON object to an instance of ExchangeRate + # + # @param json_object [String] + # @return [Monite::ExchangeRate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + base = parsed_json["base"] + to = parsed_json["to"] + rate = parsed_json["rate"] + new( + base: base, + to: to, + rate: rate, + additional_properties: struct + ) + end +# Serialize an instance of ExchangeRate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.base.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.base is not the expected type, validation failed.") + obj.to.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.to is not the expected type, validation failed.") + obj.rate.is_a?(Float) != false || raise("Passed value for field obj.rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/export_format.rb b/lib/monite/types/export_format.rb new file mode 100644 index 0000000..642867b --- /dev/null +++ b/lib/monite/types/export_format.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class ExportFormat + + CSV = "csv" + PDF = "pdf" + CSV_XERO = "csv_xero" + + end +end \ No newline at end of file diff --git a/lib/monite/types/export_object_schema.rb b/lib/monite/types/export_object_schema.rb new file mode 100644 index 0000000..4f25ac7 --- /dev/null +++ b/lib/monite/types/export_object_schema.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "json" +require_relative "export_payable_schema" +require_relative "export_receivable_schema" + +module Monite + class ExportObjectSchema + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::ExportObjectSchema] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of ExportObjectSchema + # + # @param json_object [String] + # @return [Monite::ExportObjectSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.name + when "payable" + member = Monite::ExportPayableSchema.from_json(json_object: json_object) + when "receivable" + member = Monite::ExportReceivableSchema.from_json(json_object: json_object) + else + member = Monite::ExportPayableSchema.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.name) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "payable" + { **@member.to_json, name: @discriminant }.to_json + when "receivable" + { **@member.to_json, name: @discriminant }.to_json + else + { "name": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.name + when "payable" + Monite::ExportPayableSchema.validate_raw(obj: obj) + when "receivable" + Monite::ExportReceivableSchema.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::ExportPayableSchema] + # @return [Monite::ExportObjectSchema] + def self.payable(member:) + new(member: member, discriminant: "payable") + end + # @param member [Monite::ExportReceivableSchema] + # @return [Monite::ExportObjectSchema] + def self.receivable(member:) + new(member: member, discriminant: "receivable") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/export_payable_schema.rb b/lib/monite/types/export_payable_schema.rb new file mode 100644 index 0000000..0aea95c --- /dev/null +++ b/lib/monite/types/export_payable_schema.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +require_relative "payable_state_enum" +require "ostruct" +require "json" + +module Monite + class ExportPayableSchema + # @return [Array] + attr_reader :statuses + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param statuses [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ExportPayableSchema] + def initialize(statuses:, additional_properties: nil) + @statuses = statuses + @additional_properties = additional_properties + @_field_set = { "statuses": statuses } + end +# Deserialize a JSON object to an instance of ExportPayableSchema + # + # @param json_object [String] + # @return [Monite::ExportPayableSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + statuses = parsed_json["statuses"] + new(statuses: statuses, additional_properties: struct) + end +# Serialize an instance of ExportPayableSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.statuses.is_a?(Array) != false || raise("Passed value for field obj.statuses is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/export_receivable_schema.rb b/lib/monite/types/export_receivable_schema.rb new file mode 100644 index 0000000..61e1889 --- /dev/null +++ b/lib/monite/types/export_receivable_schema.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +require_relative "receivables_status_enum" +require "ostruct" +require "json" + +module Monite + class ExportReceivableSchema + # @return [Array] + attr_reader :statuses + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param statuses [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ExportReceivableSchema] + def initialize(statuses:, additional_properties: nil) + @statuses = statuses + @additional_properties = additional_properties + @_field_set = { "statuses": statuses } + end +# Deserialize a JSON object to an instance of ExportReceivableSchema + # + # @param json_object [String] + # @return [Monite::ExportReceivableSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + statuses = parsed_json["statuses"] + new(statuses: statuses, additional_properties: struct) + end +# Serialize an instance of ExportReceivableSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.statuses.is_a?(Array) != false || raise("Passed value for field obj.statuses is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/export_setting_cursor_fields.rb b/lib/monite/types/export_setting_cursor_fields.rb new file mode 100644 index 0000000..cb339a4 --- /dev/null +++ b/lib/monite/types/export_setting_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ExportSettingCursorFields + + ID = "id" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/extra_data_resource.rb b/lib/monite/types/extra_data_resource.rb new file mode 100644 index 0000000..c7c77cc --- /dev/null +++ b/lib/monite/types/extra_data_resource.rb @@ -0,0 +1,116 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "supported_field_names" +require "ostruct" +require "json" + +module Monite + class ExtraDataResource + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :created_by + # @return [Monite::SupportedFieldNames] + attr_reader :field_name + # @return [String] + attr_reader :field_value + # @return [String] + attr_reader :object_id + # @return [String] + attr_reader :object_type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param created_by [String] + # @param field_name [Monite::SupportedFieldNames] + # @param field_value [String] + # @param object_id [String] + # @param object_type [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ExtraDataResource] + def initialize(id:, created_at:, updated_at:, created_by: OMIT, field_name:, field_value:, object_id:, object_type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @created_by = created_by if created_by != OMIT + @field_name = field_name + @field_value = field_value + @object_id = object_id + @object_type = object_type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_by": created_by, "field_name": field_name, "field_value": field_value, "object_id": object_id, "object_type": object_type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ExtraDataResource + # + # @param json_object [String] + # @return [Monite::ExtraDataResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_by = parsed_json["created_by"] + field_name = parsed_json["field_name"] + field_value = parsed_json["field_value"] + object_id = parsed_json["object_id"] + object_type = parsed_json["object_type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_by: created_by, + field_name: field_name, + field_value: field_value, + object_id: object_id, + object_type: object_type, + additional_properties: struct + ) + end +# Serialize an instance of ExtraDataResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_by&.is_a?(String) != false || raise("Passed value for field obj.created_by is not the expected type, validation failed.") + obj.field_name.is_a?(Monite::SupportedFieldNames) != false || raise("Passed value for field obj.field_name is not the expected type, validation failed.") + obj.field_value.is_a?(String) != false || raise("Passed value for field obj.field_value is not the expected type, validation failed.") + obj.object_id.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.object_type.is_a?(String) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/extra_data_resource_list.rb b/lib/monite/types/extra_data_resource_list.rb new file mode 100644 index 0000000..3dbce95 --- /dev/null +++ b/lib/monite/types/extra_data_resource_list.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require_relative "extra_data_resource" +require "ostruct" +require "json" + +module Monite + class ExtraDataResourceList + # @return [Array] + attr_reader :data + # @return [String] + attr_reader :next_pagination_token + # @return [String] + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] + # @param prev_pagination_token [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ExtraDataResourceList] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ExtraDataResourceList + # + # @param json_object [String] + # @return [Monite::ExtraDataResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ExtraDataResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ExtraDataResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/file_response.rb b/lib/monite/types/file_response.rb new file mode 100644 index 0000000..d7d517f --- /dev/null +++ b/lib/monite/types/file_response.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class FileResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :file_type + # @return [String] + attr_reader :md_5 + # @return [String] + attr_reader :mimetype + # @return [String] + attr_reader :name + # @return [String] + attr_reader :region + # @return [String] + attr_reader :s_3_bucket + # @return [String] + attr_reader :s_3_file_path + # @return [Integer] + attr_reader :size + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param file_type [String] + # @param md_5 [String] + # @param mimetype [String] + # @param name [String] + # @param region [String] + # @param s_3_bucket [String] + # @param s_3_file_path [String] + # @param size [Integer] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FileResponse] + def initialize(id:, created_at:, updated_at:, file_type:, md_5:, mimetype:, name:, region:, s_3_bucket:, s_3_file_path:, size:, url:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @file_type = file_type + @md_5 = md_5 + @mimetype = mimetype + @name = name + @region = region + @s_3_bucket = s_3_bucket + @s_3_file_path = s_3_file_path + @size = size + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "file_type": file_type, "md5": md_5, "mimetype": mimetype, "name": name, "region": region, "s3_bucket": s_3_bucket, "s3_file_path": s_3_file_path, "size": size, "url": url } + end +# Deserialize a JSON object to an instance of FileResponse + # + # @param json_object [String] + # @return [Monite::FileResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + file_type = parsed_json["file_type"] + md_5 = parsed_json["md5"] + mimetype = parsed_json["mimetype"] + name = parsed_json["name"] + region = parsed_json["region"] + s_3_bucket = parsed_json["s3_bucket"] + s_3_file_path = parsed_json["s3_file_path"] + size = parsed_json["size"] + url = parsed_json["url"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + file_type: file_type, + md_5: md_5, + mimetype: mimetype, + name: name, + region: region, + s_3_bucket: s_3_bucket, + s_3_file_path: s_3_file_path, + size: size, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of FileResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.file_type.is_a?(String) != false || raise("Passed value for field obj.file_type is not the expected type, validation failed.") + obj.md_5.is_a?(String) != false || raise("Passed value for field obj.md_5 is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.region.is_a?(String) != false || raise("Passed value for field obj.region is not the expected type, validation failed.") + obj.s_3_bucket.is_a?(String) != false || raise("Passed value for field obj.s_3_bucket is not the expected type, validation failed.") + obj.s_3_file_path.is_a?(String) != false || raise("Passed value for field obj.s_3_file_path is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/file_schema.rb b/lib/monite/types/file_schema.rb new file mode 100644 index 0000000..15bc5f0 --- /dev/null +++ b/lib/monite/types/file_schema.rb @@ -0,0 +1,150 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class FileSchema + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :entity_id + # @return [String] + attr_reader :file_type + # @return [String] + attr_reader :md_5 + # @return [String] + attr_reader :mimetype + # @return [String] + attr_reader :name + # @return [String] + attr_reader :region + # @return [String] + attr_reader :s_3_bucket + # @return [String] + attr_reader :s_3_file_path + # @return [Integer] + attr_reader :size + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param entity_id [String] + # @param file_type [String] + # @param md_5 [String] + # @param mimetype [String] + # @param name [String] + # @param region [String] + # @param s_3_bucket [String] + # @param s_3_file_path [String] + # @param size [Integer] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FileSchema] + def initialize(id:, created_at:, updated_at:, entity_id: OMIT, file_type:, md_5:, mimetype:, name:, region:, s_3_bucket:, s_3_file_path:, size:, url:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @entity_id = entity_id if entity_id != OMIT + @file_type = file_type + @md_5 = md_5 + @mimetype = mimetype + @name = name + @region = region + @s_3_bucket = s_3_bucket + @s_3_file_path = s_3_file_path + @size = size + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "entity_id": entity_id, "file_type": file_type, "md5": md_5, "mimetype": mimetype, "name": name, "region": region, "s3_bucket": s_3_bucket, "s3_file_path": s_3_file_path, "size": size, "url": url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FileSchema + # + # @param json_object [String] + # @return [Monite::FileSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + entity_id = parsed_json["entity_id"] + file_type = parsed_json["file_type"] + md_5 = parsed_json["md5"] + mimetype = parsed_json["mimetype"] + name = parsed_json["name"] + region = parsed_json["region"] + s_3_bucket = parsed_json["s3_bucket"] + s_3_file_path = parsed_json["s3_file_path"] + size = parsed_json["size"] + url = parsed_json["url"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + entity_id: entity_id, + file_type: file_type, + md_5: md_5, + mimetype: mimetype, + name: name, + region: region, + s_3_bucket: s_3_bucket, + s_3_file_path: s_3_file_path, + size: size, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of FileSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.entity_id&.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.file_type.is_a?(String) != false || raise("Passed value for field obj.file_type is not the expected type, validation failed.") + obj.md_5.is_a?(String) != false || raise("Passed value for field obj.md_5 is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.region.is_a?(String) != false || raise("Passed value for field obj.region is not the expected type, validation failed.") + obj.s_3_bucket.is_a?(String) != false || raise("Passed value for field obj.s_3_bucket is not the expected type, validation failed.") + obj.s_3_file_path.is_a?(String) != false || raise("Passed value for field obj.s_3_file_path is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/file_schema_2.rb b/lib/monite/types/file_schema_2.rb new file mode 100644 index 0000000..851fc96 --- /dev/null +++ b/lib/monite/types/file_schema_2.rb @@ -0,0 +1,148 @@ +# frozen_string_literal: true +require "date" +require_relative "preview_schema_2" +require_relative "page_schema_2" +require "ostruct" +require "json" + +module Monite +# Represents a file (such as a PDF invoice) that was uploaded to Monite. + class FileSchema2 + # @return [String] A unique ID of this file. + attr_reader :id + # @return [DateTime] UTC date and time when this file was uploaded to Monite. Timestamps follow the +# [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + attr_reader :created_at + # @return [String] The type of the business object associated with this file. + attr_reader :file_type + # @return [String] The original file name (if available). + attr_reader :name + # @return [String] Geographical region of the data center where the file is stored. + attr_reader :region + # @return [String] The MD5 hash of the file. + attr_reader :md_5 + # @return [String] The file's [media +# type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). + attr_reader :mimetype + # @return [String] The URL to download the file. + attr_reader :url + # @return [Integer] The file size in bytes. + attr_reader :size + # @return [Array] Preview images generated for this file. There can be multiple images with +# different sizes. + attr_reader :previews + # @return [Array] If the file is a PDF document, this property contains individual pages extracted +# from the file. Otherwise, an empty array. + attr_reader :pages + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of this file. + # @param created_at [DateTime] UTC date and time when this file was uploaded to Monite. Timestamps follow the +# [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param file_type [String] The type of the business object associated with this file. + # @param name [String] The original file name (if available). + # @param region [String] Geographical region of the data center where the file is stored. + # @param md_5 [String] The MD5 hash of the file. + # @param mimetype [String] The file's [media +# type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). + # @param url [String] The URL to download the file. + # @param size [Integer] The file size in bytes. + # @param previews [Array] Preview images generated for this file. There can be multiple images with +# different sizes. + # @param pages [Array] If the file is a PDF document, this property contains individual pages extracted +# from the file. Otherwise, an empty array. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FileSchema2] + def initialize(id:, created_at:, file_type:, name:, region:, md_5:, mimetype:, url:, size:, previews: OMIT, pages: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @file_type = file_type + @name = name + @region = region + @md_5 = md_5 + @mimetype = mimetype + @url = url + @size = size + @previews = previews if previews != OMIT + @pages = pages if pages != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "file_type": file_type, "name": name, "region": region, "md5": md_5, "mimetype": mimetype, "url": url, "size": size, "previews": previews, "pages": pages }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FileSchema2 + # + # @param json_object [String] + # @return [Monite::FileSchema2] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + file_type = parsed_json["file_type"] + name = parsed_json["name"] + region = parsed_json["region"] + md_5 = parsed_json["md5"] + mimetype = parsed_json["mimetype"] + url = parsed_json["url"] + size = parsed_json["size"] + previews = parsed_json["previews"]&.map do | item | + item = item.to_json + Monite::PreviewSchema2.from_json(json_object: item) +end + pages = parsed_json["pages"]&.map do | item | + item = item.to_json + Monite::PageSchema2.from_json(json_object: item) +end + new( + id: id, + created_at: created_at, + file_type: file_type, + name: name, + region: region, + md_5: md_5, + mimetype: mimetype, + url: url, + size: size, + previews: previews, + pages: pages, + additional_properties: struct + ) + end +# Serialize an instance of FileSchema2 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.file_type.is_a?(String) != false || raise("Passed value for field obj.file_type is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.region.is_a?(String) != false || raise("Passed value for field obj.region is not the expected type, validation failed.") + obj.md_5.is_a?(String) != false || raise("Passed value for field obj.md_5 is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.previews&.is_a?(Array) != false || raise("Passed value for field obj.previews is not the expected type, validation failed.") + obj.pages&.is_a?(Array) != false || raise("Passed value for field obj.pages is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/file_schema_3.rb b/lib/monite/types/file_schema_3.rb new file mode 100644 index 0000000..ee217a6 --- /dev/null +++ b/lib/monite/types/file_schema_3.rb @@ -0,0 +1,148 @@ +# frozen_string_literal: true +require "date" +require_relative "page_schema" +require_relative "preview_schema" +require "ostruct" +require "json" + +module Monite +# Represents a file (such as a PDF invoice) that was uploaded to Monite. + class FileSchema3 + # @return [String] A unique ID of this file. + attr_reader :id + # @return [DateTime] UTC date and time when this file was uploaded to Monite. Timestamps follow the +# [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + attr_reader :created_at + # @return [String] The type of the business object associated with this file. + attr_reader :file_type + # @return [String] The MD5 hash of the file. + attr_reader :md_5 + # @return [String] The file's [media +# type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). + attr_reader :mimetype + # @return [String] The original file name (if available). + attr_reader :name + # @return [Array] If the file is a PDF document, this property contains individual pages extracted +# from the file. Otherwise, an empty array. + attr_reader :pages + # @return [Array] Preview images generated for this file. There can be multiple images with +# different sizes. + attr_reader :previews + # @return [String] Geographical region of the data center where the file is stored. + attr_reader :region + # @return [Integer] The file size in bytes. + attr_reader :size + # @return [String] The URL to download the file. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of this file. + # @param created_at [DateTime] UTC date and time when this file was uploaded to Monite. Timestamps follow the +# [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param file_type [String] The type of the business object associated with this file. + # @param md_5 [String] The MD5 hash of the file. + # @param mimetype [String] The file's [media +# type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). + # @param name [String] The original file name (if available). + # @param pages [Array] If the file is a PDF document, this property contains individual pages extracted +# from the file. Otherwise, an empty array. + # @param previews [Array] Preview images generated for this file. There can be multiple images with +# different sizes. + # @param region [String] Geographical region of the data center where the file is stored. + # @param size [Integer] The file size in bytes. + # @param url [String] The URL to download the file. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FileSchema3] + def initialize(id:, created_at:, file_type:, md_5:, mimetype:, name:, pages: OMIT, previews: OMIT, region:, size:, url:, additional_properties: nil) + @id = id + @created_at = created_at + @file_type = file_type + @md_5 = md_5 + @mimetype = mimetype + @name = name + @pages = pages if pages != OMIT + @previews = previews if previews != OMIT + @region = region + @size = size + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "file_type": file_type, "md5": md_5, "mimetype": mimetype, "name": name, "pages": pages, "previews": previews, "region": region, "size": size, "url": url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FileSchema3 + # + # @param json_object [String] + # @return [Monite::FileSchema3] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + file_type = parsed_json["file_type"] + md_5 = parsed_json["md5"] + mimetype = parsed_json["mimetype"] + name = parsed_json["name"] + pages = parsed_json["pages"]&.map do | item | + item = item.to_json + Monite::PageSchema.from_json(json_object: item) +end + previews = parsed_json["previews"]&.map do | item | + item = item.to_json + Monite::PreviewSchema.from_json(json_object: item) +end + region = parsed_json["region"] + size = parsed_json["size"] + url = parsed_json["url"] + new( + id: id, + created_at: created_at, + file_type: file_type, + md_5: md_5, + mimetype: mimetype, + name: name, + pages: pages, + previews: previews, + region: region, + size: size, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of FileSchema3 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.file_type.is_a?(String) != false || raise("Passed value for field obj.file_type is not the expected type, validation failed.") + obj.md_5.is_a?(String) != false || raise("Passed value for field obj.md_5 is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.pages&.is_a?(Array) != false || raise("Passed value for field obj.pages is not the expected type, validation failed.") + obj.previews&.is_a?(Array) != false || raise("Passed value for field obj.previews is not the expected type, validation failed.") + obj.region.is_a?(String) != false || raise("Passed value for field obj.region is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/file_schema_4.rb b/lib/monite/types/file_schema_4.rb new file mode 100644 index 0000000..3a1b957 --- /dev/null +++ b/lib/monite/types/file_schema_4.rb @@ -0,0 +1,148 @@ +# frozen_string_literal: true +require "date" +require_relative "page_schema_3" +require_relative "preview_schema_3" +require "ostruct" +require "json" + +module Monite +# Represents a file (such as a PDF invoice) that was uploaded to Monite. + class FileSchema4 + # @return [String] A unique ID of this file. + attr_reader :id + # @return [DateTime] UTC date and time when this file was uploaded to Monite. Timestamps follow the +# [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + attr_reader :created_at + # @return [String] The type of the business object associated with this file. + attr_reader :file_type + # @return [String] The MD5 hash of the file. + attr_reader :md_5 + # @return [String] The file's [media +# type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). + attr_reader :mimetype + # @return [String] The original file name (if available). + attr_reader :name + # @return [Array] If the file is a PDF document, this property contains individual pages extracted +# from the file. Otherwise, an empty array. + attr_reader :pages + # @return [Array] Preview images generated for this file. There can be multiple images with +# different sizes. + attr_reader :previews + # @return [String] Geographical region of the data center where the file is stored. + attr_reader :region + # @return [Integer] The file size in bytes. + attr_reader :size + # @return [String] The URL to download the file. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of this file. + # @param created_at [DateTime] UTC date and time when this file was uploaded to Monite. Timestamps follow the +# [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param file_type [String] The type of the business object associated with this file. + # @param md_5 [String] The MD5 hash of the file. + # @param mimetype [String] The file's [media +# type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types). + # @param name [String] The original file name (if available). + # @param pages [Array] If the file is a PDF document, this property contains individual pages extracted +# from the file. Otherwise, an empty array. + # @param previews [Array] Preview images generated for this file. There can be multiple images with +# different sizes. + # @param region [String] Geographical region of the data center where the file is stored. + # @param size [Integer] The file size in bytes. + # @param url [String] The URL to download the file. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FileSchema4] + def initialize(id:, created_at:, file_type:, md_5:, mimetype:, name:, pages: OMIT, previews: OMIT, region:, size:, url:, additional_properties: nil) + @id = id + @created_at = created_at + @file_type = file_type + @md_5 = md_5 + @mimetype = mimetype + @name = name + @pages = pages if pages != OMIT + @previews = previews if previews != OMIT + @region = region + @size = size + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "file_type": file_type, "md5": md_5, "mimetype": mimetype, "name": name, "pages": pages, "previews": previews, "region": region, "size": size, "url": url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FileSchema4 + # + # @param json_object [String] + # @return [Monite::FileSchema4] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + file_type = parsed_json["file_type"] + md_5 = parsed_json["md5"] + mimetype = parsed_json["mimetype"] + name = parsed_json["name"] + pages = parsed_json["pages"]&.map do | item | + item = item.to_json + Monite::PageSchema3.from_json(json_object: item) +end + previews = parsed_json["previews"]&.map do | item | + item = item.to_json + Monite::PreviewSchema3.from_json(json_object: item) +end + region = parsed_json["region"] + size = parsed_json["size"] + url = parsed_json["url"] + new( + id: id, + created_at: created_at, + file_type: file_type, + md_5: md_5, + mimetype: mimetype, + name: name, + pages: pages, + previews: previews, + region: region, + size: size, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of FileSchema4 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.file_type.is_a?(String) != false || raise("Passed value for field obj.file_type is not the expected type, validation failed.") + obj.md_5.is_a?(String) != false || raise("Passed value for field obj.md_5 is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.pages&.is_a?(Array) != false || raise("Passed value for field obj.pages is not the expected type, validation failed.") + obj.previews&.is_a?(Array) != false || raise("Passed value for field obj.previews is not the expected type, validation failed.") + obj.region.is_a?(String) != false || raise("Passed value for field obj.region is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/files_response.rb b/lib/monite/types/files_response.rb new file mode 100644 index 0000000..5cb9fb6 --- /dev/null +++ b/lib/monite/types/files_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "file_response" +require "ostruct" +require "json" + +module Monite + class FilesResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FilesResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of FilesResponse + # + # @param json_object [String] + # @return [Monite::FilesResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::FileResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of FilesResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_invoice.rb b/lib/monite/types/financing_invoice.rb new file mode 100644 index 0000000..248918c --- /dev/null +++ b/lib/monite/types/financing_invoice.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true +require_relative "financing_invoice_type" +require_relative "wc_invoice_status" +require_relative "currency_enum" +require_relative "repayment_schedule" +require "ostruct" +require "json" + +module Monite + class FinancingInvoice + # @return [Monite::FinancingInvoiceType] The type of the invoice i.e. receivable or payable. + attr_reader :type + # @return [Monite::WcInvoiceStatus] Status of the invoice. + attr_reader :status + # @return [String] Monite invoice ID. + attr_reader :invoice_id + # @return [String] Monite document ID. + attr_reader :document_id + # @return [String] Monite invoice due date. + attr_reader :due_date + # @return [String] Monite invoice issue date. + attr_reader :issue_date + # @return [Integer] Total amount of the invoice in minor units. + attr_reader :total_amount + # @return [Monite::CurrencyEnum] Currency code. + attr_reader :currency + # @return [String] Description of the invoice. + attr_reader :description + # @return [String] Payer type. BUSINESS or INDIVIDUAL + attr_reader :payer_type + # @return [String] Payer business name. Only applicable for BUSINESS payer type. + attr_reader :payer_business_name + # @return [String] Payer first name. Only applicable for INDIVIDUAL payer type. + attr_reader :payer_first_name + # @return [String] Payer last name. Only applicable for INDIVIDUAL payer type. + attr_reader :payer_last_name + # @return [Monite::RepaymentSchedule] Repayment schedule of the invoice. + attr_reader :repayment_schedule + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param type [Monite::FinancingInvoiceType] The type of the invoice i.e. receivable or payable. + # @param status [Monite::WcInvoiceStatus] Status of the invoice. + # @param invoice_id [String] Monite invoice ID. + # @param document_id [String] Monite document ID. + # @param due_date [String] Monite invoice due date. + # @param issue_date [String] Monite invoice issue date. + # @param total_amount [Integer] Total amount of the invoice in minor units. + # @param currency [Monite::CurrencyEnum] Currency code. + # @param description [String] Description of the invoice. + # @param payer_type [String] Payer type. BUSINESS or INDIVIDUAL + # @param payer_business_name [String] Payer business name. Only applicable for BUSINESS payer type. + # @param payer_first_name [String] Payer first name. Only applicable for INDIVIDUAL payer type. + # @param payer_last_name [String] Payer last name. Only applicable for INDIVIDUAL payer type. + # @param repayment_schedule [Monite::RepaymentSchedule] Repayment schedule of the invoice. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingInvoice] + def initialize(type:, status:, invoice_id:, document_id:, due_date:, issue_date:, total_amount:, currency:, description: OMIT, payer_type:, payer_business_name: OMIT, payer_first_name: OMIT, payer_last_name: OMIT, repayment_schedule: OMIT, additional_properties: nil) + @type = type + @status = status + @invoice_id = invoice_id + @document_id = document_id + @due_date = due_date + @issue_date = issue_date + @total_amount = total_amount + @currency = currency + @description = description if description != OMIT + @payer_type = payer_type + @payer_business_name = payer_business_name if payer_business_name != OMIT + @payer_first_name = payer_first_name if payer_first_name != OMIT + @payer_last_name = payer_last_name if payer_last_name != OMIT + @repayment_schedule = repayment_schedule if repayment_schedule != OMIT + @additional_properties = additional_properties + @_field_set = { "type": type, "status": status, "invoice_id": invoice_id, "document_id": document_id, "due_date": due_date, "issue_date": issue_date, "total_amount": total_amount, "currency": currency, "description": description, "payer_type": payer_type, "payer_business_name": payer_business_name, "payer_first_name": payer_first_name, "payer_last_name": payer_last_name, "repayment_schedule": repayment_schedule }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FinancingInvoice + # + # @param json_object [String] + # @return [Monite::FinancingInvoice] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + type = parsed_json["type"] + status = parsed_json["status"] + invoice_id = parsed_json["invoice_id"] + document_id = parsed_json["document_id"] + due_date = parsed_json["due_date"] + issue_date = parsed_json["issue_date"] + total_amount = parsed_json["total_amount"] + currency = parsed_json["currency"] + description = parsed_json["description"] + payer_type = parsed_json["payer_type"] + payer_business_name = parsed_json["payer_business_name"] + payer_first_name = parsed_json["payer_first_name"] + payer_last_name = parsed_json["payer_last_name"] + unless parsed_json["repayment_schedule"].nil? + repayment_schedule = parsed_json["repayment_schedule"].to_json + repayment_schedule = Monite::RepaymentSchedule.from_json(json_object: repayment_schedule) + else + repayment_schedule = nil + end + new( + type: type, + status: status, + invoice_id: invoice_id, + document_id: document_id, + due_date: due_date, + issue_date: issue_date, + total_amount: total_amount, + currency: currency, + description: description, + payer_type: payer_type, + payer_business_name: payer_business_name, + payer_first_name: payer_first_name, + payer_last_name: payer_last_name, + repayment_schedule: repayment_schedule, + additional_properties: struct + ) + end +# Serialize an instance of FinancingInvoice to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.type.is_a?(Monite::FinancingInvoiceType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.status.is_a?(Monite::WcInvoiceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.invoice_id.is_a?(String) != false || raise("Passed value for field obj.invoice_id is not the expected type, validation failed.") + obj.document_id.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.due_date.is_a?(String) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.") + obj.issue_date.is_a?(String) != false || raise("Passed value for field obj.issue_date is not the expected type, validation failed.") + obj.total_amount.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.payer_type.is_a?(String) != false || raise("Passed value for field obj.payer_type is not the expected type, validation failed.") + obj.payer_business_name&.is_a?(String) != false || raise("Passed value for field obj.payer_business_name is not the expected type, validation failed.") + obj.payer_first_name&.is_a?(String) != false || raise("Passed value for field obj.payer_first_name is not the expected type, validation failed.") + obj.payer_last_name&.is_a?(String) != false || raise("Passed value for field obj.payer_last_name is not the expected type, validation failed.") + obj.repayment_schedule.nil? || Monite::RepaymentSchedule.validate_raw(obj: obj.repayment_schedule) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_invoice_cursor_fields.rb b/lib/monite/types/financing_invoice_cursor_fields.rb new file mode 100644 index 0000000..f3a6930 --- /dev/null +++ b/lib/monite/types/financing_invoice_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class FinancingInvoiceCursorFields + + ID = "id" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_invoice_list_response.rb b/lib/monite/types/financing_invoice_list_response.rb new file mode 100644 index 0000000..0346854 --- /dev/null +++ b/lib/monite/types/financing_invoice_list_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "financing_invoice" +require "ostruct" +require "json" + +module Monite + class FinancingInvoiceListResponse + # @return [Array] A list of invoices requested for financing. + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A list of invoices requested for financing. + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingInvoiceListResponse] + def initialize(data:, prev_pagination_token: OMIT, next_pagination_token: OMIT, additional_properties: nil) + @data = data + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "prev_pagination_token": prev_pagination_token, "next_pagination_token": next_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FinancingInvoiceListResponse + # + # @param json_object [String] + # @return [Monite::FinancingInvoiceListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::FinancingInvoice.from_json(json_object: item) +end + prev_pagination_token = parsed_json["prev_pagination_token"] + next_pagination_token = parsed_json["next_pagination_token"] + new( + data: data, + prev_pagination_token: prev_pagination_token, + next_pagination_token: next_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of FinancingInvoiceListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_invoice_type.rb b/lib/monite/types/financing_invoice_type.rb new file mode 100644 index 0000000..9bd0577 --- /dev/null +++ b/lib/monite/types/financing_invoice_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class FinancingInvoiceType + + PAYABLE = "payable" + RECEIVABLE = "receivable" + + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_offer.rb b/lib/monite/types/financing_offer.rb new file mode 100644 index 0000000..108ac53 --- /dev/null +++ b/lib/monite/types/financing_offer.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true +require_relative "wc_offer_status" +require_relative "currency_enum" +require_relative "pricing_plan" +require "ostruct" +require "json" + +module Monite + class FinancingOffer + # @return [Monite::WcOfferStatus] The status of the financing offer. + attr_reader :status + # @return [Integer] The total credit limit in minor units. + attr_reader :total_amount + # @return [Integer] The available credit limit in minor units. + attr_reader :available_amount + # @return [Monite::CurrencyEnum] The currency code. + attr_reader :currency + # @return [Array] A list of pricing plans for the offer. + attr_reader :pricing_plans + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param status [Monite::WcOfferStatus] The status of the financing offer. + # @param total_amount [Integer] The total credit limit in minor units. + # @param available_amount [Integer] The available credit limit in minor units. + # @param currency [Monite::CurrencyEnum] The currency code. + # @param pricing_plans [Array] A list of pricing plans for the offer. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingOffer] + def initialize(status:, total_amount:, available_amount: OMIT, currency:, pricing_plans:, additional_properties: nil) + @status = status + @total_amount = total_amount + @available_amount = available_amount if available_amount != OMIT + @currency = currency + @pricing_plans = pricing_plans + @additional_properties = additional_properties + @_field_set = { "status": status, "total_amount": total_amount, "available_amount": available_amount, "currency": currency, "pricing_plans": pricing_plans }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of FinancingOffer + # + # @param json_object [String] + # @return [Monite::FinancingOffer] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + status = parsed_json["status"] + total_amount = parsed_json["total_amount"] + available_amount = parsed_json["available_amount"] + currency = parsed_json["currency"] + pricing_plans = parsed_json["pricing_plans"]&.map do | item | + item = item.to_json + Monite::PricingPlan.from_json(json_object: item) +end + new( + status: status, + total_amount: total_amount, + available_amount: available_amount, + currency: currency, + pricing_plans: pricing_plans, + additional_properties: struct + ) + end +# Serialize an instance of FinancingOffer to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.status.is_a?(Monite::WcOfferStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.total_amount.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.available_amount&.is_a?(Integer) != false || raise("Passed value for field obj.available_amount is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.pricing_plans.is_a?(Array) != false || raise("Passed value for field obj.pricing_plans is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_offers_response.rb b/lib/monite/types/financing_offers_response.rb new file mode 100644 index 0000000..0df9eb2 --- /dev/null +++ b/lib/monite/types/financing_offers_response.rb @@ -0,0 +1,66 @@ +# frozen_string_literal: true +require_relative "financing_offer" +require_relative "wc_business_status" +require "ostruct" +require "json" + +module Monite + class FinancingOffersResponse + # @return [Array] A list of financing offers extended to the business. + attr_reader :offers + # @return [Monite::WcBusinessStatus] The business's onboarding status. + attr_reader :business_status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param offers [Array] A list of financing offers extended to the business. + # @param business_status [Monite::WcBusinessStatus] The business's onboarding status. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingOffersResponse] + def initialize(offers:, business_status:, additional_properties: nil) + @offers = offers + @business_status = business_status + @additional_properties = additional_properties + @_field_set = { "offers": offers, "business_status": business_status } + end +# Deserialize a JSON object to an instance of FinancingOffersResponse + # + # @param json_object [String] + # @return [Monite::FinancingOffersResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + offers = parsed_json["offers"]&.map do | item | + item = item.to_json + Monite::FinancingOffer.from_json(json_object: item) +end + business_status = parsed_json["business_status"] + new( + offers: offers, + business_status: business_status, + additional_properties: struct + ) + end +# Serialize an instance of FinancingOffersResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.offers.is_a?(Array) != false || raise("Passed value for field obj.offers is not the expected type, validation failed.") + obj.business_status.is_a?(Monite::WcBusinessStatus) != false || raise("Passed value for field obj.business_status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_push_invoices_request_invoice.rb b/lib/monite/types/financing_push_invoices_request_invoice.rb new file mode 100644 index 0000000..86098cb --- /dev/null +++ b/lib/monite/types/financing_push_invoices_request_invoice.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "financing_invoice_type" +require "ostruct" +require "json" + +module Monite + class FinancingPushInvoicesRequestInvoice + # @return [String] The invoice ID. + attr_reader :id + # @return [Monite::FinancingInvoiceType] The invoice type. + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] The invoice ID. + # @param type [Monite::FinancingInvoiceType] The invoice type. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingPushInvoicesRequestInvoice] + def initialize(id:, type:, additional_properties: nil) + @id = id + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "type": type } + end +# Deserialize a JSON object to an instance of FinancingPushInvoicesRequestInvoice + # + # @param json_object [String] + # @return [Monite::FinancingPushInvoicesRequestInvoice] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + type = parsed_json["type"] + new( + id: id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of FinancingPushInvoicesRequestInvoice to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.type.is_a?(Monite::FinancingInvoiceType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_push_invoices_response.rb b/lib/monite/types/financing_push_invoices_response.rb new file mode 100644 index 0000000..20d83e1 --- /dev/null +++ b/lib/monite/types/financing_push_invoices_response.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class FinancingPushInvoicesResponse + # @return [String] A connect token for Kanmon SDK. + attr_reader :connect_token + # @return [String] An embedded session token for Kanmon SDK. + attr_reader :session_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param connect_token [String] A connect token for Kanmon SDK. + # @param session_token [String] An embedded session token for Kanmon SDK. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingPushInvoicesResponse] + def initialize(connect_token:, session_token:, additional_properties: nil) + @connect_token = connect_token + @session_token = session_token + @additional_properties = additional_properties + @_field_set = { "connect_token": connect_token, "session_token": session_token } + end +# Deserialize a JSON object to an instance of FinancingPushInvoicesResponse + # + # @param json_object [String] + # @return [Monite::FinancingPushInvoicesResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + connect_token = parsed_json["connect_token"] + session_token = parsed_json["session_token"] + new( + connect_token: connect_token, + session_token: session_token, + additional_properties: struct + ) + end +# Serialize an instance of FinancingPushInvoicesResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.connect_token.is_a?(String) != false || raise("Passed value for field obj.connect_token is not the expected type, validation failed.") + obj.session_token.is_a?(String) != false || raise("Passed value for field obj.session_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/financing_token_response.rb b/lib/monite/types/financing_token_response.rb new file mode 100644 index 0000000..8a9dcb4 --- /dev/null +++ b/lib/monite/types/financing_token_response.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class FinancingTokenResponse + # @return [String] A connect token for Kanmon SDK. + attr_reader :connect_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param connect_token [String] A connect token for Kanmon SDK. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::FinancingTokenResponse] + def initialize(connect_token:, additional_properties: nil) + @connect_token = connect_token + @additional_properties = additional_properties + @_field_set = { "connect_token": connect_token } + end +# Deserialize a JSON object to an instance of FinancingTokenResponse + # + # @param json_object [String] + # @return [Monite::FinancingTokenResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + connect_token = parsed_json["connect_token"] + new(connect_token: connect_token, additional_properties: struct) + end +# Serialize an instance of FinancingTokenResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.connect_token.is_a?(String) != false || raise("Passed value for field obj.connect_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/get_all_payment_reminders.rb b/lib/monite/types/get_all_payment_reminders.rb new file mode 100644 index 0000000..f78973b --- /dev/null +++ b/lib/monite/types/get_all_payment_reminders.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "payment_reminder_response" +require "ostruct" +require "json" + +module Monite + class GetAllPaymentReminders + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::GetAllPaymentReminders] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of GetAllPaymentReminders + # + # @param json_object [String] + # @return [Monite::GetAllPaymentReminders] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PaymentReminderResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of GetAllPaymentReminders to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/get_all_recurrences.rb b/lib/monite/types/get_all_recurrences.rb new file mode 100644 index 0000000..6c7159e --- /dev/null +++ b/lib/monite/types/get_all_recurrences.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "recurrence" +require "ostruct" +require "json" + +module Monite + class GetAllRecurrences + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::GetAllRecurrences] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of GetAllRecurrences + # + # @param json_object [String] + # @return [Monite::GetAllRecurrences] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::Recurrence.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of GetAllRecurrences to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/get_onboarding_requirements_response.rb b/lib/monite/types/get_onboarding_requirements_response.rb new file mode 100644 index 0000000..3303061 --- /dev/null +++ b/lib/monite/types/get_onboarding_requirements_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "single_onboarding_requirements_response" +require "ostruct" +require "json" + +module Monite + class GetOnboardingRequirementsResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::GetOnboardingRequirementsResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of GetOnboardingRequirementsResponse + # + # @param json_object [String] + # @return [Monite::GetOnboardingRequirementsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::SingleOnboardingRequirementsResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of GetOnboardingRequirementsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/grant_type.rb b/lib/monite/types/grant_type.rb new file mode 100644 index 0000000..30e09f4 --- /dev/null +++ b/lib/monite/types/grant_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class GrantType + + CLIENT_CREDENTIALS = "client_credentials" + ENTITY_USER = "entity_user" + + end +end \ No newline at end of file diff --git a/lib/monite/types/http_validation_error.rb b/lib/monite/types/http_validation_error.rb new file mode 100644 index 0000000..7fb4e7f --- /dev/null +++ b/lib/monite/types/http_validation_error.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "validation_error" +require "ostruct" +require "json" + +module Monite + class HttpValidationError + # @return [Array] + attr_reader :detail + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param detail [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::HttpValidationError] + def initialize(detail: OMIT, additional_properties: nil) + @detail = detail if detail != OMIT + @additional_properties = additional_properties + @_field_set = { "detail": detail }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of HttpValidationError + # + # @param json_object [String] + # @return [Monite::HttpValidationError] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + detail = parsed_json["detail"]&.map do | item | + item = item.to_json + Monite::ValidationError.from_json(json_object: item) +end + new(detail: detail, additional_properties: struct) + end +# Serialize an instance of HttpValidationError to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.detail&.is_a?(Array) != false || raise("Passed value for field obj.detail is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/individual_response_schema.rb b/lib/monite/types/individual_response_schema.rb new file mode 100644 index 0000000..d15b2ec --- /dev/null +++ b/lib/monite/types/individual_response_schema.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Contains data specific to entities of the `individual` type. + class IndividualResponseSchema + # @return [String] + attr_reader :date_of_birth + # @return [String] A first name of an individual + attr_reader :first_name + # @return [String] + attr_reader :id_number + # @return [String] A last name of an individual + attr_reader :last_name + # @return [String] The last four digits of the individual's Social Security number + attr_reader :ssn_last_4 + # @return [String] A title of an individual + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date_of_birth [String] + # @param first_name [String] A first name of an individual + # @param id_number [String] + # @param last_name [String] A last name of an individual + # @param ssn_last_4 [String] The last four digits of the individual's Social Security number + # @param title [String] A title of an individual + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::IndividualResponseSchema] + def initialize(date_of_birth: OMIT, first_name:, id_number: OMIT, last_name:, ssn_last_4: OMIT, title: OMIT, additional_properties: nil) + @date_of_birth = date_of_birth if date_of_birth != OMIT + @first_name = first_name + @id_number = id_number if id_number != OMIT + @last_name = last_name + @ssn_last_4 = ssn_last_4 if ssn_last_4 != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "date_of_birth": date_of_birth, "first_name": first_name, "id_number": id_number, "last_name": last_name, "ssn_last_4": ssn_last_4, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of IndividualResponseSchema + # + # @param json_object [String] + # @return [Monite::IndividualResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date_of_birth = parsed_json["date_of_birth"] + first_name = parsed_json["first_name"] + id_number = parsed_json["id_number"] + last_name = parsed_json["last_name"] + ssn_last_4 = parsed_json["ssn_last_4"] + title = parsed_json["title"] + new( + date_of_birth: date_of_birth, + first_name: first_name, + id_number: id_number, + last_name: last_name, + ssn_last_4: ssn_last_4, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of IndividualResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date_of_birth&.is_a?(String) != false || raise("Passed value for field obj.date_of_birth is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.id_number&.is_a?(String) != false || raise("Passed value for field obj.id_number is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.ssn_last_4&.is_a?(String) != false || raise("Passed value for field obj.ssn_last_4 is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/individual_schema.rb b/lib/monite/types/individual_schema.rb new file mode 100644 index 0000000..941dd79 --- /dev/null +++ b/lib/monite/types/individual_schema.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema contains metadata for an individual + class IndividualSchema + # @return [String] + attr_reader :date_of_birth + # @return [String] A first name of an individual + attr_reader :first_name + # @return [String] + attr_reader :id_number + # @return [String] A last name of an individual + attr_reader :last_name + # @return [String] The last four digits of the individual's Social Security number + attr_reader :ssn_last_4 + # @return [String] A title of an individual + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date_of_birth [String] + # @param first_name [String] A first name of an individual + # @param id_number [String] + # @param last_name [String] A last name of an individual + # @param ssn_last_4 [String] The last four digits of the individual's Social Security number + # @param title [String] A title of an individual + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::IndividualSchema] + def initialize(date_of_birth: OMIT, first_name:, id_number: OMIT, last_name:, ssn_last_4: OMIT, title: OMIT, additional_properties: nil) + @date_of_birth = date_of_birth if date_of_birth != OMIT + @first_name = first_name + @id_number = id_number if id_number != OMIT + @last_name = last_name + @ssn_last_4 = ssn_last_4 if ssn_last_4 != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "date_of_birth": date_of_birth, "first_name": first_name, "id_number": id_number, "last_name": last_name, "ssn_last_4": ssn_last_4, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of IndividualSchema + # + # @param json_object [String] + # @return [Monite::IndividualSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date_of_birth = parsed_json["date_of_birth"] + first_name = parsed_json["first_name"] + id_number = parsed_json["id_number"] + last_name = parsed_json["last_name"] + ssn_last_4 = parsed_json["ssn_last_4"] + title = parsed_json["title"] + new( + date_of_birth: date_of_birth, + first_name: first_name, + id_number: id_number, + last_name: last_name, + ssn_last_4: ssn_last_4, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of IndividualSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date_of_birth&.is_a?(String) != false || raise("Passed value for field obj.date_of_birth is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.id_number&.is_a?(String) != false || raise("Passed value for field obj.id_number is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.ssn_last_4&.is_a?(String) != false || raise("Passed value for field obj.ssn_last_4 is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/invoice.rb b/lib/monite/types/invoice.rb new file mode 100644 index 0000000..60dc372 --- /dev/null +++ b/lib/monite/types/invoice.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "invoice_file" +require "ostruct" +require "json" + +module Monite + class Invoice + # @return [String] + attr_reader :due_date + # @return [Monite::InvoiceFile] + attr_reader :file + # @return [String] + attr_reader :issue_date + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param due_date [String] + # @param file [Monite::InvoiceFile] + # @param issue_date [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Invoice] + def initialize(due_date: OMIT, file: OMIT, issue_date: OMIT, additional_properties: nil) + @due_date = due_date if due_date != OMIT + @file = file if file != OMIT + @issue_date = issue_date if issue_date != OMIT + @additional_properties = additional_properties + @_field_set = { "due_date": due_date, "file": file, "issue_date": issue_date }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of Invoice + # + # @param json_object [String] + # @return [Monite::Invoice] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + due_date = parsed_json["due_date"] + unless parsed_json["file"].nil? + file = parsed_json["file"].to_json + file = Monite::InvoiceFile.from_json(json_object: file) + else + file = nil + end + issue_date = parsed_json["issue_date"] + new( + due_date: due_date, + file: file, + issue_date: issue_date, + additional_properties: struct + ) + end +# Serialize an instance of Invoice to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.due_date&.is_a?(String) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.") + obj.file.nil? || Monite::InvoiceFile.validate_raw(obj: obj.file) + obj.issue_date&.is_a?(String) != false || raise("Passed value for field obj.issue_date is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/invoice_file.rb b/lib/monite/types/invoice_file.rb new file mode 100644 index 0000000..5647065 --- /dev/null +++ b/lib/monite/types/invoice_file.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class InvoiceFile + # @return [String] + attr_reader :mimetype + # @return [String] + attr_reader :name + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param mimetype [String] + # @param name [String] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::InvoiceFile] + def initialize(mimetype:, name:, url:, additional_properties: nil) + @mimetype = mimetype + @name = name + @url = url + @additional_properties = additional_properties + @_field_set = { "mimetype": mimetype, "name": name, "url": url } + end +# Deserialize a JSON object to an instance of InvoiceFile + # + # @param json_object [String] + # @return [Monite::InvoiceFile] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + mimetype = parsed_json["mimetype"] + name = parsed_json["name"] + url = parsed_json["url"] + new( + mimetype: mimetype, + name: name, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of InvoiceFile to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/invoice_response_payload.rb b/lib/monite/types/invoice_response_payload.rb new file mode 100644 index 0000000..2157c9a --- /dev/null +++ b/lib/monite/types/invoice_response_payload.rb @@ -0,0 +1,641 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "receivables_representation_of_counterpart_address" +require_relative "receivable_counterpart_contact" +require_relative "receivable_counterpart_type" +require_relative "receivable_counterpart_vat_id_response" +require_relative "currency_enum" +require_relative "discount" +require_relative "invoice_response_payload_entity" +require_relative "receivable_entity_address_schema" +require_relative "receivables_representation_of_entity_bank_account" +require_relative "receivable_entity_vat_id_response" +require_relative "language_code_enum" +require "date" +require_relative "response_item" +require "date" +require_relative "payment_terms" +require_relative "related_documents" +require_relative "receivables_status_enum" +require_relative "tag_read_schema" +require_relative "total_vat_amount_item" +require_relative "vat_mode_enum" +require "ostruct" +require "json" + +module Monite + class InvoiceResponsePayload + # @return [String] + attr_reader :id + # @return [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + attr_reader :updated_at + # @return [Integer] How much is left to be paid in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Equal 0 if +# the Invoice is fully paid. + attr_reader :amount_due + # @return [Integer] How much has been paid [minor +# units](https://docs.monite.com/references/currencies#minor-units) + attr_reader :amount_paid + # @return [Integer] How much is left to be paid in in [minor +# units](https://docs.monite.com/references/currencies#minor-units), including +# payment_term discounts. + attr_reader :amount_to_pay + # @return [String] The unique ID of a previous document related to the receivable if applicable. + attr_reader :based_on + # @return [String] The unique document ID of a previous document related to the receivable if +# applicable. + attr_reader :based_on_document_id + # @return [String] Field with a comment for pay/partially/uncollectible info on this Invoice + attr_reader :comment + # @return [String] The commercial terms of the receivable (e.g. The products must be delivered in X +# days). + attr_reader :commercial_condition_description + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address + # @return [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + attr_reader :counterpart_business_type + # @return [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + attr_reader :counterpart_contact + # @return [String] Unique ID of the counterpart. + attr_reader :counterpart_id + # @return [String] A legal name of a counterpart it is an organization or first and last name if it +# is an individual + attr_reader :counterpart_name + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address + # @return [String] The VAT/TAX ID of the counterpart. + attr_reader :counterpart_tax_id + # @return [Monite::ReceivableCounterpartType] The type of the counterpart. + attr_reader :counterpart_type + # @return [Monite::ReceivableCounterpartVatIdResponse] + attr_reader :counterpart_vat_id + # @return [Monite::CurrencyEnum] The currency used in the receivable. + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [Integer] Total price of the receivable with discounts before taxes [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :discounted_subtotal + # @return [String] The sequential code systematically assigned to invoices. + attr_reader :document_id + # @return [String] Optional field representing date until which invoice should be paid + attr_reader :due_date + # @return [Monite::InvoiceResponsePayloadEntity] + attr_reader :entity + # @return [Monite::ReceivableEntityAddressSchema] + attr_reader :entity_address + # @return [Monite::ReceivablesRepresentationOfEntityBankAccount] + attr_reader :entity_bank_account + # @return [String] The entity user who created this document. + attr_reader :entity_user_id + # @return [Monite::ReceivableEntityVatIdResponse] + attr_reader :entity_vat_id + # @return [Monite::LanguageCodeEnum] The language of the customer-facing PDF file (`file_url`). The value matches the +# counterpart's `language` at the time when this PDF file was generated. + attr_reader :file_language + # @return [String] The receivable's PDF URL in the counterpart's default language. + attr_reader :file_url + # @return [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. +# If omitted or `null`, defaults to the invoice issue date and the value is +# automatically set when the invoice is moved to the `issued` status. + attr_reader :fulfillment_date + # @return [DateTime] Optional field for the issue of the entry. + attr_reader :issue_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable. + attr_reader :memo + # @return [Monite::LanguageCodeEnum] The language of the entity's copy of the PDF file (`original_file_url`). The +# value matches the entity's `language` at the time when this PDF file was +# generated. + attr_reader :original_file_language + # @return [String] The receivable's PDF URL in the entity's default language. + attr_reader :original_file_url + # @return [String] + attr_reader :overdue_reminder_id + # @return [DateTime] Date and time when the invoice was paid. + attr_reader :paid_at + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] Link to the invoice's payment page. Either Monite's payment links or your custom +# payment links. + attr_reader :payment_page_url + # @return [String] + attr_reader :payment_reminder_id + # @return [Monite::PaymentTerms] + attr_reader :payment_terms + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [String] Contain purchase order number. + attr_reader :purchase_order + # @return [String] Stores an unique ID of a recurrence if the receivable is in a recurring status + attr_reader :recurrence_id + # @return [Monite::RelatedDocuments] Ids of documents that relate to invoice. I.e credit notes, proforma invoices, +# etc. + attr_reader :related_documents + # @return [Monite::ReceivablesStatusEnum] The status of the receivable inside the receivable workflow. + attr_reader :status + # @return [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :subtotal + # @return [Array] The list of tags for this receivable. + attr_reader :tags + # @return [Integer] Total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Calculated as +# a subtotal + total_vat_amount. + attr_reader :total_amount + # @return [Integer] The total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units), including VAT +# and excluding all issued credit notes. + attr_reader :total_amount_with_credit_notes + # @return [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :total_vat_amount + # @return [Array] List of total vat amount for each VAT, presented in receivable + attr_reader :total_vat_amounts + # @return [Integer] Total price of the receivable with tax withheld in minor units + attr_reader :total_withholding_tax + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + attr_reader :vat_mode + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + # @param amount_due [Integer] How much is left to be paid in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Equal 0 if +# the Invoice is fully paid. + # @param amount_paid [Integer] How much has been paid [minor +# units](https://docs.monite.com/references/currencies#minor-units) + # @param amount_to_pay [Integer] How much is left to be paid in in [minor +# units](https://docs.monite.com/references/currencies#minor-units), including +# payment_term discounts. + # @param based_on [String] The unique ID of a previous document related to the receivable if applicable. + # @param based_on_document_id [String] The unique document ID of a previous document related to the receivable if +# applicable. + # @param comment [String] Field with a comment for pay/partially/uncollectible info on this Invoice + # @param commercial_condition_description [String] The commercial terms of the receivable (e.g. The products must be delivered in X +# days). + # @param counterpart_billing_address [Monite::ReceivablesRepresentationOfCounterpartAddress] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_business_type [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + # @param counterpart_contact [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + # @param counterpart_id [String] Unique ID of the counterpart. + # @param counterpart_name [String] A legal name of a counterpart it is an organization or first and last name if it +# is an individual + # @param counterpart_shipping_address [Monite::ReceivablesRepresentationOfCounterpartAddress] Address where goods were shipped / where services were provided. + # @param counterpart_tax_id [String] The VAT/TAX ID of the counterpart. + # @param counterpart_type [Monite::ReceivableCounterpartType] The type of the counterpart. + # @param counterpart_vat_id [Monite::ReceivableCounterpartVatIdResponse] + # @param currency [Monite::CurrencyEnum] The currency used in the receivable. + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param discounted_subtotal [Integer] Total price of the receivable with discounts before taxes [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param document_id [String] The sequential code systematically assigned to invoices. + # @param due_date [String] Optional field representing date until which invoice should be paid + # @param entity [Monite::InvoiceResponsePayloadEntity] + # @param entity_address [Monite::ReceivableEntityAddressSchema] + # @param entity_bank_account [Monite::ReceivablesRepresentationOfEntityBankAccount] + # @param entity_user_id [String] The entity user who created this document. + # @param entity_vat_id [Monite::ReceivableEntityVatIdResponse] + # @param file_language [Monite::LanguageCodeEnum] The language of the customer-facing PDF file (`file_url`). The value matches the +# counterpart's `language` at the time when this PDF file was generated. + # @param file_url [String] The receivable's PDF URL in the counterpart's default language. + # @param fulfillment_date [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. +# If omitted or `null`, defaults to the invoice issue date and the value is +# automatically set when the invoice is moved to the `issued` status. + # @param issue_date [DateTime] Optional field for the issue of the entry. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable. + # @param original_file_language [Monite::LanguageCodeEnum] The language of the entity's copy of the PDF file (`original_file_url`). The +# value matches the entity's `language` at the time when this PDF file was +# generated. + # @param original_file_url [String] The receivable's PDF URL in the entity's default language. + # @param overdue_reminder_id [String] + # @param paid_at [DateTime] Date and time when the invoice was paid. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_page_url [String] Link to the invoice's payment page. Either Monite's payment links or your custom +# payment links. + # @param payment_reminder_id [String] + # @param payment_terms [Monite::PaymentTerms] + # @param project_id [String] A project related to current receivable + # @param purchase_order [String] Contain purchase order number. + # @param recurrence_id [String] Stores an unique ID of a recurrence if the receivable is in a recurring status + # @param related_documents [Monite::RelatedDocuments] Ids of documents that relate to invoice. I.e credit notes, proforma invoices, +# etc. + # @param status [Monite::ReceivablesStatusEnum] The status of the receivable inside the receivable workflow. + # @param subtotal [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param tags [Array] The list of tags for this receivable. + # @param total_amount [Integer] Total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Calculated as +# a subtotal + total_vat_amount. + # @param total_amount_with_credit_notes [Integer] The total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units), including VAT +# and excluding all issued credit notes. + # @param total_vat_amount [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param total_vat_amounts [Array] List of total vat amount for each VAT, presented in receivable + # @param total_withholding_tax [Integer] Total price of the receivable with tax withheld in minor units + # @param trade_name [String] Trade name of the entity + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::InvoiceResponsePayload] + def initialize(id:, created_at:, updated_at:, amount_due:, amount_paid:, amount_to_pay: OMIT, based_on: OMIT, based_on_document_id: OMIT, comment: OMIT, commercial_condition_description: OMIT, counterpart_billing_address: OMIT, counterpart_business_type: OMIT, counterpart_contact: OMIT, counterpart_id:, counterpart_name: OMIT, counterpart_shipping_address: OMIT, counterpart_tax_id: OMIT, counterpart_type:, counterpart_vat_id: OMIT, currency:, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, discounted_subtotal: OMIT, document_id: OMIT, due_date: OMIT, entity:, entity_address:, entity_bank_account: OMIT, entity_user_id: OMIT, entity_vat_id: OMIT, file_language:, file_url: OMIT, fulfillment_date: OMIT, issue_date: OMIT, line_items:, memo: OMIT, original_file_language:, original_file_url: OMIT, overdue_reminder_id: OMIT, paid_at: OMIT, partner_metadata: OMIT, payment_page_url: OMIT, payment_reminder_id: OMIT, payment_terms: OMIT, project_id: OMIT, purchase_order: OMIT, recurrence_id: OMIT, related_documents:, status:, subtotal: OMIT, tags: OMIT, total_amount: OMIT, total_amount_with_credit_notes:, total_vat_amount:, total_vat_amounts: OMIT, total_withholding_tax: OMIT, trade_name: OMIT, vat_exempt: OMIT, vat_exemption_rationale: OMIT, vat_mode: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @amount_due = amount_due + @amount_paid = amount_paid + @amount_to_pay = amount_to_pay if amount_to_pay != OMIT + @based_on = based_on if based_on != OMIT + @based_on_document_id = based_on_document_id if based_on_document_id != OMIT + @comment = comment if comment != OMIT + @commercial_condition_description = commercial_condition_description if commercial_condition_description != OMIT + @counterpart_billing_address = counterpart_billing_address if counterpart_billing_address != OMIT + @counterpart_business_type = counterpart_business_type if counterpart_business_type != OMIT + @counterpart_contact = counterpart_contact if counterpart_contact != OMIT + @counterpart_id = counterpart_id + @counterpart_name = counterpart_name if counterpart_name != OMIT + @counterpart_shipping_address = counterpart_shipping_address if counterpart_shipping_address != OMIT + @counterpart_tax_id = counterpart_tax_id if counterpart_tax_id != OMIT + @counterpart_type = counterpart_type + @counterpart_vat_id = counterpart_vat_id if counterpart_vat_id != OMIT + @currency = currency + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @discounted_subtotal = discounted_subtotal if discounted_subtotal != OMIT + @document_id = document_id if document_id != OMIT + @due_date = due_date if due_date != OMIT + @entity = entity + @entity_address = entity_address + @entity_bank_account = entity_bank_account if entity_bank_account != OMIT + @entity_user_id = entity_user_id if entity_user_id != OMIT + @entity_vat_id = entity_vat_id if entity_vat_id != OMIT + @file_language = file_language + @file_url = file_url if file_url != OMIT + @fulfillment_date = fulfillment_date if fulfillment_date != OMIT + @issue_date = issue_date if issue_date != OMIT + @line_items = line_items + @memo = memo if memo != OMIT + @original_file_language = original_file_language + @original_file_url = original_file_url if original_file_url != OMIT + @overdue_reminder_id = overdue_reminder_id if overdue_reminder_id != OMIT + @paid_at = paid_at if paid_at != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @payment_page_url = payment_page_url if payment_page_url != OMIT + @payment_reminder_id = payment_reminder_id if payment_reminder_id != OMIT + @payment_terms = payment_terms if payment_terms != OMIT + @project_id = project_id if project_id != OMIT + @purchase_order = purchase_order if purchase_order != OMIT + @recurrence_id = recurrence_id if recurrence_id != OMIT + @related_documents = related_documents + @status = status + @subtotal = subtotal if subtotal != OMIT + @tags = tags if tags != OMIT + @total_amount = total_amount if total_amount != OMIT + @total_amount_with_credit_notes = total_amount_with_credit_notes + @total_vat_amount = total_vat_amount + @total_vat_amounts = total_vat_amounts if total_vat_amounts != OMIT + @total_withholding_tax = total_withholding_tax if total_withholding_tax != OMIT + @trade_name = trade_name if trade_name != OMIT + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @vat_mode = vat_mode if vat_mode != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "amount_due": amount_due, "amount_paid": amount_paid, "amount_to_pay": amount_to_pay, "based_on": based_on, "based_on_document_id": based_on_document_id, "comment": comment, "commercial_condition_description": commercial_condition_description, "counterpart_billing_address": counterpart_billing_address, "counterpart_business_type": counterpart_business_type, "counterpart_contact": counterpart_contact, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, "counterpart_shipping_address": counterpart_shipping_address, "counterpart_tax_id": counterpart_tax_id, "counterpart_type": counterpart_type, "counterpart_vat_id": counterpart_vat_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "discounted_subtotal": discounted_subtotal, "document_id": document_id, "due_date": due_date, "entity": entity, "entity_address": entity_address, "entity_bank_account": entity_bank_account, "entity_user_id": entity_user_id, "entity_vat_id": entity_vat_id, "file_language": file_language, "file_url": file_url, "fulfillment_date": fulfillment_date, "issue_date": issue_date, "line_items": line_items, "memo": memo, "original_file_language": original_file_language, "original_file_url": original_file_url, "overdue_reminder_id": overdue_reminder_id, "paid_at": paid_at, "partner_metadata": partner_metadata, "payment_page_url": payment_page_url, "payment_reminder_id": payment_reminder_id, "payment_terms": payment_terms, "project_id": project_id, "purchase_order": purchase_order, "recurrence_id": recurrence_id, "related_documents": related_documents, "status": status, "subtotal": subtotal, "tags": tags, "total_amount": total_amount, "total_amount_with_credit_notes": total_amount_with_credit_notes, "total_vat_amount": total_vat_amount, "total_vat_amounts": total_vat_amounts, "total_withholding_tax": total_withholding_tax, "trade_name": trade_name, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "vat_mode": vat_mode, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of InvoiceResponsePayload + # + # @param json_object [String] + # @return [Monite::InvoiceResponsePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + amount_due = parsed_json["amount_due"] + amount_paid = parsed_json["amount_paid"] + amount_to_pay = parsed_json["amount_to_pay"] + based_on = parsed_json["based_on"] + based_on_document_id = parsed_json["based_on_document_id"] + comment = parsed_json["comment"] + commercial_condition_description = parsed_json["commercial_condition_description"] + unless parsed_json["counterpart_billing_address"].nil? + counterpart_billing_address = parsed_json["counterpart_billing_address"].to_json + counterpart_billing_address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: counterpart_billing_address) + else + counterpart_billing_address = nil + end + counterpart_business_type = parsed_json["counterpart_business_type"] + unless parsed_json["counterpart_contact"].nil? + counterpart_contact = parsed_json["counterpart_contact"].to_json + counterpart_contact = Monite::ReceivableCounterpartContact.from_json(json_object: counterpart_contact) + else + counterpart_contact = nil + end + counterpart_id = parsed_json["counterpart_id"] + counterpart_name = parsed_json["counterpart_name"] + unless parsed_json["counterpart_shipping_address"].nil? + counterpart_shipping_address = parsed_json["counterpart_shipping_address"].to_json + counterpart_shipping_address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: counterpart_shipping_address) + else + counterpart_shipping_address = nil + end + counterpart_tax_id = parsed_json["counterpart_tax_id"] + counterpart_type = parsed_json["counterpart_type"] + unless parsed_json["counterpart_vat_id"].nil? + counterpart_vat_id = parsed_json["counterpart_vat_id"].to_json + counterpart_vat_id = Monite::ReceivableCounterpartVatIdResponse.from_json(json_object: counterpart_vat_id) + else + counterpart_vat_id = nil + end + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + discounted_subtotal = parsed_json["discounted_subtotal"] + document_id = parsed_json["document_id"] + due_date = parsed_json["due_date"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::InvoiceResponsePayloadEntity.from_json(json_object: entity) + else + entity = nil + end + unless parsed_json["entity_address"].nil? + entity_address = parsed_json["entity_address"].to_json + entity_address = Monite::ReceivableEntityAddressSchema.from_json(json_object: entity_address) + else + entity_address = nil + end + unless parsed_json["entity_bank_account"].nil? + entity_bank_account = parsed_json["entity_bank_account"].to_json + entity_bank_account = Monite::ReceivablesRepresentationOfEntityBankAccount.from_json(json_object: entity_bank_account) + else + entity_bank_account = nil + end + entity_user_id = parsed_json["entity_user_id"] + unless parsed_json["entity_vat_id"].nil? + entity_vat_id = parsed_json["entity_vat_id"].to_json + entity_vat_id = Monite::ReceivableEntityVatIdResponse.from_json(json_object: entity_vat_id) + else + entity_vat_id = nil + end + file_language = parsed_json["file_language"] + file_url = parsed_json["file_url"] + fulfillment_date = parsed_json["fulfillment_date"] + issue_date = unless parsed_json["issue_date"].nil? + DateTime.parse(parsed_json["issue_date"]) +else + nil +end + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::ResponseItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + original_file_language = parsed_json["original_file_language"] + original_file_url = parsed_json["original_file_url"] + overdue_reminder_id = parsed_json["overdue_reminder_id"] + paid_at = unless parsed_json["paid_at"].nil? + DateTime.parse(parsed_json["paid_at"]) +else + nil +end + partner_metadata = parsed_json["partner_metadata"] + payment_page_url = parsed_json["payment_page_url"] + payment_reminder_id = parsed_json["payment_reminder_id"] + unless parsed_json["payment_terms"].nil? + payment_terms = parsed_json["payment_terms"].to_json + payment_terms = Monite::PaymentTerms.from_json(json_object: payment_terms) + else + payment_terms = nil + end + project_id = parsed_json["project_id"] + purchase_order = parsed_json["purchase_order"] + recurrence_id = parsed_json["recurrence_id"] + unless parsed_json["related_documents"].nil? + related_documents = parsed_json["related_documents"].to_json + related_documents = Monite::RelatedDocuments.from_json(json_object: related_documents) + else + related_documents = nil + end + status = parsed_json["status"] + subtotal = parsed_json["subtotal"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + total_amount = parsed_json["total_amount"] + total_amount_with_credit_notes = parsed_json["total_amount_with_credit_notes"] + total_vat_amount = parsed_json["total_vat_amount"] + total_vat_amounts = parsed_json["total_vat_amounts"]&.map do | item | + item = item.to_json + Monite::TotalVatAmountItem.from_json(json_object: item) +end + total_withholding_tax = parsed_json["total_withholding_tax"] + trade_name = parsed_json["trade_name"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + vat_mode = parsed_json["vat_mode"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + amount_due: amount_due, + amount_paid: amount_paid, + amount_to_pay: amount_to_pay, + based_on: based_on, + based_on_document_id: based_on_document_id, + comment: comment, + commercial_condition_description: commercial_condition_description, + counterpart_billing_address: counterpart_billing_address, + counterpart_business_type: counterpart_business_type, + counterpart_contact: counterpart_contact, + counterpart_id: counterpart_id, + counterpart_name: counterpart_name, + counterpart_shipping_address: counterpart_shipping_address, + counterpart_tax_id: counterpart_tax_id, + counterpart_type: counterpart_type, + counterpart_vat_id: counterpart_vat_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + discounted_subtotal: discounted_subtotal, + document_id: document_id, + due_date: due_date, + entity: entity, + entity_address: entity_address, + entity_bank_account: entity_bank_account, + entity_user_id: entity_user_id, + entity_vat_id: entity_vat_id, + file_language: file_language, + file_url: file_url, + fulfillment_date: fulfillment_date, + issue_date: issue_date, + line_items: line_items, + memo: memo, + original_file_language: original_file_language, + original_file_url: original_file_url, + overdue_reminder_id: overdue_reminder_id, + paid_at: paid_at, + partner_metadata: partner_metadata, + payment_page_url: payment_page_url, + payment_reminder_id: payment_reminder_id, + payment_terms: payment_terms, + project_id: project_id, + purchase_order: purchase_order, + recurrence_id: recurrence_id, + related_documents: related_documents, + status: status, + subtotal: subtotal, + tags: tags, + total_amount: total_amount, + total_amount_with_credit_notes: total_amount_with_credit_notes, + total_vat_amount: total_vat_amount, + total_vat_amounts: total_vat_amounts, + total_withholding_tax: total_withholding_tax, + trade_name: trade_name, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + vat_mode: vat_mode, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of InvoiceResponsePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.amount_due.is_a?(Integer) != false || raise("Passed value for field obj.amount_due is not the expected type, validation failed.") + obj.amount_paid.is_a?(Integer) != false || raise("Passed value for field obj.amount_paid is not the expected type, validation failed.") + obj.amount_to_pay&.is_a?(Integer) != false || raise("Passed value for field obj.amount_to_pay is not the expected type, validation failed.") + obj.based_on&.is_a?(String) != false || raise("Passed value for field obj.based_on is not the expected type, validation failed.") + obj.based_on_document_id&.is_a?(String) != false || raise("Passed value for field obj.based_on_document_id is not the expected type, validation failed.") + obj.comment&.is_a?(String) != false || raise("Passed value for field obj.comment is not the expected type, validation failed.") + obj.commercial_condition_description&.is_a?(String) != false || raise("Passed value for field obj.commercial_condition_description is not the expected type, validation failed.") + obj.counterpart_billing_address.nil? || Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.counterpart_billing_address) + obj.counterpart_business_type&.is_a?(String) != false || raise("Passed value for field obj.counterpart_business_type is not the expected type, validation failed.") + obj.counterpart_contact.nil? || Monite::ReceivableCounterpartContact.validate_raw(obj: obj.counterpart_contact) + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_name&.is_a?(String) != false || raise("Passed value for field obj.counterpart_name is not the expected type, validation failed.") + obj.counterpart_shipping_address.nil? || Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.counterpart_shipping_address) + obj.counterpart_tax_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_tax_id is not the expected type, validation failed.") + obj.counterpart_type.is_a?(Monite::ReceivableCounterpartType) != false || raise("Passed value for field obj.counterpart_type is not the expected type, validation failed.") + obj.counterpart_vat_id.nil? || Monite::ReceivableCounterpartVatIdResponse.validate_raw(obj: obj.counterpart_vat_id) + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.discounted_subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.discounted_subtotal is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.due_date&.is_a?(String) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.") + Monite::InvoiceResponsePayloadEntity.validate_raw(obj: obj.entity) + Monite::ReceivableEntityAddressSchema.validate_raw(obj: obj.entity_address) + obj.entity_bank_account.nil? || Monite::ReceivablesRepresentationOfEntityBankAccount.validate_raw(obj: obj.entity_bank_account) + obj.entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.entity_user_id is not the expected type, validation failed.") + obj.entity_vat_id.nil? || Monite::ReceivableEntityVatIdResponse.validate_raw(obj: obj.entity_vat_id) + obj.file_language.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.file_language is not the expected type, validation failed.") + obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") + obj.fulfillment_date&.is_a?(String) != false || raise("Passed value for field obj.fulfillment_date is not the expected type, validation failed.") + obj.issue_date&.is_a?(DateTime) != false || raise("Passed value for field obj.issue_date is not the expected type, validation failed.") + obj.line_items.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.original_file_language.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.original_file_language is not the expected type, validation failed.") + obj.original_file_url&.is_a?(String) != false || raise("Passed value for field obj.original_file_url is not the expected type, validation failed.") + obj.overdue_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.overdue_reminder_id is not the expected type, validation failed.") + obj.paid_at&.is_a?(DateTime) != false || raise("Passed value for field obj.paid_at is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.payment_page_url&.is_a?(String) != false || raise("Passed value for field obj.payment_page_url is not the expected type, validation failed.") + obj.payment_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.payment_reminder_id is not the expected type, validation failed.") + obj.payment_terms.nil? || Monite::PaymentTerms.validate_raw(obj: obj.payment_terms) + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.purchase_order&.is_a?(String) != false || raise("Passed value for field obj.purchase_order is not the expected type, validation failed.") + obj.recurrence_id&.is_a?(String) != false || raise("Passed value for field obj.recurrence_id is not the expected type, validation failed.") + Monite::RelatedDocuments.validate_raw(obj: obj.related_documents) + obj.status.is_a?(Monite::ReceivablesStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.total_amount_with_credit_notes.is_a?(Integer) != false || raise("Passed value for field obj.total_amount_with_credit_notes is not the expected type, validation failed.") + obj.total_vat_amount.is_a?(Integer) != false || raise("Passed value for field obj.total_vat_amount is not the expected type, validation failed.") + obj.total_vat_amounts&.is_a?(Array) != false || raise("Passed value for field obj.total_vat_amounts is not the expected type, validation failed.") + obj.total_withholding_tax&.is_a?(Integer) != false || raise("Passed value for field obj.total_withholding_tax is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.vat_mode&.is_a?(Monite::VatModeEnum) != false || raise("Passed value for field obj.vat_mode is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/invoice_response_payload_entity.rb b/lib/monite/types/invoice_response_payload_entity.rb new file mode 100644 index 0000000..6518ad4 --- /dev/null +++ b/lib/monite/types/invoice_response_payload_entity.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "json" +require_relative "receivable_entity_organization" +require_relative "receivable_entity_individual" + +module Monite + class InvoiceResponsePayloadEntity + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::InvoiceResponsePayloadEntity] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of InvoiceResponsePayloadEntity + # + # @param json_object [String] + # @return [Monite::InvoiceResponsePayloadEntity] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "organization" + member = Monite::ReceivableEntityOrganization.from_json(json_object: json_object) + when "individual" + member = Monite::ReceivableEntityIndividual.from_json(json_object: json_object) + else + member = Monite::ReceivableEntityOrganization.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "organization" + { **@member.to_json, type: @discriminant }.to_json + when "individual" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "organization" + Monite::ReceivableEntityOrganization.validate_raw(obj: obj) + when "individual" + Monite::ReceivableEntityIndividual.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::ReceivableEntityOrganization] + # @return [Monite::InvoiceResponsePayloadEntity] + def self.organization(member:) + new(member: member, discriminant: "organization") + end + # @param member [Monite::ReceivableEntityIndividual] + # @return [Monite::InvoiceResponsePayloadEntity] + def self.individual(member:) + new(member: member, discriminant: "individual") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/item.rb b/lib/monite/types/item.rb new file mode 100644 index 0000000..3201238 --- /dev/null +++ b/lib/monite/types/item.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Contains information about a text block or line extracted from an uploaded +# document by OCR. + class Item + # @return [String] The text as recognized by OCR. + attr_reader :text + # @return [Float] OCR confidence score - the estimated accuracy percentage of character +# recognition of the extracted text, from 0 to 100%. + attr_reader :confidence + # @return [Object] + attr_reader :processed_text + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param text [String] The text as recognized by OCR. + # @param confidence [Float] OCR confidence score - the estimated accuracy percentage of character +# recognition of the extracted text, from 0 to 100%. + # @param processed_text [Object] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Item] + def initialize(text:, confidence:, processed_text: OMIT, additional_properties: nil) + @text = text + @confidence = confidence + @processed_text = processed_text if processed_text != OMIT + @additional_properties = additional_properties + @_field_set = { "text": text, "confidence": confidence, "processed_text": processed_text }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of Item + # + # @param json_object [String] + # @return [Monite::Item] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + text = parsed_json["text"] + confidence = parsed_json["confidence"] + processed_text = parsed_json["processed_text"] + new( + text: text, + confidence: confidence, + processed_text: processed_text, + additional_properties: struct + ) + end +# Serialize an instance of Item to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.text.is_a?(String) != false || raise("Passed value for field obj.text is not the expected type, validation failed.") + obj.confidence.is_a?(Float) != false || raise("Passed value for field obj.confidence is not the expected type, validation failed.") + obj.processed_text&.is_a?(Object) != false || raise("Passed value for field obj.processed_text is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/iteration_status.rb b/lib/monite/types/iteration_status.rb new file mode 100644 index 0000000..56fca81 --- /dev/null +++ b/lib/monite/types/iteration_status.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class IterationStatus + + PENDING = "pending" + COMPLETED = "completed" + CANCELED = "canceled" + ISSUE_FAILED = "issue_failed" + SEND_FAILED = "send_failed" + + end +end \ No newline at end of file diff --git a/lib/monite/types/label_n_value.rb b/lib/monite/types/label_n_value.rb new file mode 100644 index 0000000..26e8227 --- /dev/null +++ b/lib/monite/types/label_n_value.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true +require_relative "item" +require "ostruct" +require "json" + +module Monite +# A label-value pair extracted from an uploaded document by OCR. +# For example, the label could be "Total" and the value could be a currency +# amount. + class LabelNValue + # @return [Monite::Item] Text label. + attr_reader :label + # @return [Monite::Item] The value (if any). + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param label [Monite::Item] Text label. + # @param value [Monite::Item] The value (if any). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LabelNValue] + def initialize(label:, value:, additional_properties: nil) + @label = label + @value = value + @additional_properties = additional_properties + @_field_set = { "label": label, "value": value } + end +# Deserialize a JSON object to an instance of LabelNValue + # + # @param json_object [String] + # @return [Monite::LabelNValue] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["label"].nil? + label = parsed_json["label"].to_json + label = Monite::Item.from_json(json_object: label) + else + label = nil + end + unless parsed_json["value"].nil? + value = parsed_json["value"].to_json + value = Monite::Item.from_json(json_object: value) + else + value = nil + end + new( + label: label, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of LabelNValue to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::Item.validate_raw(obj: obj.label) + Monite::Item.validate_raw(obj: obj.value) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/language_code_enum.rb b/lib/monite/types/language_code_enum.rb new file mode 100644 index 0000000..93b44cc --- /dev/null +++ b/lib/monite/types/language_code_enum.rb @@ -0,0 +1,188 @@ +# frozen_string_literal: true + +module Monite + class LanguageCodeEnum + + AB = "ab" + AA = "aa" + AF = "af" + AK = "ak" + SQ = "sq" + AM = "am" + AR = "ar" + AN = "an" + HY = "hy" + AV = "av" + AE = "ae" + AY = "ay" + AZ = "az" + BM = "bm" + BA = "ba" + EU = "eu" + BE = "be" + BN = "bn" + BI = "bi" + BS = "bs" + BR = "br" + BG = "bg" + MY = "my" + CA = "ca" + CH = "ch" + CE = "ce" + NY = "ny" + ZH = "zh" + CU = "cu" + CV = "cv" + KW = "kw" + CO = "co" + CR = "cr" + HR = "hr" + CS = "cs" + DA = "da" + DV = "dv" + NL = "nl" + DZ = "dz" + EN = "en" + EO = "eo" + ET = "et" + EE = "ee" + FO = "fo" + FJ = "fj" + FI = "fi" + FR = "fr" + FY = "fy" + FF = "ff" + GD = "gd" + GL = "gl" + LG = "lg" + KA = "ka" + DE = "de" + EL = "el" + KL = "kl" + GN = "gn" + GU = "gu" + HT = "ht" + HA = "ha" + HE = "he" + HZ = "hz" + HI = "hi" + HO = "ho" + HU = "hu" + IO = "io" + IG = "ig" + ID = "id" + IA = "ia" + IE = "ie" + IU = "iu" + IK = "ik" + GA = "ga" + IT = "it" + JA = "ja" + JV = "jv" + KN = "kn" + KR = "kr" + KS = "ks" + KK = "kk" + KM = "km" + KI = "ki" + RW = "rw" + KY = "ky" + KV = "kv" + KG = "kg" + KO = "ko" + KJ = "kj" + KU = "ku" + LO = "lo" + LA = "la" + LV = "lv" + LI = "li" + LN = "ln" + LT = "lt" + LU = "lu" + LB = "lb" + MK = "mk" + MG = "mg" + MS = "ms" + ML = "ml" + MT = "mt" + GV = "gv" + MI = "mi" + MR = "mr" + MH = "mh" + MN = "mn" + NA = "na" + NV = "nv" + ND = "nd" + NR = "nr" + NG = "ng" + NE = "ne" + NO = "no" + NB = "nb" + NN = "nn" + II = "ii" + OC = "oc" + OJ = "oj" + OM = "om" + OS = "os" + PI = "pi" + PS = "ps" + FA = "fa" + PL = "pl" + PT = "pt" + PA = "pa" + QU = "qu" + RO = "ro" + RM = "rm" + RN = "rn" + RU = "ru" + SE = "se" + SM = "sm" + SG = "sg" + SA = "sa" + SC = "sc" + SR = "sr" + SN = "sn" + SD = "sd" + SI = "si" + SK = "sk" + SL = "sl" + SO = "so" + ST = "st" + ES = "es" + SU = "su" + SW = "sw" + SS = "ss" + SV = "sv" + TL = "tl" + TY = "ty" + TG = "tg" + TA = "ta" + TT = "tt" + TE = "te" + TH = "th" + BO = "bo" + TI = "ti" + TO = "to" + TS = "ts" + TN = "tn" + TR = "tr" + TK = "tk" + TW = "tw" + UG = "ug" + UK = "uk" + UR = "ur" + UZ = "uz" + VE = "ve" + VI = "vi" + VO = "vo" + WA = "wa" + CY = "cy" + WO = "wo" + XH = "xh" + YI = "yi" + YO = "yo" + ZA = "za" + ZU = "zu" + + end +end \ No newline at end of file diff --git a/lib/monite/types/ledger_account_cursor_fields.rb b/lib/monite/types/ledger_account_cursor_fields.rb new file mode 100644 index 0000000..82af9cb --- /dev/null +++ b/lib/monite/types/ledger_account_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + LEDGER_ACCOUNT_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/ledger_account_list_response.rb b/lib/monite/types/ledger_account_list_response.rb new file mode 100644 index 0000000..aa57224 --- /dev/null +++ b/lib/monite/types/ledger_account_list_response.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true +require_relative "ledger_account_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of ledger accounts. + class LedgerAccountListResponse + # @return [Array] + attr_reader :data + # @return [String] + attr_reader :next_pagination_token + # @return [String] + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] + # @param prev_pagination_token [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LedgerAccountListResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LedgerAccountListResponse + # + # @param json_object [String] + # @return [Monite::LedgerAccountListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::LedgerAccountResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of LedgerAccountListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ledger_account_response.rb b/lib/monite/types/ledger_account_response.rb new file mode 100644 index 0000000..0a0c4d2 --- /dev/null +++ b/lib/monite/types/ledger_account_response.rb @@ -0,0 +1,135 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite +# Represents a general ledger account retrieved from an accounting system. + class LedgerAccountResponse + # @return [String] A unique identifier of the ledger account. + attr_reader :id + # @return [Monite::CurrencyEnum] The currency of the ledger account, specified as a three-letter [currency +# code](https://docs.monite.com/references/currencies) (ISO 4217). + attr_reader :currency + # @return [Integer] The current balance in the account. + attr_reader :current_balance + # @return [String] User-defined description of the ledger account. + attr_reader :description + # @return [Boolean] Indicates whether this ledger account represents a bank account. + attr_reader :is_bank_account + # @return [String] A user-defined name of the ledger account. Examples: Accounts Receivable, Office +# Equipment, Advertising, Salaries. + attr_reader :name + # @return [String] The account code in the accounting system. + attr_reader :nominal_code + # @return [String] The status of the ledger account. Possible values: Active, Archived, Pending, +# Unknown. + attr_reader :status + # @return [String] The subtype or category of the ledger account. Possible values vary based on the +# accounting system used. Examples: Current, Fixed, Expense, Inventory, Equity. + attr_reader :subtype + # @return [String] The type of the ledger account. It determines whether the account is a credit +# account or a debit account and where it appears in financial reports within the +# accounting system. Possible values: Asset, Equity, Expense, Income, Liability, +# Unknown. + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique identifier of the ledger account. + # @param currency [Monite::CurrencyEnum] The currency of the ledger account, specified as a three-letter [currency +# code](https://docs.monite.com/references/currencies) (ISO 4217). + # @param current_balance [Integer] The current balance in the account. + # @param description [String] User-defined description of the ledger account. + # @param is_bank_account [Boolean] Indicates whether this ledger account represents a bank account. + # @param name [String] A user-defined name of the ledger account. Examples: Accounts Receivable, Office +# Equipment, Advertising, Salaries. + # @param nominal_code [String] The account code in the accounting system. + # @param status [String] The status of the ledger account. Possible values: Active, Archived, Pending, +# Unknown. + # @param subtype [String] The subtype or category of the ledger account. Possible values vary based on the +# accounting system used. Examples: Current, Fixed, Expense, Inventory, Equity. + # @param type [String] The type of the ledger account. It determines whether the account is a credit +# account or a debit account and where it appears in financial reports within the +# accounting system. Possible values: Asset, Equity, Expense, Income, Liability, +# Unknown. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LedgerAccountResponse] + def initialize(id:, currency: OMIT, current_balance: OMIT, description: OMIT, is_bank_account:, name:, nominal_code: OMIT, status:, subtype: OMIT, type:, additional_properties: nil) + @id = id + @currency = currency if currency != OMIT + @current_balance = current_balance if current_balance != OMIT + @description = description if description != OMIT + @is_bank_account = is_bank_account + @name = name + @nominal_code = nominal_code if nominal_code != OMIT + @status = status + @subtype = subtype if subtype != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "currency": currency, "current_balance": current_balance, "description": description, "is_bank_account": is_bank_account, "name": name, "nominal_code": nominal_code, "status": status, "subtype": subtype, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LedgerAccountResponse + # + # @param json_object [String] + # @return [Monite::LedgerAccountResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + currency = parsed_json["currency"] + current_balance = parsed_json["current_balance"] + description = parsed_json["description"] + is_bank_account = parsed_json["is_bank_account"] + name = parsed_json["name"] + nominal_code = parsed_json["nominal_code"] + status = parsed_json["status"] + subtype = parsed_json["subtype"] + type = parsed_json["type"] + new( + id: id, + currency: currency, + current_balance: current_balance, + description: description, + is_bank_account: is_bank_account, + name: name, + nominal_code: nominal_code, + status: status, + subtype: subtype, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of LedgerAccountResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.current_balance&.is_a?(Integer) != false || raise("Passed value for field obj.current_balance is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.is_bank_account.is_a?(Boolean) != false || raise("Passed value for field obj.is_bank_account is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.nominal_code&.is_a?(String) != false || raise("Passed value for field obj.nominal_code is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtype&.is_a?(String) != false || raise("Passed value for field obj.subtype is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item.rb b/lib/monite/types/line_item.rb new file mode 100644 index 0000000..82e62f9 --- /dev/null +++ b/lib/monite/types/line_item.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true +require_relative "discount" +require_relative "line_item_product_create" +require "ostruct" +require "json" + +module Monite + class LineItem + # @return [Monite::Discount] The discount for a product. + attr_reader :discount + # @return [Monite::LineItemProductCreate] Object of product. Can be used instead of product_id, created in product's +# catalog + attr_reader :product + # @return [String] Unique identifier of the product. + attr_reader :product_id + # @return [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + attr_reader :quantity + # @return [Integer] Percent minor units. Example: 12.5% is 1250. This field is only required on +# invoices issued by entities in the US, Pakistan, and other unsupported +# countries. + attr_reader :tax_rate_value + # @return [String] Unique identifier of the vat rate object. This field is required for all +# entities in supported countries except the US and Pakistan. + attr_reader :vat_rate_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param discount [Monite::Discount] The discount for a product. + # @param product [Monite::LineItemProductCreate] Object of product. Can be used instead of product_id, created in product's +# catalog + # @param product_id [String] Unique identifier of the product. + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + # @param tax_rate_value [Integer] Percent minor units. Example: 12.5% is 1250. This field is only required on +# invoices issued by entities in the US, Pakistan, and other unsupported +# countries. + # @param vat_rate_id [String] Unique identifier of the vat rate object. This field is required for all +# entities in supported countries except the US and Pakistan. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItem] + def initialize(discount: OMIT, product: OMIT, product_id: OMIT, quantity:, tax_rate_value: OMIT, vat_rate_id: OMIT, additional_properties: nil) + @discount = discount if discount != OMIT + @product = product if product != OMIT + @product_id = product_id if product_id != OMIT + @quantity = quantity + @tax_rate_value = tax_rate_value if tax_rate_value != OMIT + @vat_rate_id = vat_rate_id if vat_rate_id != OMIT + @additional_properties = additional_properties + @_field_set = { "discount": discount, "product": product, "product_id": product_id, "quantity": quantity, "tax_rate_value": tax_rate_value, "vat_rate_id": vat_rate_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItem + # + # @param json_object [String] + # @return [Monite::LineItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + unless parsed_json["product"].nil? + product = parsed_json["product"].to_json + product = Monite::LineItemProductCreate.from_json(json_object: product) + else + product = nil + end + product_id = parsed_json["product_id"] + quantity = parsed_json["quantity"] + tax_rate_value = parsed_json["tax_rate_value"] + vat_rate_id = parsed_json["vat_rate_id"] + new( + discount: discount, + product: product, + product_id: product_id, + quantity: quantity, + tax_rate_value: tax_rate_value, + vat_rate_id: vat_rate_id, + additional_properties: struct + ) + end +# Serialize an instance of LineItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.product.nil? || Monite::LineItemProductCreate.validate_raw(obj: obj.product) + obj.product_id&.is_a?(String) != false || raise("Passed value for field obj.product_id is not the expected type, validation failed.") + obj.quantity.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.tax_rate_value&.is_a?(Integer) != false || raise("Passed value for field obj.tax_rate_value is not the expected type, validation failed.") + obj.vat_rate_id&.is_a?(String) != false || raise("Passed value for field obj.vat_rate_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_cursor_fields.rb b/lib/monite/types/line_item_cursor_fields.rb new file mode 100644 index 0000000..0a79d69 --- /dev/null +++ b/lib/monite/types/line_item_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class LineItemCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_internal_request.rb b/lib/monite/types/line_item_internal_request.rb new file mode 100644 index 0000000..3ad723c --- /dev/null +++ b/lib/monite/types/line_item_internal_request.rb @@ -0,0 +1,133 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class LineItemInternalRequest + # @return [String] ID of the tax rate reference used for accounting integration. May be used to +# override auto-picked tax rate reference in accounting platform in case of any +# platform-specific constraints. + attr_reader :accounting_tax_rate_id + # @return [String] Description of the product. + attr_reader :description + # @return [String] ID of the account record used to store bookkeeping entries for balance-sheet and +# income-statement transactions. + attr_reader :ledger_account_id + # @return [String] Name of the product. + attr_reader :name + # @return [Float] The quantity of each of the goods, materials, or services listed in the payable. + attr_reader :quantity + # @return [Integer] + attr_reader :subtotal + # @return [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :tax + # @return [Integer] + attr_reader :total + # @return [String] The unit of the product + attr_reader :unit + # @return [Integer] The unit price of the product, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :unit_price + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param accounting_tax_rate_id [String] ID of the tax rate reference used for accounting integration. May be used to +# override auto-picked tax rate reference in accounting platform in case of any +# platform-specific constraints. + # @param description [String] Description of the product. + # @param ledger_account_id [String] ID of the account record used to store bookkeeping entries for balance-sheet and +# income-statement transactions. + # @param name [String] Name of the product. + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the payable. + # @param subtotal [Integer] + # @param tax [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param total [Integer] + # @param unit [String] The unit of the product + # @param unit_price [Integer] The unit price of the product, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemInternalRequest] + def initialize(accounting_tax_rate_id: OMIT, description: OMIT, ledger_account_id: OMIT, name: OMIT, quantity: OMIT, subtotal: OMIT, tax: OMIT, total: OMIT, unit: OMIT, unit_price: OMIT, additional_properties: nil) + @accounting_tax_rate_id = accounting_tax_rate_id if accounting_tax_rate_id != OMIT + @description = description if description != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @name = name if name != OMIT + @quantity = quantity if quantity != OMIT + @subtotal = subtotal if subtotal != OMIT + @tax = tax if tax != OMIT + @total = total if total != OMIT + @unit = unit if unit != OMIT + @unit_price = unit_price if unit_price != OMIT + @additional_properties = additional_properties + @_field_set = { "accounting_tax_rate_id": accounting_tax_rate_id, "description": description, "ledger_account_id": ledger_account_id, "name": name, "quantity": quantity, "subtotal": subtotal, "tax": tax, "total": total, "unit": unit, "unit_price": unit_price }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemInternalRequest + # + # @param json_object [String] + # @return [Monite::LineItemInternalRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + accounting_tax_rate_id = parsed_json["accounting_tax_rate_id"] + description = parsed_json["description"] + ledger_account_id = parsed_json["ledger_account_id"] + name = parsed_json["name"] + quantity = parsed_json["quantity"] + subtotal = parsed_json["subtotal"] + tax = parsed_json["tax"] + total = parsed_json["total"] + unit = parsed_json["unit"] + unit_price = parsed_json["unit_price"] + new( + accounting_tax_rate_id: accounting_tax_rate_id, + description: description, + ledger_account_id: ledger_account_id, + name: name, + quantity: quantity, + subtotal: subtotal, + tax: tax, + total: total, + unit: unit, + unit_price: unit_price, + additional_properties: struct + ) + end +# Serialize an instance of LineItemInternalRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.accounting_tax_rate_id&.is_a?(String) != false || raise("Passed value for field obj.accounting_tax_rate_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.unit_price&.is_a?(Integer) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_pagination_response.rb b/lib/monite/types/line_item_pagination_response.rb new file mode 100644 index 0000000..9b92f0d --- /dev/null +++ b/lib/monite/types/line_item_pagination_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "line_item_response" +require "ostruct" +require "json" + +module Monite + class LineItemPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemPaginationResponse + # + # @param json_object [String] + # @return [Monite::LineItemPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::LineItemResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of LineItemPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_product.rb b/lib/monite/types/line_item_product.rb new file mode 100644 index 0000000..555544e --- /dev/null +++ b/lib/monite/types/line_item_product.rb @@ -0,0 +1,152 @@ +# frozen_string_literal: true +require_relative "line_item_product_measure_unit" +require_relative "price" +require_relative "product_service_type_enum" +require_relative "line_item_product_vat_rate" +require "ostruct" +require "json" + +module Monite + class LineItemProduct + # @return [String] Unique ID of the product. + attr_reader :id + # @return [String] Description of the product. + attr_reader :description + # @return [Boolean] Indicates whether the product is inline + attr_reader :is_inline + # @return [String] + attr_reader :ledger_account_id + # @return [Monite::LineItemProductMeasureUnit] + attr_reader :measure_unit + # @return [String] Name of the product. + attr_reader :name + # @return [Monite::Price] + attr_reader :price + # @return [Monite::Price] + attr_reader :price_after_vat + # @return [Float] The smallest amount allowed for this product. + attr_reader :smallest_amount + # @return [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + attr_reader :type + # @return [Monite::LineItemProductVatRate] + attr_reader :vat_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the product. + # @param description [String] Description of the product. + # @param is_inline [Boolean] Indicates whether the product is inline + # @param ledger_account_id [String] + # @param measure_unit [Monite::LineItemProductMeasureUnit] + # @param name [String] Name of the product. + # @param price [Monite::Price] + # @param price_after_vat [Monite::Price] + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param vat_rate [Monite::LineItemProductVatRate] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemProduct] + def initialize(id:, description: OMIT, is_inline: OMIT, ledger_account_id: OMIT, measure_unit: OMIT, name:, price:, price_after_vat:, smallest_amount: OMIT, type: OMIT, vat_rate:, additional_properties: nil) + @id = id + @description = description if description != OMIT + @is_inline = is_inline if is_inline != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @measure_unit = measure_unit if measure_unit != OMIT + @name = name + @price = price + @price_after_vat = price_after_vat + @smallest_amount = smallest_amount if smallest_amount != OMIT + @type = type if type != OMIT + @vat_rate = vat_rate + @additional_properties = additional_properties + @_field_set = { "id": id, "description": description, "is_inline": is_inline, "ledger_account_id": ledger_account_id, "measure_unit": measure_unit, "name": name, "price": price, "price_after_vat": price_after_vat, "smallest_amount": smallest_amount, "type": type, "vat_rate": vat_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemProduct + # + # @param json_object [String] + # @return [Monite::LineItemProduct] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + description = parsed_json["description"] + is_inline = parsed_json["is_inline"] + ledger_account_id = parsed_json["ledger_account_id"] + unless parsed_json["measure_unit"].nil? + measure_unit = parsed_json["measure_unit"].to_json + measure_unit = Monite::LineItemProductMeasureUnit.from_json(json_object: measure_unit) + else + measure_unit = nil + end + name = parsed_json["name"] + unless parsed_json["price"].nil? + price = parsed_json["price"].to_json + price = Monite::Price.from_json(json_object: price) + else + price = nil + end + unless parsed_json["price_after_vat"].nil? + price_after_vat = parsed_json["price_after_vat"].to_json + price_after_vat = Monite::Price.from_json(json_object: price_after_vat) + else + price_after_vat = nil + end + smallest_amount = parsed_json["smallest_amount"] + type = parsed_json["type"] + unless parsed_json["vat_rate"].nil? + vat_rate = parsed_json["vat_rate"].to_json + vat_rate = Monite::LineItemProductVatRate.from_json(json_object: vat_rate) + else + vat_rate = nil + end + new( + id: id, + description: description, + is_inline: is_inline, + ledger_account_id: ledger_account_id, + measure_unit: measure_unit, + name: name, + price: price, + price_after_vat: price_after_vat, + smallest_amount: smallest_amount, + type: type, + vat_rate: vat_rate, + additional_properties: struct + ) + end +# Serialize an instance of LineItemProduct to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.is_inline&.is_a?(Boolean) != false || raise("Passed value for field obj.is_inline is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.measure_unit.nil? || Monite::LineItemProductMeasureUnit.validate_raw(obj: obj.measure_unit) + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + Monite::Price.validate_raw(obj: obj.price) + Monite::Price.validate_raw(obj: obj.price_after_vat) + obj.smallest_amount&.is_a?(Float) != false || raise("Passed value for field obj.smallest_amount is not the expected type, validation failed.") + obj.type&.is_a?(Monite::ProductServiceTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + Monite::LineItemProductVatRate.validate_raw(obj: obj.vat_rate) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_product_create.rb b/lib/monite/types/line_item_product_create.rb new file mode 100644 index 0000000..d9f0695 --- /dev/null +++ b/lib/monite/types/line_item_product_create.rb @@ -0,0 +1,113 @@ +# frozen_string_literal: true +require_relative "unit_request" +require_relative "price" +require_relative "product_service_type_enum" +require "ostruct" +require "json" + +module Monite + class LineItemProductCreate + # @return [String] Description of the product. + attr_reader :description + # @return [String] + attr_reader :ledger_account_id + # @return [Monite::UnitRequest] + attr_reader :measure_unit + # @return [String] Name of the product. + attr_reader :name + # @return [Monite::Price] + attr_reader :price + # @return [Float] The smallest amount allowed for this product. + attr_reader :smallest_amount + # @return [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] Description of the product. + # @param ledger_account_id [String] + # @param measure_unit [Monite::UnitRequest] + # @param name [String] Name of the product. + # @param price [Monite::Price] + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemProductCreate] + def initialize(description: OMIT, ledger_account_id: OMIT, measure_unit: OMIT, name:, price:, smallest_amount: OMIT, type: OMIT, additional_properties: nil) + @description = description if description != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @measure_unit = measure_unit if measure_unit != OMIT + @name = name + @price = price + @smallest_amount = smallest_amount if smallest_amount != OMIT + @type = type if type != OMIT + @additional_properties = additional_properties + @_field_set = { "description": description, "ledger_account_id": ledger_account_id, "measure_unit": measure_unit, "name": name, "price": price, "smallest_amount": smallest_amount, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemProductCreate + # + # @param json_object [String] + # @return [Monite::LineItemProductCreate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + ledger_account_id = parsed_json["ledger_account_id"] + unless parsed_json["measure_unit"].nil? + measure_unit = parsed_json["measure_unit"].to_json + measure_unit = Monite::UnitRequest.from_json(json_object: measure_unit) + else + measure_unit = nil + end + name = parsed_json["name"] + unless parsed_json["price"].nil? + price = parsed_json["price"].to_json + price = Monite::Price.from_json(json_object: price) + else + price = nil + end + smallest_amount = parsed_json["smallest_amount"] + type = parsed_json["type"] + new( + description: description, + ledger_account_id: ledger_account_id, + measure_unit: measure_unit, + name: name, + price: price, + smallest_amount: smallest_amount, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of LineItemProductCreate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.measure_unit.nil? || Monite::UnitRequest.validate_raw(obj: obj.measure_unit) + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + Monite::Price.validate_raw(obj: obj.price) + obj.smallest_amount&.is_a?(Float) != false || raise("Passed value for field obj.smallest_amount is not the expected type, validation failed.") + obj.type&.is_a?(Monite::ProductServiceTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_product_measure_unit.rb b/lib/monite/types/line_item_product_measure_unit.rb new file mode 100644 index 0000000..b60b709 --- /dev/null +++ b/lib/monite/types/line_item_product_measure_unit.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class LineItemProductMeasureUnit + # @return [String] + attr_reader :id + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param description [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemProductMeasureUnit] + def initialize(id: OMIT, description: OMIT, name:, additional_properties: nil) + @id = id if id != OMIT + @description = description if description != OMIT + @name = name + @additional_properties = additional_properties + @_field_set = { "id": id, "description": description, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemProductMeasureUnit + # + # @param json_object [String] + # @return [Monite::LineItemProductMeasureUnit] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + description = parsed_json["description"] + name = parsed_json["name"] + new( + id: id, + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of LineItemProductMeasureUnit to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_product_vat_rate.rb b/lib/monite/types/line_item_product_vat_rate.rb new file mode 100644 index 0000000..118e49b --- /dev/null +++ b/lib/monite/types/line_item_product_vat_rate.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class LineItemProductVatRate + # @return [String] Unique identifier of the vat rate object. + attr_reader :id + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [Integer] Percent minor units. Example: 12.5% is 1250. + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique identifier of the vat rate object. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param value [Integer] Percent minor units. Example: 12.5% is 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemProductVatRate] + def initialize(id: OMIT, country:, value:, additional_properties: nil) + @id = id if id != OMIT + @country = country + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "country": country, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemProductVatRate + # + # @param json_object [String] + # @return [Monite::LineItemProductVatRate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + country = parsed_json["country"] + value = parsed_json["value"] + new( + id: id, + country: country, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of LineItemProductVatRate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.value.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_request.rb b/lib/monite/types/line_item_request.rb new file mode 100644 index 0000000..d175c07 --- /dev/null +++ b/lib/monite/types/line_item_request.rb @@ -0,0 +1,119 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class LineItemRequest + # @return [String] ID of the tax rate reference used for accounting integration. May be used to +# override auto-picked tax rate reference in accounting platform in case of any +# platform-specific constraints. + attr_reader :accounting_tax_rate_id + # @return [String] Description of the product. + attr_reader :description + # @return [String] ID of the account record used to store bookkeeping entries for balance-sheet and +# income-statement transactions. + attr_reader :ledger_account_id + # @return [String] Name of the product. + attr_reader :name + # @return [Float] The quantity of each of the goods, materials, or services listed in the payable. + attr_reader :quantity + # @return [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :tax + # @return [String] The unit of the product + attr_reader :unit + # @return [Integer] The unit price of the product, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :unit_price + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param accounting_tax_rate_id [String] ID of the tax rate reference used for accounting integration. May be used to +# override auto-picked tax rate reference in accounting platform in case of any +# platform-specific constraints. + # @param description [String] Description of the product. + # @param ledger_account_id [String] ID of the account record used to store bookkeeping entries for balance-sheet and +# income-statement transactions. + # @param name [String] Name of the product. + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the payable. + # @param tax [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param unit [String] The unit of the product + # @param unit_price [Integer] The unit price of the product, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemRequest] + def initialize(accounting_tax_rate_id: OMIT, description: OMIT, ledger_account_id: OMIT, name: OMIT, quantity: OMIT, tax: OMIT, unit: OMIT, unit_price: OMIT, additional_properties: nil) + @accounting_tax_rate_id = accounting_tax_rate_id if accounting_tax_rate_id != OMIT + @description = description if description != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @name = name if name != OMIT + @quantity = quantity if quantity != OMIT + @tax = tax if tax != OMIT + @unit = unit if unit != OMIT + @unit_price = unit_price if unit_price != OMIT + @additional_properties = additional_properties + @_field_set = { "accounting_tax_rate_id": accounting_tax_rate_id, "description": description, "ledger_account_id": ledger_account_id, "name": name, "quantity": quantity, "tax": tax, "unit": unit, "unit_price": unit_price }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemRequest + # + # @param json_object [String] + # @return [Monite::LineItemRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + accounting_tax_rate_id = parsed_json["accounting_tax_rate_id"] + description = parsed_json["description"] + ledger_account_id = parsed_json["ledger_account_id"] + name = parsed_json["name"] + quantity = parsed_json["quantity"] + tax = parsed_json["tax"] + unit = parsed_json["unit"] + unit_price = parsed_json["unit_price"] + new( + accounting_tax_rate_id: accounting_tax_rate_id, + description: description, + ledger_account_id: ledger_account_id, + name: name, + quantity: quantity, + tax: tax, + unit: unit, + unit_price: unit_price, + additional_properties: struct + ) + end +# Serialize an instance of LineItemRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.accounting_tax_rate_id&.is_a?(String) != false || raise("Passed value for field obj.accounting_tax_rate_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.unit_price&.is_a?(Integer) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_response.rb b/lib/monite/types/line_item_response.rb new file mode 100644 index 0000000..7e56514 --- /dev/null +++ b/lib/monite/types/line_item_response.rb @@ -0,0 +1,167 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class LineItemResponse + # @return [String] + attr_reader :id + # @return [String] ID of the tax rate reference used for accounting integartion. May be used to +# override auto-picked tax rate reference in accounting platform in case of any +# platform-specific constraints. + attr_reader :accounting_tax_rate_id + # @return [String] Description of the product. + attr_reader :description + # @return [String] ID of the account record used to store bookkeeping entries for balance-sheet and +# income-statement transactions. + attr_reader :ledger_account_id + # @return [String] Name of the product. + attr_reader :name + # @return [String] + attr_reader :payable_id + # @return [Float] The quantity of each of the goods, materials, or services listed in the payable. + attr_reader :quantity + # @return [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :subtotal + # @return [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :tax + # @return [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :tax_amount + # @return [Integer] The actual price of the product. + attr_reader :total + # @return [String] The unit of the product + attr_reader :unit + # @return [Integer] The unit price of the product, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :unit_price + # @return [String] ID of the user who created the tag. + attr_reader :was_created_by_user_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param accounting_tax_rate_id [String] ID of the tax rate reference used for accounting integartion. May be used to +# override auto-picked tax rate reference in accounting platform in case of any +# platform-specific constraints. + # @param description [String] Description of the product. + # @param ledger_account_id [String] ID of the account record used to store bookkeeping entries for balance-sheet and +# income-statement transactions. + # @param name [String] Name of the product. + # @param payable_id [String] + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the payable. + # @param subtotal [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param tax [Integer] VAT rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param tax_amount [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total [Integer] The actual price of the product. + # @param unit [String] The unit of the product + # @param unit_price [Integer] The unit price of the product, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param was_created_by_user_id [String] ID of the user who created the tag. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemResponse] + def initialize(id:, accounting_tax_rate_id: OMIT, description: OMIT, ledger_account_id: OMIT, name: OMIT, payable_id:, quantity: OMIT, subtotal: OMIT, tax: OMIT, tax_amount: OMIT, total: OMIT, unit: OMIT, unit_price: OMIT, was_created_by_user_id: OMIT, additional_properties: nil) + @id = id + @accounting_tax_rate_id = accounting_tax_rate_id if accounting_tax_rate_id != OMIT + @description = description if description != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @name = name if name != OMIT + @payable_id = payable_id + @quantity = quantity if quantity != OMIT + @subtotal = subtotal if subtotal != OMIT + @tax = tax if tax != OMIT + @tax_amount = tax_amount if tax_amount != OMIT + @total = total if total != OMIT + @unit = unit if unit != OMIT + @unit_price = unit_price if unit_price != OMIT + @was_created_by_user_id = was_created_by_user_id if was_created_by_user_id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "accounting_tax_rate_id": accounting_tax_rate_id, "description": description, "ledger_account_id": ledger_account_id, "name": name, "payable_id": payable_id, "quantity": quantity, "subtotal": subtotal, "tax": tax, "tax_amount": tax_amount, "total": total, "unit": unit, "unit_price": unit_price, "was_created_by_user_id": was_created_by_user_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemResponse + # + # @param json_object [String] + # @return [Monite::LineItemResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + accounting_tax_rate_id = parsed_json["accounting_tax_rate_id"] + description = parsed_json["description"] + ledger_account_id = parsed_json["ledger_account_id"] + name = parsed_json["name"] + payable_id = parsed_json["payable_id"] + quantity = parsed_json["quantity"] + subtotal = parsed_json["subtotal"] + tax = parsed_json["tax"] + tax_amount = parsed_json["tax_amount"] + total = parsed_json["total"] + unit = parsed_json["unit"] + unit_price = parsed_json["unit_price"] + was_created_by_user_id = parsed_json["was_created_by_user_id"] + new( + id: id, + accounting_tax_rate_id: accounting_tax_rate_id, + description: description, + ledger_account_id: ledger_account_id, + name: name, + payable_id: payable_id, + quantity: quantity, + subtotal: subtotal, + tax: tax, + tax_amount: tax_amount, + total: total, + unit: unit, + unit_price: unit_price, + was_created_by_user_id: was_created_by_user_id, + additional_properties: struct + ) + end +# Serialize an instance of LineItemResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.accounting_tax_rate_id&.is_a?(String) != false || raise("Passed value for field obj.accounting_tax_rate_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.payable_id.is_a?(String) != false || raise("Passed value for field obj.payable_id is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.tax_amount&.is_a?(Integer) != false || raise("Passed value for field obj.tax_amount is not the expected type, validation failed.") + obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.unit_price&.is_a?(Integer) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + obj.was_created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.was_created_by_user_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_item_update.rb b/lib/monite/types/line_item_update.rb new file mode 100644 index 0000000..1fb4d32 --- /dev/null +++ b/lib/monite/types/line_item_update.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +require_relative "discount" +require "ostruct" +require "json" + +module Monite + class LineItemUpdate + # @return [Monite::Discount] The discount for a product. + attr_reader :discount + # @return [Integer] The actual price of the product in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :price + # @return [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + attr_reader :quantity + # @return [Integer] Percent minor units. Example: 12.5% is 1250. This field is only required on +# invoices issued by entities in the US, Pakistan, and other unsupported +# countries. + attr_reader :tax_rate_value + # @return [String] Unique identifier of the vat rate object. This field is required for all +# entities in supported countries except the US and Pakistan. + attr_reader :vat_rate_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param discount [Monite::Discount] The discount for a product. + # @param price [Integer] The actual price of the product in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + # @param tax_rate_value [Integer] Percent minor units. Example: 12.5% is 1250. This field is only required on +# invoices issued by entities in the US, Pakistan, and other unsupported +# countries. + # @param vat_rate_id [String] Unique identifier of the vat rate object. This field is required for all +# entities in supported countries except the US and Pakistan. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemUpdate] + def initialize(discount: OMIT, price: OMIT, quantity: OMIT, tax_rate_value: OMIT, vat_rate_id: OMIT, additional_properties: nil) + @discount = discount if discount != OMIT + @price = price if price != OMIT + @quantity = quantity if quantity != OMIT + @tax_rate_value = tax_rate_value if tax_rate_value != OMIT + @vat_rate_id = vat_rate_id if vat_rate_id != OMIT + @additional_properties = additional_properties + @_field_set = { "discount": discount, "price": price, "quantity": quantity, "tax_rate_value": tax_rate_value, "vat_rate_id": vat_rate_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of LineItemUpdate + # + # @param json_object [String] + # @return [Monite::LineItemUpdate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + price = parsed_json["price"] + quantity = parsed_json["quantity"] + tax_rate_value = parsed_json["tax_rate_value"] + vat_rate_id = parsed_json["vat_rate_id"] + new( + discount: discount, + price: price, + quantity: quantity, + tax_rate_value: tax_rate_value, + vat_rate_id: vat_rate_id, + additional_properties: struct + ) + end +# Serialize an instance of LineItemUpdate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.price&.is_a?(Integer) != false || raise("Passed value for field obj.price is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.tax_rate_value&.is_a?(Integer) != false || raise("Passed value for field obj.tax_rate_value is not the expected type, validation failed.") + obj.vat_rate_id&.is_a?(String) != false || raise("Passed value for field obj.vat_rate_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_items_replace_response.rb b/lib/monite/types/line_items_replace_response.rb new file mode 100644 index 0000000..ddd8b6b --- /dev/null +++ b/lib/monite/types/line_items_replace_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "line_item_response" +require "ostruct" +require "json" + +module Monite + class LineItemsReplaceResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemsReplaceResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of LineItemsReplaceResponse + # + # @param json_object [String] + # @return [Monite::LineItemsReplaceResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::LineItemResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of LineItemsReplaceResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/line_items_response.rb b/lib/monite/types/line_items_response.rb new file mode 100644 index 0000000..d13c3bc --- /dev/null +++ b/lib/monite/types/line_items_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "response_item" +require "ostruct" +require "json" + +module Monite + class LineItemsResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::LineItemsResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of LineItemsResponse + # + # @param json_object [String] + # @return [Monite::LineItemsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ResponseItem.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of LineItemsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/mail_sent_event_data.rb b/lib/monite/types/mail_sent_event_data.rb new file mode 100644 index 0000000..d6436d3 --- /dev/null +++ b/lib/monite/types/mail_sent_event_data.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true +require_relative "receivable_mail_status_enum" +require_relative "receivable_mail_recipients" +require "ostruct" +require "json" + +module Monite +# Contains information about a sent email. + class MailSentEventData + # @return [String] ID of the email sending operation. Can be used to get the email sending status +# from `GET /receivables/{receivable_id}/mails/{mail_id}`. + attr_reader :mail_id + # @return [Monite::ReceivableMailStatusEnum] The overall email sending status across all recipients. + attr_reader :mail_status + # @return [Monite::ReceivableMailRecipients] Contains a list of email recipients (To, CC, BCC) and the email sending status +# for each recipient. + attr_reader :recipients + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param mail_id [String] ID of the email sending operation. Can be used to get the email sending status +# from `GET /receivables/{receivable_id}/mails/{mail_id}`. + # @param mail_status [Monite::ReceivableMailStatusEnum] The overall email sending status across all recipients. + # @param recipients [Monite::ReceivableMailRecipients] Contains a list of email recipients (To, CC, BCC) and the email sending status +# for each recipient. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MailSentEventData] + def initialize(mail_id:, mail_status:, recipients:, additional_properties: nil) + @mail_id = mail_id + @mail_status = mail_status + @recipients = recipients + @additional_properties = additional_properties + @_field_set = { "mail_id": mail_id, "mail_status": mail_status, "recipients": recipients } + end +# Deserialize a JSON object to an instance of MailSentEventData + # + # @param json_object [String] + # @return [Monite::MailSentEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + mail_id = parsed_json["mail_id"] + mail_status = parsed_json["mail_status"] + unless parsed_json["recipients"].nil? + recipients = parsed_json["recipients"].to_json + recipients = Monite::ReceivableMailRecipients.from_json(json_object: recipients) + else + recipients = nil + end + new( + mail_id: mail_id, + mail_status: mail_status, + recipients: recipients, + additional_properties: struct + ) + end +# Serialize an instance of MailSentEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mail_id.is_a?(String) != false || raise("Passed value for field obj.mail_id is not the expected type, validation failed.") + obj.mail_status.is_a?(Monite::ReceivableMailStatusEnum) != false || raise("Passed value for field obj.mail_status is not the expected type, validation failed.") + Monite::ReceivableMailRecipients.validate_raw(obj: obj.recipients) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/mail_settings.rb b/lib/monite/types/mail_settings.rb new file mode 100644 index 0000000..9727821 --- /dev/null +++ b/lib/monite/types/mail_settings.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class MailSettings + # @return [Boolean] + attr_reader :attach_documents_as_pdf + # @return [String] + attr_reader :from_email_username + # @return [String] + attr_reader :from_name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param attach_documents_as_pdf [Boolean] + # @param from_email_username [String] + # @param from_name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MailSettings] + def initialize(attach_documents_as_pdf:, from_email_username: OMIT, from_name: OMIT, additional_properties: nil) + @attach_documents_as_pdf = attach_documents_as_pdf + @from_email_username = from_email_username if from_email_username != OMIT + @from_name = from_name if from_name != OMIT + @additional_properties = additional_properties + @_field_set = { "attach_documents_as_pdf": attach_documents_as_pdf, "from_email_username": from_email_username, "from_name": from_name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of MailSettings + # + # @param json_object [String] + # @return [Monite::MailSettings] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + attach_documents_as_pdf = parsed_json["attach_documents_as_pdf"] + from_email_username = parsed_json["from_email_username"] + from_name = parsed_json["from_name"] + new( + attach_documents_as_pdf: attach_documents_as_pdf, + from_email_username: from_email_username, + from_name: from_name, + additional_properties: struct + ) + end +# Serialize an instance of MailSettings to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.attach_documents_as_pdf.is_a?(Boolean) != false || raise("Passed value for field obj.attach_documents_as_pdf is not the expected type, validation failed.") + obj.from_email_username&.is_a?(String) != false || raise("Passed value for field obj.from_email_username is not the expected type, validation failed.") + obj.from_name&.is_a?(String) != false || raise("Passed value for field obj.from_name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/mailbox_data_response.rb b/lib/monite/types/mailbox_data_response.rb new file mode 100644 index 0000000..37fb283 --- /dev/null +++ b/lib/monite/types/mailbox_data_response.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "mailbox_response" +require "ostruct" +require "json" + +module Monite + class MailboxDataResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MailboxDataResponse] + def initialize(data: OMIT, additional_properties: nil) + @data = data if data != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of MailboxDataResponse + # + # @param json_object [String] + # @return [Monite::MailboxDataResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::MailboxResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of MailboxDataResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data&.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/mailbox_object_type_enum.rb b/lib/monite/types/mailbox_object_type_enum.rb new file mode 100644 index 0000000..e793731 --- /dev/null +++ b/lib/monite/types/mailbox_object_type_enum.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + MAILBOX_OBJECT_TYPE_ENUM = String +end \ No newline at end of file diff --git a/lib/monite/types/mailbox_response.rb b/lib/monite/types/mailbox_response.rb new file mode 100644 index 0000000..87e4fe2 --- /dev/null +++ b/lib/monite/types/mailbox_response.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class MailboxResponse + # @return [String] Mailbox UUID + attr_reader :id + # @return [String] + attr_reader :mailbox_domain_id + # @return [String] + attr_reader :mailbox_full_address + # @return [String] + attr_reader :mailbox_name + # @return [String] + attr_reader :related_object_type + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Mailbox UUID + # @param mailbox_domain_id [String] + # @param mailbox_full_address [String] + # @param mailbox_name [String] + # @param related_object_type [String] + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MailboxResponse] + def initialize(id:, mailbox_domain_id: OMIT, mailbox_full_address:, mailbox_name:, related_object_type:, status:, additional_properties: nil) + @id = id + @mailbox_domain_id = mailbox_domain_id if mailbox_domain_id != OMIT + @mailbox_full_address = mailbox_full_address + @mailbox_name = mailbox_name + @related_object_type = related_object_type + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "mailbox_domain_id": mailbox_domain_id, "mailbox_full_address": mailbox_full_address, "mailbox_name": mailbox_name, "related_object_type": related_object_type, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of MailboxResponse + # + # @param json_object [String] + # @return [Monite::MailboxResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + mailbox_domain_id = parsed_json["mailbox_domain_id"] + mailbox_full_address = parsed_json["mailbox_full_address"] + mailbox_name = parsed_json["mailbox_name"] + related_object_type = parsed_json["related_object_type"] + status = parsed_json["status"] + new( + id: id, + mailbox_domain_id: mailbox_domain_id, + mailbox_full_address: mailbox_full_address, + mailbox_name: mailbox_name, + related_object_type: related_object_type, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of MailboxResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.mailbox_domain_id&.is_a?(String) != false || raise("Passed value for field obj.mailbox_domain_id is not the expected type, validation failed.") + obj.mailbox_full_address.is_a?(String) != false || raise("Passed value for field obj.mailbox_full_address is not the expected type, validation failed.") + obj.mailbox_name.is_a?(String) != false || raise("Passed value for field obj.mailbox_name is not the expected type, validation failed.") + obj.related_object_type.is_a?(String) != false || raise("Passed value for field obj.related_object_type is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/message_response.rb b/lib/monite/types/message_response.rb new file mode 100644 index 0000000..1e2053b --- /dev/null +++ b/lib/monite/types/message_response.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class MessageResponse + # @return [String] + attr_reader :message + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param message [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MessageResponse] + def initialize(message:, additional_properties: nil) + @message = message + @additional_properties = additional_properties + @_field_set = { "message": message } + end +# Deserialize a JSON object to an instance of MessageResponse + # + # @param json_object [String] + # @return [Monite::MessageResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + message = parsed_json["message"] + new(message: message, additional_properties: struct) + end +# Serialize an instance of MessageResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/missing_fields.rb b/lib/monite/types/missing_fields.rb new file mode 100644 index 0000000..44c73a0 --- /dev/null +++ b/lib/monite/types/missing_fields.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true +require_relative "missing_line_item_fields" +require "ostruct" +require "json" + +module Monite + class MissingFields + # @return [Array] Missing fields of counterpart. + attr_reader :counterpart + # @return [Array] Missing fields of entity. + attr_reader :entity + # @return [Array] Missing fields of line items. + attr_reader :products + # @return [Array] Missing fields of receivable. + attr_reader :receivable + # @return [Array] List of invalid vat rates. + attr_reader :vat_rates + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param counterpart [Array] Missing fields of counterpart. + # @param entity [Array] Missing fields of entity. + # @param products [Array] Missing fields of line items. + # @param receivable [Array] Missing fields of receivable. + # @param vat_rates [Array] List of invalid vat rates. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MissingFields] + def initialize(counterpart: OMIT, entity: OMIT, products: OMIT, receivable: OMIT, vat_rates: OMIT, additional_properties: nil) + @counterpart = counterpart if counterpart != OMIT + @entity = entity if entity != OMIT + @products = products if products != OMIT + @receivable = receivable if receivable != OMIT + @vat_rates = vat_rates if vat_rates != OMIT + @additional_properties = additional_properties + @_field_set = { "counterpart": counterpart, "entity": entity, "products": products, "receivable": receivable, "vat_rates": vat_rates }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of MissingFields + # + # @param json_object [String] + # @return [Monite::MissingFields] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + counterpart = parsed_json["counterpart"] + entity = parsed_json["entity"] + products = parsed_json["products"]&.map do | item | + item = item.to_json + Monite::MissingLineItemFields.from_json(json_object: item) +end + receivable = parsed_json["receivable"] + vat_rates = parsed_json["vat_rates"] + new( + counterpart: counterpart, + entity: entity, + products: products, + receivable: receivable, + vat_rates: vat_rates, + additional_properties: struct + ) + end +# Serialize an instance of MissingFields to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.counterpart&.is_a?(Array) != false || raise("Passed value for field obj.counterpart is not the expected type, validation failed.") + obj.entity&.is_a?(Array) != false || raise("Passed value for field obj.entity is not the expected type, validation failed.") + obj.products&.is_a?(Array) != false || raise("Passed value for field obj.products is not the expected type, validation failed.") + obj.receivable&.is_a?(Array) != false || raise("Passed value for field obj.receivable is not the expected type, validation failed.") + obj.vat_rates&.is_a?(Array) != false || raise("Passed value for field obj.vat_rates is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/missing_line_item_fields.rb b/lib/monite/types/missing_line_item_fields.rb new file mode 100644 index 0000000..b34a258 --- /dev/null +++ b/lib/monite/types/missing_line_item_fields.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class MissingLineItemFields + # @return [Integer] Order number of line item. + attr_reader :line_item_number + # @return [Array] Missing fields of line item. + attr_reader :missing_fields + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param line_item_number [Integer] Order number of line item. + # @param missing_fields [Array] Missing fields of line item. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::MissingLineItemFields] + def initialize(line_item_number:, missing_fields:, additional_properties: nil) + @line_item_number = line_item_number + @missing_fields = missing_fields + @additional_properties = additional_properties + @_field_set = { "line_item_number": line_item_number, "missing_fields": missing_fields } + end +# Deserialize a JSON object to an instance of MissingLineItemFields + # + # @param json_object [String] + # @return [Monite::MissingLineItemFields] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + line_item_number = parsed_json["line_item_number"] + missing_fields = parsed_json["missing_fields"] + new( + line_item_number: line_item_number, + missing_fields: missing_fields, + additional_properties: struct + ) + end +# Serialize an instance of MissingLineItemFields to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.line_item_number.is_a?(Integer) != false || raise("Passed value for field obj.line_item_number is not the expected type, validation failed.") + obj.missing_fields.is_a?(Array) != false || raise("Passed value for field obj.missing_fields is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/monite_all_payment_methods.rb b/lib/monite/types/monite_all_payment_methods.rb new file mode 100644 index 0000000..8f0c5af --- /dev/null +++ b/lib/monite/types/monite_all_payment_methods.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Monite + class MoniteAllPaymentMethods + + SEPA_PAYMENTS = "SEPA Payments" + US_ACH_PAYMENTS = "US ACH Payments" + BLIK = "BLIK" + CARD_PAYMENTS = "Card payments" + BACS_DIRECT_DEBIT = "Bacs Direct Debit" + BANCONTACT = "Bancontact" + ELECTRONIC_PAYMENT_STANDARD = "Electronic Payment Standard" + GIROPAY = "Giropay" + I_DEAL = "iDEAL" + PRZELEWY_24 = "Przelewy24" + SEPA_DIRECT_DEBIT = "SEPA Direct Debit" + SOFORT = "SOFORT" + APPLE_PAY = "Apple Pay" + GOOGLE_PAY = "Google Pay" + + end +end \ No newline at end of file diff --git a/lib/monite/types/monite_all_payment_methods_types.rb b/lib/monite/types/monite_all_payment_methods_types.rb new file mode 100644 index 0000000..694b919 --- /dev/null +++ b/lib/monite/types/monite_all_payment_methods_types.rb @@ -0,0 +1,22 @@ +# frozen_string_literal: true + +module Monite + class MoniteAllPaymentMethodsTypes + + SEPA_CREDIT = "sepa_credit" + US_ACH = "us_ach" + BLIK = "blik" + CARD = "card" + BACS_DIRECT_DEBIT = "bacs_direct_debit" + BANCONTACT = "bancontact" + EPS = "eps" + GIROPAY = "giropay" + IDEAL = "ideal" + P_24 = "p24" + SEPA_DEBIT = "sepa_debit" + SOFORT = "sofort" + APPLEPAY = "applepay" + GOOGLEPAY = "googlepay" + + end +end \ No newline at end of file diff --git a/lib/monite/types/object_match_types.rb b/lib/monite/types/object_match_types.rb new file mode 100644 index 0000000..7971345 --- /dev/null +++ b/lib/monite/types/object_match_types.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite + class ObjectMatchTypes + + PRODUCT = "product" + CUSTOMER = "customer" + VENDOR = "vendor" + RECEIVABLE = "receivable" + BILL = "bill" + PAYMENT_RECORD = "payment_record" + + end +end \ No newline at end of file diff --git a/lib/monite/types/object_type.rb b/lib/monite/types/object_type.rb new file mode 100644 index 0000000..9c3a03f --- /dev/null +++ b/lib/monite/types/object_type.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true + +module Monite + class ObjectType + + ACCOUNT = "account" + APPROVAL = "approval" + APPROVAL_REQUEST = "approval_request" + APPROVAL_POLICY = "approval_policy" + APPROVAL_POLICY_PROCESS = "approval_policy_process" + AUDIT_TRAIL = "audit_trail" + COMMENT = "comment" + COUNTERPART = "counterpart" + COUNTERPART_ADDRESS = "counterpart_address" + COUNTERPART_BANK_ACCOUNT = "counterpart_bank_account" + COUNTERPART_CONTACT_PERSON = "counterpart_contact_person" + COUNTERPART_PARTNER_METADATA = "counterpart_partner_metadata" + COUNTERPART_TAX_ID = "counterpart_tax_id" + COUNTERPART_VAT_ID = "counterpart_vat_id" + EINVOICING = "einvoicing" + ENTITY = "entity" + ENTITY_BANK_ACCOUNT = "entity_bank_account" + ENTITY_SETTINGS = "entity_settings" + ENTITY_TOKEN = "entity_token" + ENTITY_USER = "entity_user" + ENTITY_USER_TOKEN = "entity_user_token" + ENTITY_VAT_IDS = "entity_vat_ids" + EXPORT = "export" + MAILBOX = "mailbox" + MONITESCRIPT_PROCESS = "monitescript_process" + ONBOARDING = "onboarding" + OVERDUE_REMINDER = "overdue_reminder" + PARTNER = "partner" + PARTNER_INTERNAL_CONFIG = "partner_internal_config" + PARTNER_SETTINGS = "partner_settings" + PARTNER_TOKEN = "partner_token" + PAYABLE = "payable" + PAYABLE_LINE_ITEM = "payable_line_item" + PAYABLES_CREDIT_NOTE = "payables_credit_note" + PAYABLES_PURCHASE_ORDER = "payables_purchase_order" + PAYMENT = "payment" + PAYMENT_INTENT = "payment_intent" + PAYMENT_LINK = "payment_link" + PAYMENT_RECORD = "payment_record" + PAYMENT_REMINDER = "payment_reminder" + PERSON = "person" + PRODUCT = "product" + PROJECT = "project" + RECEIVABLE = "receivable" + RECONCILIATION = "reconciliation" + RECURRENCE = "recurrence" + ROLE = "role" + TAG = "tag" + TODO_TASK = "todo_task" + TODO_TASK_MUTE = "todo_task_mute" + TRANSACTION = "transaction" + WEBHOOK = "webhook" + WORKFLOW = "workflow" + WORKFLOW_PIPELINE = "workflow_pipeline" + + end +end \ No newline at end of file diff --git a/lib/monite/types/object_type_available_comment.rb b/lib/monite/types/object_type_available_comment.rb new file mode 100644 index 0000000..2fa1448 --- /dev/null +++ b/lib/monite/types/object_type_available_comment.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + OBJECT_TYPE_AVAILABLE_COMMENT = String +end \ No newline at end of file diff --git a/lib/monite/types/object_type_enum.rb b/lib/monite/types/object_type_enum.rb new file mode 100644 index 0000000..0d2a05c --- /dev/null +++ b/lib/monite/types/object_type_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ObjectTypeEnum + + RECEIVABLE = "receivable" + PAYABLE = "payable" + + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_address.rb b/lib/monite/types/ocr_address.rb new file mode 100644 index 0000000..7505f0a --- /dev/null +++ b/lib/monite/types/ocr_address.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# In general it's compatible with CounterpartAddress model but +# * All fields are optional +# * There is an additional field original_country_name + class OcrAddress + # @return [String] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Country name as it is stated in the document. + attr_reader :original_country_name + # @return [String] City name. + attr_reader :city + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param country [String] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param original_country_name [String] Country name as it is stated in the document. + # @param city [String] City name. + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OcrAddress] + def initialize(country: OMIT, original_country_name: OMIT, city: OMIT, postal_code: OMIT, state: OMIT, line_1: OMIT, line_2: OMIT, additional_properties: nil) + @country = country if country != OMIT + @original_country_name = original_country_name if original_country_name != OMIT + @city = city if city != OMIT + @postal_code = postal_code if postal_code != OMIT + @state = state if state != OMIT + @line_1 = line_1 if line_1 != OMIT + @line_2 = line_2 if line_2 != OMIT + @additional_properties = additional_properties + @_field_set = { "country": country, "original_country_name": original_country_name, "city": city, "postal_code": postal_code, "state": state, "line1": line_1, "line2": line_2 }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OcrAddress + # + # @param json_object [String] + # @return [Monite::OcrAddress] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + country = parsed_json["country"] + original_country_name = parsed_json["original_country_name"] + city = parsed_json["city"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + new( + country: country, + original_country_name: original_country_name, + city: city, + postal_code: postal_code, + state: state, + line_1: line_1, + line_2: line_2, + additional_properties: struct + ) + end +# Serialize an instance of OcrAddress to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.country&.is_a?(String) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.original_country_name&.is_a?(String) != false || raise("Passed value for field obj.original_country_name is not the expected type, validation failed.") + obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.postal_code&.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + obj.line_1&.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_auto_tagging_settings_request.rb b/lib/monite/types/ocr_auto_tagging_settings_request.rb new file mode 100644 index 0000000..6bbbd33 --- /dev/null +++ b/lib/monite/types/ocr_auto_tagging_settings_request.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OcrAutoTaggingSettingsRequest + # @return [Boolean] A switch to temporarily disable a keyword without removing it from the list. + attr_reader :enabled + # @return [Array] A list of words that will be searched for assigning a tag in the recognized +# fields of the document after OCR processing. If at least one match is found, the +# tag will be assigned. Each keyword must be between 2 and 25 characters long. + attr_reader :keywords + # @return [String] Tag identifier that will be assigned to the payable document if one of the words +# listed in keywords is found during OCR. + attr_reader :tag_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param enabled [Boolean] A switch to temporarily disable a keyword without removing it from the list. + # @param keywords [Array] A list of words that will be searched for assigning a tag in the recognized +# fields of the document after OCR processing. If at least one match is found, the +# tag will be assigned. Each keyword must be between 2 and 25 characters long. + # @param tag_id [String] Tag identifier that will be assigned to the payable document if one of the words +# listed in keywords is found during OCR. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OcrAutoTaggingSettingsRequest] + def initialize(enabled:, keywords:, tag_id:, additional_properties: nil) + @enabled = enabled + @keywords = keywords + @tag_id = tag_id + @additional_properties = additional_properties + @_field_set = { "enabled": enabled, "keywords": keywords, "tag_id": tag_id } + end +# Deserialize a JSON object to an instance of OcrAutoTaggingSettingsRequest + # + # @param json_object [String] + # @return [Monite::OcrAutoTaggingSettingsRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + enabled = parsed_json["enabled"] + keywords = parsed_json["keywords"] + tag_id = parsed_json["tag_id"] + new( + enabled: enabled, + keywords: keywords, + tag_id: tag_id, + additional_properties: struct + ) + end +# Serialize an instance of OcrAutoTaggingSettingsRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.enabled.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.") + obj.keywords.is_a?(Array) != false || raise("Passed value for field obj.keywords is not the expected type, validation failed.") + obj.tag_id.is_a?(String) != false || raise("Passed value for field obj.tag_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_recognition_response.rb b/lib/monite/types/ocr_recognition_response.rb new file mode 100644 index 0000000..84d897e --- /dev/null +++ b/lib/monite/types/ocr_recognition_response.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require_relative "label_n_value" +require "ostruct" +require "json" + +module Monite +# Contains information about all text blocks extracted from an uploaded invoice by +# OCR. +# The text blocks are grouped into `line_items` (invoice line items) and `summary` +# (all other information). +# Legacy schema used for AWS textract recognition. + class OcrRecognitionResponse + # @return [Array] Invoice text content other than the line items. Such as the invoice issue and +# due dates, vendor name and address, and other general information. + attr_reader :summary + # @return [Array] Text content of the invoice line items as recognized by OCR. + attr_reader :line_items + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param summary [Array] Invoice text content other than the line items. Such as the invoice issue and +# due dates, vendor name and address, and other general information. + # @param line_items [Array] Text content of the invoice line items as recognized by OCR. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OcrRecognitionResponse] + def initialize(summary: OMIT, line_items: OMIT, additional_properties: nil) + @summary = summary if summary != OMIT + @line_items = line_items if line_items != OMIT + @additional_properties = additional_properties + @_field_set = { "summary": summary, "line_items": line_items }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OcrRecognitionResponse + # + # @param json_object [String] + # @return [Monite::OcrRecognitionResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + summary = parsed_json["summary"]&.map do | item | + item = item.to_json + Monite::LabelNValue.from_json(json_object: item) +end + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::LabelNValue.from_json(json_object: item) +end + new( + summary: summary, + line_items: line_items, + additional_properties: struct + ) + end +# Serialize an instance of OcrRecognitionResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.summary&.is_a?(Array) != false || raise("Passed value for field obj.summary is not the expected type, validation failed.") + obj.line_items&.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_response_invoice_receipt_data.rb b/lib/monite/types/ocr_response_invoice_receipt_data.rb new file mode 100644 index 0000000..df3a971 --- /dev/null +++ b/lib/monite/types/ocr_response_invoice_receipt_data.rb @@ -0,0 +1,249 @@ +# frozen_string_literal: true +require_relative "ocr_address" +require_relative "ocr_response_invoice_receipt_line_item" +require_relative "ocr_response_invoice_receipt_line_item_raw" +require "ostruct" +require "json" + +module Monite + class OcrResponseInvoiceReceiptData + # @return [String] + attr_reader :type + # @return [Integer] Total in cents/eurocents. Outdated, actual conversion happens in payables. + attr_reader :total + # @return [Float] Total paid amount + attr_reader :total_paid_amount_raw + # @return [Float] Total, without minor units + attr_reader :total_raw + # @return [Integer] Subtotal cents/eurocents. Outdated, actual conversion happens in payables. + attr_reader :total_excl_vat + # @return [Float] Subtotal, without minor units + attr_reader :total_excl_vat_raw + # @return [Integer] VAT amount in cents. Outdated, actual conversion happens in payables. + attr_reader :total_vat_amount + # @return [Float] VAT amount, without minor units + attr_reader :total_vat_amount_raw + # @return [Integer] VAT Percent minor units. Example: 12.5% is 1250. Outdated, actual conversion +# happens in payables. + attr_reader :total_vat_rate + # @return [Float] VAT Percent raw, without minor units. + attr_reader :total_vat_rate_raw + # @return [String] ISO 4217 currency code + attr_reader :currency + # @return [String] Purchase Order Number + attr_reader :purchase_order_number + # @return [String] Counterpart name + attr_reader :counterpart_name + # @return [String] Counterpart address + attr_reader :counterpart_address + # @return [String] Counterpart bank ID + attr_reader :counterpart_account_id + # @return [String] Invoice/receipt ID + attr_reader :document_id + # @return [Array] Raw payment terms parsed but not calculated. + attr_reader :payment_terms_raw + # @return [String] Tax payer ID + attr_reader :tax_payer_id + # @return [String] Counterpart VAT ID + attr_reader :counterpart_vat_id + # @return [String] Document issuance date in ISO format + attr_reader :document_issued_at_date + # @return [String] Document due date in ISO format + attr_reader :document_due_date + # @return [Monite::OcrAddress] Counterpart address as a json object compatible with counterparts service + attr_reader :counterpart_address_object + # @return [String] The bank account number + attr_reader :counterpart_account_number + # @return [String] The bank routing number + attr_reader :counterpart_routing_number + # @return [Array] List of line items from document. Outdated, actual conversion happens in +# payables. + attr_reader :line_items + # @return [Array] List of line items from document raw, without minor units conversion. + attr_reader :line_items_raw + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param type [String] + # @param total [Integer] Total in cents/eurocents. Outdated, actual conversion happens in payables. + # @param total_paid_amount_raw [Float] Total paid amount + # @param total_raw [Float] Total, without minor units + # @param total_excl_vat [Integer] Subtotal cents/eurocents. Outdated, actual conversion happens in payables. + # @param total_excl_vat_raw [Float] Subtotal, without minor units + # @param total_vat_amount [Integer] VAT amount in cents. Outdated, actual conversion happens in payables. + # @param total_vat_amount_raw [Float] VAT amount, without minor units + # @param total_vat_rate [Integer] VAT Percent minor units. Example: 12.5% is 1250. Outdated, actual conversion +# happens in payables. + # @param total_vat_rate_raw [Float] VAT Percent raw, without minor units. + # @param currency [String] ISO 4217 currency code + # @param purchase_order_number [String] Purchase Order Number + # @param counterpart_name [String] Counterpart name + # @param counterpart_address [String] Counterpart address + # @param counterpart_account_id [String] Counterpart bank ID + # @param document_id [String] Invoice/receipt ID + # @param payment_terms_raw [Array] Raw payment terms parsed but not calculated. + # @param tax_payer_id [String] Tax payer ID + # @param counterpart_vat_id [String] Counterpart VAT ID + # @param document_issued_at_date [String] Document issuance date in ISO format + # @param document_due_date [String] Document due date in ISO format + # @param counterpart_address_object [Monite::OcrAddress] Counterpart address as a json object compatible with counterparts service + # @param counterpart_account_number [String] The bank account number + # @param counterpart_routing_number [String] The bank routing number + # @param line_items [Array] List of line items from document. Outdated, actual conversion happens in +# payables. + # @param line_items_raw [Array] List of line items from document raw, without minor units conversion. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OcrResponseInvoiceReceiptData] + def initialize(type: OMIT, total: OMIT, total_paid_amount_raw: OMIT, total_raw: OMIT, total_excl_vat: OMIT, total_excl_vat_raw: OMIT, total_vat_amount: OMIT, total_vat_amount_raw: OMIT, total_vat_rate: OMIT, total_vat_rate_raw: OMIT, currency: OMIT, purchase_order_number: OMIT, counterpart_name: OMIT, counterpart_address: OMIT, counterpart_account_id: OMIT, document_id: OMIT, payment_terms_raw: OMIT, tax_payer_id: OMIT, counterpart_vat_id: OMIT, document_issued_at_date: OMIT, document_due_date: OMIT, counterpart_address_object: OMIT, counterpart_account_number: OMIT, counterpart_routing_number: OMIT, line_items: OMIT, line_items_raw: OMIT, additional_properties: nil) + @type = type if type != OMIT + @total = total if total != OMIT + @total_paid_amount_raw = total_paid_amount_raw if total_paid_amount_raw != OMIT + @total_raw = total_raw if total_raw != OMIT + @total_excl_vat = total_excl_vat if total_excl_vat != OMIT + @total_excl_vat_raw = total_excl_vat_raw if total_excl_vat_raw != OMIT + @total_vat_amount = total_vat_amount if total_vat_amount != OMIT + @total_vat_amount_raw = total_vat_amount_raw if total_vat_amount_raw != OMIT + @total_vat_rate = total_vat_rate if total_vat_rate != OMIT + @total_vat_rate_raw = total_vat_rate_raw if total_vat_rate_raw != OMIT + @currency = currency if currency != OMIT + @purchase_order_number = purchase_order_number if purchase_order_number != OMIT + @counterpart_name = counterpart_name if counterpart_name != OMIT + @counterpart_address = counterpart_address if counterpart_address != OMIT + @counterpart_account_id = counterpart_account_id if counterpart_account_id != OMIT + @document_id = document_id if document_id != OMIT + @payment_terms_raw = payment_terms_raw if payment_terms_raw != OMIT + @tax_payer_id = tax_payer_id if tax_payer_id != OMIT + @counterpart_vat_id = counterpart_vat_id if counterpart_vat_id != OMIT + @document_issued_at_date = document_issued_at_date if document_issued_at_date != OMIT + @document_due_date = document_due_date if document_due_date != OMIT + @counterpart_address_object = counterpart_address_object if counterpart_address_object != OMIT + @counterpart_account_number = counterpart_account_number if counterpart_account_number != OMIT + @counterpart_routing_number = counterpart_routing_number if counterpart_routing_number != OMIT + @line_items = line_items if line_items != OMIT + @line_items_raw = line_items_raw if line_items_raw != OMIT + @additional_properties = additional_properties + @_field_set = { "type": type, "total": total, "total_paid_amount_raw": total_paid_amount_raw, "total_raw": total_raw, "total_excl_vat": total_excl_vat, "total_excl_vat_raw": total_excl_vat_raw, "total_vat_amount": total_vat_amount, "total_vat_amount_raw": total_vat_amount_raw, "total_vat_rate": total_vat_rate, "total_vat_rate_raw": total_vat_rate_raw, "currency": currency, "purchase_order_number": purchase_order_number, "counterpart_name": counterpart_name, "counterpart_address": counterpart_address, "counterpart_account_id": counterpart_account_id, "document_id": document_id, "payment_terms_raw": payment_terms_raw, "tax_payer_id": tax_payer_id, "counterpart_vat_id": counterpart_vat_id, "document_issued_at_date": document_issued_at_date, "document_due_date": document_due_date, "counterpart_address_object": counterpart_address_object, "counterpart_account_number": counterpart_account_number, "counterpart_routing_number": counterpart_routing_number, "line_items": line_items, "line_items_raw": line_items_raw }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OcrResponseInvoiceReceiptData + # + # @param json_object [String] + # @return [Monite::OcrResponseInvoiceReceiptData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + type = parsed_json["type"] + total = parsed_json["total"] + total_paid_amount_raw = parsed_json["total_paid_amount_raw"] + total_raw = parsed_json["total_raw"] + total_excl_vat = parsed_json["total_excl_vat"] + total_excl_vat_raw = parsed_json["total_excl_vat_raw"] + total_vat_amount = parsed_json["total_vat_amount"] + total_vat_amount_raw = parsed_json["total_vat_amount_raw"] + total_vat_rate = parsed_json["total_vat_rate"] + total_vat_rate_raw = parsed_json["total_vat_rate_raw"] + currency = parsed_json["currency"] + purchase_order_number = parsed_json["purchase_order_number"] + counterpart_name = parsed_json["counterpart_name"] + counterpart_address = parsed_json["counterpart_address"] + counterpart_account_id = parsed_json["counterpart_account_id"] + document_id = parsed_json["document_id"] + payment_terms_raw = parsed_json["payment_terms_raw"] + tax_payer_id = parsed_json["tax_payer_id"] + counterpart_vat_id = parsed_json["counterpart_vat_id"] + document_issued_at_date = parsed_json["document_issued_at_date"] + document_due_date = parsed_json["document_due_date"] + unless parsed_json["counterpart_address_object"].nil? + counterpart_address_object = parsed_json["counterpart_address_object"].to_json + counterpart_address_object = Monite::OcrAddress.from_json(json_object: counterpart_address_object) + else + counterpart_address_object = nil + end + counterpart_account_number = parsed_json["counterpart_account_number"] + counterpart_routing_number = parsed_json["counterpart_routing_number"] + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::OcrResponseInvoiceReceiptLineItem.from_json(json_object: item) +end + line_items_raw = parsed_json["line_items_raw"]&.map do | item | + item = item.to_json + Monite::OcrResponseInvoiceReceiptLineItemRaw.from_json(json_object: item) +end + new( + type: type, + total: total, + total_paid_amount_raw: total_paid_amount_raw, + total_raw: total_raw, + total_excl_vat: total_excl_vat, + total_excl_vat_raw: total_excl_vat_raw, + total_vat_amount: total_vat_amount, + total_vat_amount_raw: total_vat_amount_raw, + total_vat_rate: total_vat_rate, + total_vat_rate_raw: total_vat_rate_raw, + currency: currency, + purchase_order_number: purchase_order_number, + counterpart_name: counterpart_name, + counterpart_address: counterpart_address, + counterpart_account_id: counterpart_account_id, + document_id: document_id, + payment_terms_raw: payment_terms_raw, + tax_payer_id: tax_payer_id, + counterpart_vat_id: counterpart_vat_id, + document_issued_at_date: document_issued_at_date, + document_due_date: document_due_date, + counterpart_address_object: counterpart_address_object, + counterpart_account_number: counterpart_account_number, + counterpart_routing_number: counterpart_routing_number, + line_items: line_items, + line_items_raw: line_items_raw, + additional_properties: struct + ) + end +# Serialize an instance of OcrResponseInvoiceReceiptData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.type&.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.total&.is_a?(Integer) != false || raise("Passed value for field obj.total is not the expected type, validation failed.") + obj.total_paid_amount_raw&.is_a?(Float) != false || raise("Passed value for field obj.total_paid_amount_raw is not the expected type, validation failed.") + obj.total_raw&.is_a?(Float) != false || raise("Passed value for field obj.total_raw is not the expected type, validation failed.") + obj.total_excl_vat&.is_a?(Integer) != false || raise("Passed value for field obj.total_excl_vat is not the expected type, validation failed.") + obj.total_excl_vat_raw&.is_a?(Float) != false || raise("Passed value for field obj.total_excl_vat_raw is not the expected type, validation failed.") + obj.total_vat_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_vat_amount is not the expected type, validation failed.") + obj.total_vat_amount_raw&.is_a?(Float) != false || raise("Passed value for field obj.total_vat_amount_raw is not the expected type, validation failed.") + obj.total_vat_rate&.is_a?(Integer) != false || raise("Passed value for field obj.total_vat_rate is not the expected type, validation failed.") + obj.total_vat_rate_raw&.is_a?(Float) != false || raise("Passed value for field obj.total_vat_rate_raw is not the expected type, validation failed.") + obj.currency&.is_a?(String) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.purchase_order_number&.is_a?(String) != false || raise("Passed value for field obj.purchase_order_number is not the expected type, validation failed.") + obj.counterpart_name&.is_a?(String) != false || raise("Passed value for field obj.counterpart_name is not the expected type, validation failed.") + obj.counterpart_address&.is_a?(String) != false || raise("Passed value for field obj.counterpart_address is not the expected type, validation failed.") + obj.counterpart_account_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_account_id is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.payment_terms_raw&.is_a?(Array) != false || raise("Passed value for field obj.payment_terms_raw is not the expected type, validation failed.") + obj.tax_payer_id&.is_a?(String) != false || raise("Passed value for field obj.tax_payer_id is not the expected type, validation failed.") + obj.counterpart_vat_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id is not the expected type, validation failed.") + obj.document_issued_at_date&.is_a?(String) != false || raise("Passed value for field obj.document_issued_at_date is not the expected type, validation failed.") + obj.document_due_date&.is_a?(String) != false || raise("Passed value for field obj.document_due_date is not the expected type, validation failed.") + obj.counterpart_address_object.nil? || Monite::OcrAddress.validate_raw(obj: obj.counterpart_address_object) + obj.counterpart_account_number&.is_a?(String) != false || raise("Passed value for field obj.counterpart_account_number is not the expected type, validation failed.") + obj.counterpart_routing_number&.is_a?(String) != false || raise("Passed value for field obj.counterpart_routing_number is not the expected type, validation failed.") + obj.line_items&.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.line_items_raw&.is_a?(Array) != false || raise("Passed value for field obj.line_items_raw is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_response_invoice_receipt_line_item.rb b/lib/monite/types/ocr_response_invoice_receipt_line_item.rb new file mode 100644 index 0000000..72682a7 --- /dev/null +++ b/lib/monite/types/ocr_response_invoice_receipt_line_item.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OcrResponseInvoiceReceiptLineItem + # @return [String] OCR Id of line item + attr_reader :line_item_ocr_id + # @return [String] Human-readable line item description + attr_reader :description + # @return [Float] Quanity + attr_reader :quantity + # @return [Integer] Price in cents/eurocents + attr_reader :unit_price + # @return [String] Unit + attr_reader :unit + # @return [Integer] VAT Percent minor units. Example: 12.5% is 1250. + attr_reader :vat_percentage + # @return [Integer] VAT Amount minor units. + attr_reader :vat_amount + # @return [Integer] Total excl VAT + attr_reader :total_excl_vat + # @return [Integer] Total included VAT + attr_reader :total_incl_vat + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param line_item_ocr_id [String] OCR Id of line item + # @param description [String] Human-readable line item description + # @param quantity [Float] Quanity + # @param unit_price [Integer] Price in cents/eurocents + # @param unit [String] Unit + # @param vat_percentage [Integer] VAT Percent minor units. Example: 12.5% is 1250. + # @param vat_amount [Integer] VAT Amount minor units. + # @param total_excl_vat [Integer] Total excl VAT + # @param total_incl_vat [Integer] Total included VAT + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OcrResponseInvoiceReceiptLineItem] + def initialize(line_item_ocr_id: OMIT, description: OMIT, quantity: OMIT, unit_price: OMIT, unit: OMIT, vat_percentage: OMIT, vat_amount: OMIT, total_excl_vat: OMIT, total_incl_vat: OMIT, additional_properties: nil) + @line_item_ocr_id = line_item_ocr_id if line_item_ocr_id != OMIT + @description = description if description != OMIT + @quantity = quantity if quantity != OMIT + @unit_price = unit_price if unit_price != OMIT + @unit = unit if unit != OMIT + @vat_percentage = vat_percentage if vat_percentage != OMIT + @vat_amount = vat_amount if vat_amount != OMIT + @total_excl_vat = total_excl_vat if total_excl_vat != OMIT + @total_incl_vat = total_incl_vat if total_incl_vat != OMIT + @additional_properties = additional_properties + @_field_set = { "line_item_ocr_id": line_item_ocr_id, "description": description, "quantity": quantity, "unit_price": unit_price, "unit": unit, "vat_percentage": vat_percentage, "vat_amount": vat_amount, "total_excl_vat": total_excl_vat, "total_incl_vat": total_incl_vat }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OcrResponseInvoiceReceiptLineItem + # + # @param json_object [String] + # @return [Monite::OcrResponseInvoiceReceiptLineItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + line_item_ocr_id = parsed_json["line_item_ocr_id"] + description = parsed_json["description"] + quantity = parsed_json["quantity"] + unit_price = parsed_json["unit_price"] + unit = parsed_json["unit"] + vat_percentage = parsed_json["vat_percentage"] + vat_amount = parsed_json["vat_amount"] + total_excl_vat = parsed_json["total_excl_vat"] + total_incl_vat = parsed_json["total_incl_vat"] + new( + line_item_ocr_id: line_item_ocr_id, + description: description, + quantity: quantity, + unit_price: unit_price, + unit: unit, + vat_percentage: vat_percentage, + vat_amount: vat_amount, + total_excl_vat: total_excl_vat, + total_incl_vat: total_incl_vat, + additional_properties: struct + ) + end +# Serialize an instance of OcrResponseInvoiceReceiptLineItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.line_item_ocr_id&.is_a?(String) != false || raise("Passed value for field obj.line_item_ocr_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.unit_price&.is_a?(Integer) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.vat_percentage&.is_a?(Integer) != false || raise("Passed value for field obj.vat_percentage is not the expected type, validation failed.") + obj.vat_amount&.is_a?(Integer) != false || raise("Passed value for field obj.vat_amount is not the expected type, validation failed.") + obj.total_excl_vat&.is_a?(Integer) != false || raise("Passed value for field obj.total_excl_vat is not the expected type, validation failed.") + obj.total_incl_vat&.is_a?(Integer) != false || raise("Passed value for field obj.total_incl_vat is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_response_invoice_receipt_line_item_raw.rb b/lib/monite/types/ocr_response_invoice_receipt_line_item_raw.rb new file mode 100644 index 0000000..b96a12c --- /dev/null +++ b/lib/monite/types/ocr_response_invoice_receipt_line_item_raw.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OcrResponseInvoiceReceiptLineItemRaw + # @return [String] OCR Id of line item + attr_reader :line_item_ocr_id + # @return [String] Human-readable line item description + attr_reader :description + # @return [Float] Quanity + attr_reader :quantity + # @return [Float] Price as parsed + attr_reader :unit_price + # @return [String] Unit + attr_reader :unit + # @return [Float] VAT Percent as parsed. + attr_reader :vat_percentage + # @return [Float] VAT Amount as parsed. + attr_reader :vat_amount + # @return [Float] Total excluded VAT as parsed. + attr_reader :total_excl_vat + # @return [Float] Total included VAT as parsed. + attr_reader :total_incl_vat + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param line_item_ocr_id [String] OCR Id of line item + # @param description [String] Human-readable line item description + # @param quantity [Float] Quanity + # @param unit_price [Float] Price as parsed + # @param unit [String] Unit + # @param vat_percentage [Float] VAT Percent as parsed. + # @param vat_amount [Float] VAT Amount as parsed. + # @param total_excl_vat [Float] Total excluded VAT as parsed. + # @param total_incl_vat [Float] Total included VAT as parsed. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OcrResponseInvoiceReceiptLineItemRaw] + def initialize(line_item_ocr_id: OMIT, description: OMIT, quantity: OMIT, unit_price: OMIT, unit: OMIT, vat_percentage: OMIT, vat_amount: OMIT, total_excl_vat: OMIT, total_incl_vat: OMIT, additional_properties: nil) + @line_item_ocr_id = line_item_ocr_id if line_item_ocr_id != OMIT + @description = description if description != OMIT + @quantity = quantity if quantity != OMIT + @unit_price = unit_price if unit_price != OMIT + @unit = unit if unit != OMIT + @vat_percentage = vat_percentage if vat_percentage != OMIT + @vat_amount = vat_amount if vat_amount != OMIT + @total_excl_vat = total_excl_vat if total_excl_vat != OMIT + @total_incl_vat = total_incl_vat if total_incl_vat != OMIT + @additional_properties = additional_properties + @_field_set = { "line_item_ocr_id": line_item_ocr_id, "description": description, "quantity": quantity, "unit_price": unit_price, "unit": unit, "vat_percentage": vat_percentage, "vat_amount": vat_amount, "total_excl_vat": total_excl_vat, "total_incl_vat": total_incl_vat }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OcrResponseInvoiceReceiptLineItemRaw + # + # @param json_object [String] + # @return [Monite::OcrResponseInvoiceReceiptLineItemRaw] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + line_item_ocr_id = parsed_json["line_item_ocr_id"] + description = parsed_json["description"] + quantity = parsed_json["quantity"] + unit_price = parsed_json["unit_price"] + unit = parsed_json["unit"] + vat_percentage = parsed_json["vat_percentage"] + vat_amount = parsed_json["vat_amount"] + total_excl_vat = parsed_json["total_excl_vat"] + total_incl_vat = parsed_json["total_incl_vat"] + new( + line_item_ocr_id: line_item_ocr_id, + description: description, + quantity: quantity, + unit_price: unit_price, + unit: unit, + vat_percentage: vat_percentage, + vat_amount: vat_amount, + total_excl_vat: total_excl_vat, + total_incl_vat: total_incl_vat, + additional_properties: struct + ) + end +# Serialize an instance of OcrResponseInvoiceReceiptLineItemRaw to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.line_item_ocr_id&.is_a?(String) != false || raise("Passed value for field obj.line_item_ocr_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.quantity&.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.unit_price&.is_a?(Float) != false || raise("Passed value for field obj.unit_price is not the expected type, validation failed.") + obj.unit&.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.vat_percentage&.is_a?(Float) != false || raise("Passed value for field obj.vat_percentage is not the expected type, validation failed.") + obj.vat_amount&.is_a?(Float) != false || raise("Passed value for field obj.vat_amount is not the expected type, validation failed.") + obj.total_excl_vat&.is_a?(Float) != false || raise("Passed value for field obj.total_excl_vat is not the expected type, validation failed.") + obj.total_incl_vat&.is_a?(Float) != false || raise("Passed value for field obj.total_incl_vat is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ocr_status_enum.rb b/lib/monite/types/ocr_status_enum.rb new file mode 100644 index 0000000..7b45404 --- /dev/null +++ b/lib/monite/types/ocr_status_enum.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + class OcrStatusEnum + + PROCESSING = "processing" + ERROR = "error" + SUCCESS = "success" + CANCELED = "canceled" + + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_link_public_response.rb b/lib/monite/types/onboarding_link_public_response.rb new file mode 100644 index 0000000..09a1585 --- /dev/null +++ b/lib/monite/types/onboarding_link_public_response.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class OnboardingLinkPublicResponse + # @return [String] + attr_reader :id + # @return [String] + attr_reader :entity_id + # @return [DateTime] + attr_reader :expires_at + # @return [String] + attr_reader :refresh_url + # @return [String] + attr_reader :return_url + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param entity_id [String] + # @param expires_at [DateTime] + # @param refresh_url [String] + # @param return_url [String] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingLinkPublicResponse] + def initialize(id:, entity_id:, expires_at:, refresh_url:, return_url:, url:, additional_properties: nil) + @id = id + @entity_id = entity_id + @expires_at = expires_at + @refresh_url = refresh_url + @return_url = return_url + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "entity_id": entity_id, "expires_at": expires_at, "refresh_url": refresh_url, "return_url": return_url, "url": url } + end +# Deserialize a JSON object to an instance of OnboardingLinkPublicResponse + # + # @param json_object [String] + # @return [Monite::OnboardingLinkPublicResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + entity_id = parsed_json["entity_id"] + expires_at = unless parsed_json["expires_at"].nil? + DateTime.parse(parsed_json["expires_at"]) +else + nil +end + refresh_url = parsed_json["refresh_url"] + return_url = parsed_json["return_url"] + url = parsed_json["url"] + new( + id: id, + entity_id: entity_id, + expires_at: expires_at, + refresh_url: refresh_url, + return_url: return_url, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of OnboardingLinkPublicResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.expires_at.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.") + obj.refresh_url.is_a?(String) != false || raise("Passed value for field obj.refresh_url is not the expected type, validation failed.") + obj.return_url.is_a?(String) != false || raise("Passed value for field obj.return_url is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_link_request.rb b/lib/monite/types/onboarding_link_request.rb new file mode 100644 index 0000000..098a152 --- /dev/null +++ b/lib/monite/types/onboarding_link_request.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class OnboardingLinkRequest + # @return [DateTime] + attr_reader :expires_at + # @return [String] + attr_reader :refresh_url + # @return [String] + attr_reader :return_url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param expires_at [DateTime] + # @param refresh_url [String] + # @param return_url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingLinkRequest] + def initialize(expires_at:, refresh_url:, return_url:, additional_properties: nil) + @expires_at = expires_at + @refresh_url = refresh_url + @return_url = return_url + @additional_properties = additional_properties + @_field_set = { "expires_at": expires_at, "refresh_url": refresh_url, "return_url": return_url } + end +# Deserialize a JSON object to an instance of OnboardingLinkRequest + # + # @param json_object [String] + # @return [Monite::OnboardingLinkRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + expires_at = unless parsed_json["expires_at"].nil? + DateTime.parse(parsed_json["expires_at"]) +else + nil +end + refresh_url = parsed_json["refresh_url"] + return_url = parsed_json["return_url"] + new( + expires_at: expires_at, + refresh_url: refresh_url, + return_url: return_url, + additional_properties: struct + ) + end +# Serialize an instance of OnboardingLinkRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.expires_at.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.") + obj.refresh_url.is_a?(String) != false || raise("Passed value for field obj.refresh_url is not the expected type, validation failed.") + obj.return_url.is_a?(String) != false || raise("Passed value for field obj.return_url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_link_response.rb b/lib/monite/types/onboarding_link_response.rb new file mode 100644 index 0000000..63adcec --- /dev/null +++ b/lib/monite/types/onboarding_link_response.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "recipient" +require "ostruct" +require "json" + +module Monite + class OnboardingLinkResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :expires_at + # @return [Monite::Recipient] + attr_reader :recipient + # @return [String] + attr_reader :refresh_url + # @return [String] + attr_reader :return_url + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param expires_at [DateTime] + # @param recipient [Monite::Recipient] + # @param refresh_url [String] + # @param return_url [String] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingLinkResponse] + def initialize(id:, created_at:, expires_at:, recipient:, refresh_url:, return_url:, url:, additional_properties: nil) + @id = id + @created_at = created_at + @expires_at = expires_at + @recipient = recipient + @refresh_url = refresh_url + @return_url = return_url + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "expires_at": expires_at, "recipient": recipient, "refresh_url": refresh_url, "return_url": return_url, "url": url } + end +# Deserialize a JSON object to an instance of OnboardingLinkResponse + # + # @param json_object [String] + # @return [Monite::OnboardingLinkResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + expires_at = unless parsed_json["expires_at"].nil? + DateTime.parse(parsed_json["expires_at"]) +else + nil +end + unless parsed_json["recipient"].nil? + recipient = parsed_json["recipient"].to_json + recipient = Monite::Recipient.from_json(json_object: recipient) + else + recipient = nil + end + refresh_url = parsed_json["refresh_url"] + return_url = parsed_json["return_url"] + url = parsed_json["url"] + new( + id: id, + created_at: created_at, + expires_at: expires_at, + recipient: recipient, + refresh_url: refresh_url, + return_url: return_url, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of OnboardingLinkResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.expires_at.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.") + Monite::Recipient.validate_raw(obj: obj.recipient) + obj.refresh_url.is_a?(String) != false || raise("Passed value for field obj.refresh_url is not the expected type, validation failed.") + obj.return_url.is_a?(String) != false || raise("Passed value for field obj.return_url is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_payment_methods_response.rb b/lib/monite/types/onboarding_payment_methods_response.rb new file mode 100644 index 0000000..64e353c --- /dev/null +++ b/lib/monite/types/onboarding_payment_methods_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "payment_method" +require "ostruct" +require "json" + +module Monite + class OnboardingPaymentMethodsResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingPaymentMethodsResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of OnboardingPaymentMethodsResponse + # + # @param json_object [String] + # @return [Monite::OnboardingPaymentMethodsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PaymentMethod.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of OnboardingPaymentMethodsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_requirements_error.rb b/lib/monite/types/onboarding_requirements_error.rb new file mode 100644 index 0000000..ff21878 --- /dev/null +++ b/lib/monite/types/onboarding_requirements_error.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OnboardingRequirementsError + # @return [String] + attr_reader :code + # @return [String] + attr_reader :reason + # @return [String] + attr_reader :requirement + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param code [String] + # @param reason [String] + # @param requirement [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingRequirementsError] + def initialize(code:, reason:, requirement:, additional_properties: nil) + @code = code + @reason = reason + @requirement = requirement + @additional_properties = additional_properties + @_field_set = { "code": code, "reason": reason, "requirement": requirement } + end +# Deserialize a JSON object to an instance of OnboardingRequirementsError + # + # @param json_object [String] + # @return [Monite::OnboardingRequirementsError] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + code = parsed_json["code"] + reason = parsed_json["reason"] + requirement = parsed_json["requirement"] + new( + code: code, + reason: reason, + requirement: requirement, + additional_properties: struct + ) + end +# Serialize an instance of OnboardingRequirementsError to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.code.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") + obj.reason.is_a?(String) != false || raise("Passed value for field obj.reason is not the expected type, validation failed.") + obj.requirement.is_a?(String) != false || raise("Passed value for field obj.requirement is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_requirements_response.rb b/lib/monite/types/onboarding_requirements_response.rb new file mode 100644 index 0000000..98d0aca --- /dev/null +++ b/lib/monite/types/onboarding_requirements_response.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +require_relative "account_disabled_reason" +require_relative "payment_requirements" +require_relative "requirements_error" +require_relative "verification_error" +require_relative "verification_status_enum" +require "ostruct" +require "json" + +module Monite + class OnboardingRequirementsResponse + # @return [Monite::AccountDisabledReason] + attr_reader :disabled_reason + # @return [Monite::PaymentRequirements] + attr_reader :requirements + # @return [Array] + attr_reader :requirements_errors + # @return [Array] + attr_reader :verification_errors + # @return [Monite::VerificationStatusEnum] + attr_reader :verification_status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param disabled_reason [Monite::AccountDisabledReason] + # @param requirements [Monite::PaymentRequirements] + # @param requirements_errors [Array] + # @param verification_errors [Array] + # @param verification_status [Monite::VerificationStatusEnum] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingRequirementsResponse] + def initialize(disabled_reason: OMIT, requirements:, requirements_errors:, verification_errors:, verification_status:, additional_properties: nil) + @disabled_reason = disabled_reason if disabled_reason != OMIT + @requirements = requirements + @requirements_errors = requirements_errors + @verification_errors = verification_errors + @verification_status = verification_status + @additional_properties = additional_properties + @_field_set = { "disabled_reason": disabled_reason, "requirements": requirements, "requirements_errors": requirements_errors, "verification_errors": verification_errors, "verification_status": verification_status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OnboardingRequirementsResponse + # + # @param json_object [String] + # @return [Monite::OnboardingRequirementsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + disabled_reason = parsed_json["disabled_reason"] + unless parsed_json["requirements"].nil? + requirements = parsed_json["requirements"].to_json + requirements = Monite::PaymentRequirements.from_json(json_object: requirements) + else + requirements = nil + end + requirements_errors = parsed_json["requirements_errors"]&.map do | item | + item = item.to_json + Monite::RequirementsError.from_json(json_object: item) +end + verification_errors = parsed_json["verification_errors"]&.map do | item | + item = item.to_json + Monite::VerificationError.from_json(json_object: item) +end + verification_status = parsed_json["verification_status"] + new( + disabled_reason: disabled_reason, + requirements: requirements, + requirements_errors: requirements_errors, + verification_errors: verification_errors, + verification_status: verification_status, + additional_properties: struct + ) + end +# Serialize an instance of OnboardingRequirementsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.disabled_reason&.is_a?(Monite::AccountDisabledReason) != false || raise("Passed value for field obj.disabled_reason is not the expected type, validation failed.") + Monite::PaymentRequirements.validate_raw(obj: obj.requirements) + obj.requirements_errors.is_a?(Array) != false || raise("Passed value for field obj.requirements_errors is not the expected type, validation failed.") + obj.verification_errors.is_a?(Array) != false || raise("Passed value for field obj.verification_errors is not the expected type, validation failed.") + obj.verification_status.is_a?(Monite::VerificationStatusEnum) != false || raise("Passed value for field obj.verification_status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_verification_error.rb b/lib/monite/types/onboarding_verification_error.rb new file mode 100644 index 0000000..7ca3331 --- /dev/null +++ b/lib/monite/types/onboarding_verification_error.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OnboardingVerificationError + # @return [String] + attr_reader :code + # @return [String] + attr_reader :details + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param code [String] + # @param details [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OnboardingVerificationError] + def initialize(code:, details:, additional_properties: nil) + @code = code + @details = details + @additional_properties = additional_properties + @_field_set = { "code": code, "details": details } + end +# Deserialize a JSON object to an instance of OnboardingVerificationError + # + # @param json_object [String] + # @return [Monite::OnboardingVerificationError] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + code = parsed_json["code"] + details = parsed_json["details"] + new( + code: code, + details: details, + additional_properties: struct + ) + end +# Serialize an instance of OnboardingVerificationError to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.code.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") + obj.details.is_a?(String) != false || raise("Passed value for field obj.details is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/onboarding_verification_status_enum.rb b/lib/monite/types/onboarding_verification_status_enum.rb new file mode 100644 index 0000000..6fc4a60 --- /dev/null +++ b/lib/monite/types/onboarding_verification_status_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class OnboardingVerificationStatusEnum + + ENABLED = "enabled" + DISABLED = "disabled" + PENDING = "pending" + + end +end \ No newline at end of file diff --git a/lib/monite/types/optional_individual_schema.rb b/lib/monite/types/optional_individual_schema.rb new file mode 100644 index 0000000..3e17619 --- /dev/null +++ b/lib/monite/types/optional_individual_schema.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema for metadata for updating an individual + class OptionalIndividualSchema + # @return [String] + attr_reader :date_of_birth + # @return [String] A first name of an individual + attr_reader :first_name + # @return [String] + attr_reader :id_number + # @return [String] A last name of an individual + attr_reader :last_name + # @return [String] The last four digits of the individual's Social Security number + attr_reader :ssn_last_4 + # @return [String] A title of an individual + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date_of_birth [String] + # @param first_name [String] A first name of an individual + # @param id_number [String] + # @param last_name [String] A last name of an individual + # @param ssn_last_4 [String] The last four digits of the individual's Social Security number + # @param title [String] A title of an individual + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OptionalIndividualSchema] + def initialize(date_of_birth: OMIT, first_name: OMIT, id_number: OMIT, last_name: OMIT, ssn_last_4: OMIT, title: OMIT, additional_properties: nil) + @date_of_birth = date_of_birth if date_of_birth != OMIT + @first_name = first_name if first_name != OMIT + @id_number = id_number if id_number != OMIT + @last_name = last_name if last_name != OMIT + @ssn_last_4 = ssn_last_4 if ssn_last_4 != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "date_of_birth": date_of_birth, "first_name": first_name, "id_number": id_number, "last_name": last_name, "ssn_last_4": ssn_last_4, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OptionalIndividualSchema + # + # @param json_object [String] + # @return [Monite::OptionalIndividualSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date_of_birth = parsed_json["date_of_birth"] + first_name = parsed_json["first_name"] + id_number = parsed_json["id_number"] + last_name = parsed_json["last_name"] + ssn_last_4 = parsed_json["ssn_last_4"] + title = parsed_json["title"] + new( + date_of_birth: date_of_birth, + first_name: first_name, + id_number: id_number, + last_name: last_name, + ssn_last_4: ssn_last_4, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of OptionalIndividualSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date_of_birth&.is_a?(String) != false || raise("Passed value for field obj.date_of_birth is not the expected type, validation failed.") + obj.first_name&.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.id_number&.is_a?(String) != false || raise("Passed value for field obj.id_number is not the expected type, validation failed.") + obj.last_name&.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.ssn_last_4&.is_a?(String) != false || raise("Passed value for field obj.ssn_last_4 is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/optional_organization_schema.rb b/lib/monite/types/optional_organization_schema.rb new file mode 100644 index 0000000..aaa25c1 --- /dev/null +++ b/lib/monite/types/optional_organization_schema.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +require_relative "entity_business_structure" +require "ostruct" +require "json" + +module Monite +# A schema contains metadata for updating an organization + class OptionalOrganizationSchema + # @return [Monite::EntityBusinessStructure] Business structure of the company + attr_reader :business_structure + # @return [Boolean] + attr_reader :directors_provided + # @return [Boolean] + attr_reader :executives_provided + # @return [String] A code which identifies uniquely a party of a transaction worldwide + attr_reader :legal_entity_id + # @return [String] A legal name of an organization + attr_reader :legal_name + # @return [Boolean] + attr_reader :owners_provided + # @return [Boolean] + attr_reader :representative_provided + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param business_structure [Monite::EntityBusinessStructure] Business structure of the company + # @param directors_provided [Boolean] + # @param executives_provided [Boolean] + # @param legal_entity_id [String] A code which identifies uniquely a party of a transaction worldwide + # @param legal_name [String] A legal name of an organization + # @param owners_provided [Boolean] + # @param representative_provided [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OptionalOrganizationSchema] + def initialize(business_structure: OMIT, directors_provided: OMIT, executives_provided: OMIT, legal_entity_id: OMIT, legal_name: OMIT, owners_provided: OMIT, representative_provided: OMIT, additional_properties: nil) + @business_structure = business_structure if business_structure != OMIT + @directors_provided = directors_provided if directors_provided != OMIT + @executives_provided = executives_provided if executives_provided != OMIT + @legal_entity_id = legal_entity_id if legal_entity_id != OMIT + @legal_name = legal_name if legal_name != OMIT + @owners_provided = owners_provided if owners_provided != OMIT + @representative_provided = representative_provided if representative_provided != OMIT + @additional_properties = additional_properties + @_field_set = { "business_structure": business_structure, "directors_provided": directors_provided, "executives_provided": executives_provided, "legal_entity_id": legal_entity_id, "legal_name": legal_name, "owners_provided": owners_provided, "representative_provided": representative_provided }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OptionalOrganizationSchema + # + # @param json_object [String] + # @return [Monite::OptionalOrganizationSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + business_structure = parsed_json["business_structure"] + directors_provided = parsed_json["directors_provided"] + executives_provided = parsed_json["executives_provided"] + legal_entity_id = parsed_json["legal_entity_id"] + legal_name = parsed_json["legal_name"] + owners_provided = parsed_json["owners_provided"] + representative_provided = parsed_json["representative_provided"] + new( + business_structure: business_structure, + directors_provided: directors_provided, + executives_provided: executives_provided, + legal_entity_id: legal_entity_id, + legal_name: legal_name, + owners_provided: owners_provided, + representative_provided: representative_provided, + additional_properties: struct + ) + end +# Serialize an instance of OptionalOrganizationSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.business_structure&.is_a?(Monite::EntityBusinessStructure) != false || raise("Passed value for field obj.business_structure is not the expected type, validation failed.") + obj.directors_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.directors_provided is not the expected type, validation failed.") + obj.executives_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.executives_provided is not the expected type, validation failed.") + obj.legal_entity_id&.is_a?(String) != false || raise("Passed value for field obj.legal_entity_id is not the expected type, validation failed.") + obj.legal_name&.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.owners_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.owners_provided is not the expected type, validation failed.") + obj.representative_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.representative_provided is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/optional_person_address_request.rb b/lib/monite/types/optional_person_address_request.rb new file mode 100644 index 0000000..ed7b55e --- /dev/null +++ b/lib/monite/types/optional_person_address_request.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class OptionalPersonAddressRequest + # @return [String] City, district, suburb, town, or village + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter country code (ISO 3166-1 alpha-2) + attr_reader :country + # @return [String] Address line 1 (e.g., street, PO Box, or company name) + attr_reader :line_1 + # @return [String] Address line 2 (e.g., apartment, suite, unit, or building) + attr_reader :line_2 + # @return [String] ZIP or postal code + attr_reader :postal_code + # @return [String] State, county, province, or region + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City, district, suburb, town, or village + # @param country [Monite::AllowedCountries] Two-letter country code (ISO 3166-1 alpha-2) + # @param line_1 [String] Address line 1 (e.g., street, PO Box, or company name) + # @param line_2 [String] Address line 2 (e.g., apartment, suite, unit, or building) + # @param postal_code [String] ZIP or postal code + # @param state [String] State, county, province, or region + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OptionalPersonAddressRequest] + def initialize(city: OMIT, country: OMIT, line_1: OMIT, line_2: OMIT, postal_code: OMIT, state: OMIT, additional_properties: nil) + @city = city if city != OMIT + @country = country if country != OMIT + @line_1 = line_1 if line_1 != OMIT + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code if postal_code != OMIT + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OptionalPersonAddressRequest + # + # @param json_object [String] + # @return [Monite::OptionalPersonAddressRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of OptionalPersonAddressRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1&.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code&.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/optional_person_relationship.rb b/lib/monite/types/optional_person_relationship.rb new file mode 100644 index 0000000..c4fc625 --- /dev/null +++ b/lib/monite/types/optional_person_relationship.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OptionalPersonRelationship + # @return [Boolean] Whether the person is a director of the account's legal entity + attr_reader :director + # @return [Boolean] Whether the person has significant responsibility to control, manage, or direct +# the organization + attr_reader :executive + # @return [Boolean] Whether the person is an owner of the account's legal entity + attr_reader :owner + # @return [Float] The percent owned by the person of the account's legal entity + attr_reader :percent_ownership + # @return [Boolean] Whether the person is authorized as the primary representative of the account + attr_reader :representative + # @return [String] The person's title (e.g., CEO, Support Engineer) + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param director [Boolean] Whether the person is a director of the account's legal entity + # @param executive [Boolean] Whether the person has significant responsibility to control, manage, or direct +# the organization + # @param owner [Boolean] Whether the person is an owner of the account's legal entity + # @param percent_ownership [Float] The percent owned by the person of the account's legal entity + # @param representative [Boolean] Whether the person is authorized as the primary representative of the account + # @param title [String] The person's title (e.g., CEO, Support Engineer) + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OptionalPersonRelationship] + def initialize(director: OMIT, executive: OMIT, owner: OMIT, percent_ownership: OMIT, representative: OMIT, title: OMIT, additional_properties: nil) + @director = director if director != OMIT + @executive = executive if executive != OMIT + @owner = owner if owner != OMIT + @percent_ownership = percent_ownership if percent_ownership != OMIT + @representative = representative if representative != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "director": director, "executive": executive, "owner": owner, "percent_ownership": percent_ownership, "representative": representative, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OptionalPersonRelationship + # + # @param json_object [String] + # @return [Monite::OptionalPersonRelationship] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + director = parsed_json["director"] + executive = parsed_json["executive"] + owner = parsed_json["owner"] + percent_ownership = parsed_json["percent_ownership"] + representative = parsed_json["representative"] + title = parsed_json["title"] + new( + director: director, + executive: executive, + owner: owner, + percent_ownership: percent_ownership, + representative: representative, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of OptionalPersonRelationship to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.director&.is_a?(Boolean) != false || raise("Passed value for field obj.director is not the expected type, validation failed.") + obj.executive&.is_a?(Boolean) != false || raise("Passed value for field obj.executive is not the expected type, validation failed.") + obj.owner&.is_a?(Boolean) != false || raise("Passed value for field obj.owner is not the expected type, validation failed.") + obj.percent_ownership&.is_a?(Float) != false || raise("Passed value for field obj.percent_ownership is not the expected type, validation failed.") + obj.representative&.is_a?(Boolean) != false || raise("Passed value for field obj.representative is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/order_enum.rb b/lib/monite/types/order_enum.rb new file mode 100644 index 0000000..5c8ab96 --- /dev/null +++ b/lib/monite/types/order_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class OrderEnum + + ASC = "asc" + DESC = "desc" + + end +end \ No newline at end of file diff --git a/lib/monite/types/organization_response_schema.rb b/lib/monite/types/organization_response_schema.rb new file mode 100644 index 0000000..5fef3c4 --- /dev/null +++ b/lib/monite/types/organization_response_schema.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +require_relative "entity_business_structure" +require "ostruct" +require "json" + +module Monite +# Contains data specific to entities of the `organization` type. + class OrganizationResponseSchema + # @return [Monite::EntityBusinessStructure] Business structure of the company + attr_reader :business_structure + # @return [Boolean] + attr_reader :directors_provided + # @return [Boolean] + attr_reader :executives_provided + # @return [String] A code which identifies uniquely a party of a transaction worldwide + attr_reader :legal_entity_id + # @return [String] The legal name of the organization. + attr_reader :legal_name + # @return [Boolean] + attr_reader :owners_provided + # @return [Boolean] + attr_reader :representative_provided + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param business_structure [Monite::EntityBusinessStructure] Business structure of the company + # @param directors_provided [Boolean] + # @param executives_provided [Boolean] + # @param legal_entity_id [String] A code which identifies uniquely a party of a transaction worldwide + # @param legal_name [String] The legal name of the organization. + # @param owners_provided [Boolean] + # @param representative_provided [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OrganizationResponseSchema] + def initialize(business_structure: OMIT, directors_provided: OMIT, executives_provided: OMIT, legal_entity_id: OMIT, legal_name:, owners_provided: OMIT, representative_provided: OMIT, additional_properties: nil) + @business_structure = business_structure if business_structure != OMIT + @directors_provided = directors_provided if directors_provided != OMIT + @executives_provided = executives_provided if executives_provided != OMIT + @legal_entity_id = legal_entity_id if legal_entity_id != OMIT + @legal_name = legal_name + @owners_provided = owners_provided if owners_provided != OMIT + @representative_provided = representative_provided if representative_provided != OMIT + @additional_properties = additional_properties + @_field_set = { "business_structure": business_structure, "directors_provided": directors_provided, "executives_provided": executives_provided, "legal_entity_id": legal_entity_id, "legal_name": legal_name, "owners_provided": owners_provided, "representative_provided": representative_provided }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OrganizationResponseSchema + # + # @param json_object [String] + # @return [Monite::OrganizationResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + business_structure = parsed_json["business_structure"] + directors_provided = parsed_json["directors_provided"] + executives_provided = parsed_json["executives_provided"] + legal_entity_id = parsed_json["legal_entity_id"] + legal_name = parsed_json["legal_name"] + owners_provided = parsed_json["owners_provided"] + representative_provided = parsed_json["representative_provided"] + new( + business_structure: business_structure, + directors_provided: directors_provided, + executives_provided: executives_provided, + legal_entity_id: legal_entity_id, + legal_name: legal_name, + owners_provided: owners_provided, + representative_provided: representative_provided, + additional_properties: struct + ) + end +# Serialize an instance of OrganizationResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.business_structure&.is_a?(Monite::EntityBusinessStructure) != false || raise("Passed value for field obj.business_structure is not the expected type, validation failed.") + obj.directors_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.directors_provided is not the expected type, validation failed.") + obj.executives_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.executives_provided is not the expected type, validation failed.") + obj.legal_entity_id&.is_a?(String) != false || raise("Passed value for field obj.legal_entity_id is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.owners_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.owners_provided is not the expected type, validation failed.") + obj.representative_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.representative_provided is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/organization_schema.rb b/lib/monite/types/organization_schema.rb new file mode 100644 index 0000000..6d78a0b --- /dev/null +++ b/lib/monite/types/organization_schema.rb @@ -0,0 +1,104 @@ +# frozen_string_literal: true +require_relative "entity_business_structure" +require "ostruct" +require "json" + +module Monite +# A schema contains metadata for an organization + class OrganizationSchema + # @return [Monite::EntityBusinessStructure] Business structure of the company + attr_reader :business_structure + # @return [Boolean] + attr_reader :directors_provided + # @return [Boolean] + attr_reader :executives_provided + # @return [String] A code which identifies uniquely a party of a transaction worldwide + attr_reader :legal_entity_id + # @return [String] The legal name of the organization. If this organization will use Monite payment +# rails, this name must be up to 100 characters long, otherwise it can be up to +# 255 characters long. + attr_reader :legal_name + # @return [Boolean] + attr_reader :owners_provided + # @return [Boolean] + attr_reader :representative_provided + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param business_structure [Monite::EntityBusinessStructure] Business structure of the company + # @param directors_provided [Boolean] + # @param executives_provided [Boolean] + # @param legal_entity_id [String] A code which identifies uniquely a party of a transaction worldwide + # @param legal_name [String] The legal name of the organization. If this organization will use Monite payment +# rails, this name must be up to 100 characters long, otherwise it can be up to +# 255 characters long. + # @param owners_provided [Boolean] + # @param representative_provided [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OrganizationSchema] + def initialize(business_structure: OMIT, directors_provided: OMIT, executives_provided: OMIT, legal_entity_id: OMIT, legal_name:, owners_provided: OMIT, representative_provided: OMIT, additional_properties: nil) + @business_structure = business_structure if business_structure != OMIT + @directors_provided = directors_provided if directors_provided != OMIT + @executives_provided = executives_provided if executives_provided != OMIT + @legal_entity_id = legal_entity_id if legal_entity_id != OMIT + @legal_name = legal_name + @owners_provided = owners_provided if owners_provided != OMIT + @representative_provided = representative_provided if representative_provided != OMIT + @additional_properties = additional_properties + @_field_set = { "business_structure": business_structure, "directors_provided": directors_provided, "executives_provided": executives_provided, "legal_entity_id": legal_entity_id, "legal_name": legal_name, "owners_provided": owners_provided, "representative_provided": representative_provided }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OrganizationSchema + # + # @param json_object [String] + # @return [Monite::OrganizationSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + business_structure = parsed_json["business_structure"] + directors_provided = parsed_json["directors_provided"] + executives_provided = parsed_json["executives_provided"] + legal_entity_id = parsed_json["legal_entity_id"] + legal_name = parsed_json["legal_name"] + owners_provided = parsed_json["owners_provided"] + representative_provided = parsed_json["representative_provided"] + new( + business_structure: business_structure, + directors_provided: directors_provided, + executives_provided: executives_provided, + legal_entity_id: legal_entity_id, + legal_name: legal_name, + owners_provided: owners_provided, + representative_provided: representative_provided, + additional_properties: struct + ) + end +# Serialize an instance of OrganizationSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.business_structure&.is_a?(Monite::EntityBusinessStructure) != false || raise("Passed value for field obj.business_structure is not the expected type, validation failed.") + obj.directors_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.directors_provided is not the expected type, validation failed.") + obj.executives_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.executives_provided is not the expected type, validation failed.") + obj.legal_entity_id&.is_a?(String) != false || raise("Passed value for field obj.legal_entity_id is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.owners_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.owners_provided is not the expected type, validation failed.") + obj.representative_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.representative_provided is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/overdue_reminder_response.rb b/lib/monite/types/overdue_reminder_response.rb new file mode 100644 index 0000000..135776b --- /dev/null +++ b/lib/monite/types/overdue_reminder_response.rb @@ -0,0 +1,115 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "recipients" +require_relative "overdue_reminder_term" +require "ostruct" +require "json" + +module Monite + class OverdueReminderResponse + # @return [String] + attr_reader :id + # @return [DateTime] Time at which the OverdueReminder was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the OverdueReminder was last updated. Timestamps follow the ISO +# 8601 standard. + attr_reader :updated_at + # @return [String] + attr_reader :name + # @return [Monite::Recipients] + attr_reader :recipients + # @return [Array] Overdue reminder terms to send for payment + attr_reader :terms + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Time at which the OverdueReminder was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the OverdueReminder was last updated. Timestamps follow the ISO +# 8601 standard. + # @param name [String] + # @param recipients [Monite::Recipients] + # @param terms [Array] Overdue reminder terms to send for payment + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OverdueReminderResponse] + def initialize(id:, created_at:, updated_at:, name:, recipients: OMIT, terms: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @name = name + @recipients = recipients if recipients != OMIT + @terms = terms if terms != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "name": name, "recipients": recipients, "terms": terms }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OverdueReminderResponse + # + # @param json_object [String] + # @return [Monite::OverdueReminderResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + name = parsed_json["name"] + unless parsed_json["recipients"].nil? + recipients = parsed_json["recipients"].to_json + recipients = Monite::Recipients.from_json(json_object: recipients) + else + recipients = nil + end + terms = parsed_json["terms"]&.map do | item | + item = item.to_json + Monite::OverdueReminderTerm.from_json(json_object: item) +end + new( + id: id, + created_at: created_at, + updated_at: updated_at, + name: name, + recipients: recipients, + terms: terms, + additional_properties: struct + ) + end +# Serialize an instance of OverdueReminderResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.recipients.nil? || Monite::Recipients.validate_raw(obj: obj.recipients) + obj.terms&.is_a?(Array) != false || raise("Passed value for field obj.terms is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/overdue_reminder_term.rb b/lib/monite/types/overdue_reminder_term.rb new file mode 100644 index 0000000..b9a03c1 --- /dev/null +++ b/lib/monite/types/overdue_reminder_term.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class OverdueReminderTerm + # @return [String] + attr_reader :body + # @return [Integer] + attr_reader :days_after + # @return [String] + attr_reader :subject + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param body [String] + # @param days_after [Integer] + # @param subject [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OverdueReminderTerm] + def initialize(body:, days_after:, subject:, additional_properties: nil) + @body = body + @days_after = days_after + @subject = subject + @additional_properties = additional_properties + @_field_set = { "body": body, "days_after": days_after, "subject": subject } + end +# Deserialize a JSON object to an instance of OverdueReminderTerm + # + # @param json_object [String] + # @return [Monite::OverdueReminderTerm] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + body = parsed_json["body"] + days_after = parsed_json["days_after"] + subject = parsed_json["subject"] + new( + body: body, + days_after: days_after, + subject: subject, + additional_properties: struct + ) + end +# Serialize an instance of OverdueReminderTerm to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body.is_a?(String) != false || raise("Passed value for field obj.body is not the expected type, validation failed.") + obj.days_after.is_a?(Integer) != false || raise("Passed value for field obj.days_after is not the expected type, validation failed.") + obj.subject.is_a?(String) != false || raise("Passed value for field obj.subject is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ownership_declaration_input.rb b/lib/monite/types/ownership_declaration_input.rb new file mode 100644 index 0000000..3be3726 --- /dev/null +++ b/lib/monite/types/ownership_declaration_input.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class OwnershipDeclarationInput + # @return [DateTime] The date and time (in the ISO 8601 format) when the beneficial owner attestation +# was made. + attr_reader :date + # @return [String] The IP address from which the beneficial owner attestation was made. If omitted +# or set to `null` in the request, the IP address is inferred from the request +# origin or the `X-Forwarded-For` request header. + attr_reader :ip + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date [DateTime] The date and time (in the ISO 8601 format) when the beneficial owner attestation +# was made. + # @param ip [String] The IP address from which the beneficial owner attestation was made. If omitted +# or set to `null` in the request, the IP address is inferred from the request +# origin or the `X-Forwarded-For` request header. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OwnershipDeclarationInput] + def initialize(date: OMIT, ip: OMIT, additional_properties: nil) + @date = date if date != OMIT + @ip = ip if ip != OMIT + @additional_properties = additional_properties + @_field_set = { "date": date, "ip": ip }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OwnershipDeclarationInput + # + # @param json_object [String] + # @return [Monite::OwnershipDeclarationInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date = unless parsed_json["date"].nil? + DateTime.parse(parsed_json["date"]) +else + nil +end + ip = parsed_json["ip"] + new( + date: date, + ip: ip, + additional_properties: struct + ) + end +# Serialize an instance of OwnershipDeclarationInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date&.is_a?(DateTime) != false || raise("Passed value for field obj.date is not the expected type, validation failed.") + obj.ip&.is_a?(String) != false || raise("Passed value for field obj.ip is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/ownership_declaration_output.rb b/lib/monite/types/ownership_declaration_output.rb new file mode 100644 index 0000000..3fcbd97 --- /dev/null +++ b/lib/monite/types/ownership_declaration_output.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class OwnershipDeclarationOutput + # @return [DateTime] The date and time (in the ISO 8601 format) when the beneficial owner attestation +# was made. + attr_reader :date + # @return [String] The IP address from which the beneficial owner attestation was made. If omitted +# or set to `null` in the request, the IP address is inferred from the request +# origin or the `X-Forwarded-For` request header. + attr_reader :ip + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date [DateTime] The date and time (in the ISO 8601 format) when the beneficial owner attestation +# was made. + # @param ip [String] The IP address from which the beneficial owner attestation was made. If omitted +# or set to `null` in the request, the IP address is inferred from the request +# origin or the `X-Forwarded-For` request header. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::OwnershipDeclarationOutput] + def initialize(date: OMIT, ip: OMIT, additional_properties: nil) + @date = date if date != OMIT + @ip = ip if ip != OMIT + @additional_properties = additional_properties + @_field_set = { "date": date, "ip": ip }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of OwnershipDeclarationOutput + # + # @param json_object [String] + # @return [Monite::OwnershipDeclarationOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date = unless parsed_json["date"].nil? + DateTime.parse(parsed_json["date"]) +else + nil +end + ip = parsed_json["ip"] + new( + date: date, + ip: ip, + additional_properties: struct + ) + end +# Serialize an instance of OwnershipDeclarationOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date&.is_a?(DateTime) != false || raise("Passed value for field obj.date is not the expected type, validation failed.") + obj.ip&.is_a?(String) != false || raise("Passed value for field obj.ip is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/page_schema.rb b/lib/monite/types/page_schema.rb new file mode 100644 index 0000000..f453269 --- /dev/null +++ b/lib/monite/types/page_schema.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# When a PDF document is uploaded to Monite, it extracts individual pages from the +# document +# and saves them as PNG images. This object contains the image and metadata of a +# single page. + class PageSchema + # @return [String] A unique ID of the image. + attr_reader :id + # @return [String] The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) +# of the image. + attr_reader :mimetype + # @return [Integer] The page number in the PDF document, from 0. + attr_reader :number + # @return [Integer] Image file size, in bytes. + attr_reader :size + # @return [String] The URL to download the image. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of the image. + # @param mimetype [String] The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) +# of the image. + # @param number [Integer] The page number in the PDF document, from 0. + # @param size [Integer] Image file size, in bytes. + # @param url [String] The URL to download the image. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PageSchema] + def initialize(id:, mimetype:, number:, size:, url:, additional_properties: nil) + @id = id + @mimetype = mimetype + @number = number + @size = size + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "mimetype": mimetype, "number": number, "size": size, "url": url } + end +# Deserialize a JSON object to an instance of PageSchema + # + # @param json_object [String] + # @return [Monite::PageSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + mimetype = parsed_json["mimetype"] + number = parsed_json["number"] + size = parsed_json["size"] + url = parsed_json["url"] + new( + id: id, + mimetype: mimetype, + number: number, + size: size, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of PageSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.number.is_a?(Integer) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/page_schema_2.rb b/lib/monite/types/page_schema_2.rb new file mode 100644 index 0000000..b40b662 --- /dev/null +++ b/lib/monite/types/page_schema_2.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# When a PDF document is uploaded to Monite, it extracts individual pages from the +# document +# and saves them as PNG images. This object contains the image and metadata of a +# single page. + class PageSchema2 + # @return [String] A unique ID of the image. + attr_reader :id + # @return [String] The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) +# of the image. + attr_reader :mimetype + # @return [Integer] Image file size, in bytes. + attr_reader :size + # @return [Integer] The page number in the PDF document, from 0. + attr_reader :number + # @return [String] The URL to download the image. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of the image. + # @param mimetype [String] The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) +# of the image. + # @param size [Integer] Image file size, in bytes. + # @param number [Integer] The page number in the PDF document, from 0. + # @param url [String] The URL to download the image. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PageSchema2] + def initialize(id:, mimetype:, size:, number:, url:, additional_properties: nil) + @id = id + @mimetype = mimetype + @size = size + @number = number + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "mimetype": mimetype, "size": size, "number": number, "url": url } + end +# Deserialize a JSON object to an instance of PageSchema2 + # + # @param json_object [String] + # @return [Monite::PageSchema2] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + mimetype = parsed_json["mimetype"] + size = parsed_json["size"] + number = parsed_json["number"] + url = parsed_json["url"] + new( + id: id, + mimetype: mimetype, + size: size, + number: number, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of PageSchema2 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.number.is_a?(Integer) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/page_schema_3.rb b/lib/monite/types/page_schema_3.rb new file mode 100644 index 0000000..5902c82 --- /dev/null +++ b/lib/monite/types/page_schema_3.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# When a PDF document is uploaded to Monite, it extracts individual pages from the +# document +# and saves them as PNG images. This object contains the image and metadata of a +# single page. + class PageSchema3 + # @return [String] A unique ID of the image. + attr_reader :id + # @return [String] The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) +# of the image. + attr_reader :mimetype + # @return [Integer] The page number in the PDF document, from 0. + attr_reader :number + # @return [Integer] Image file size, in bytes. + attr_reader :size + # @return [String] The URL to download the image. + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of the image. + # @param mimetype [String] The [media type](https://developer.mozilla.org/en-US/docs/Web/HTTP/MIME_types) +# of the image. + # @param number [Integer] The page number in the PDF document, from 0. + # @param size [Integer] Image file size, in bytes. + # @param url [String] The URL to download the image. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PageSchema3] + def initialize(id:, mimetype:, number:, size:, url:, additional_properties: nil) + @id = id + @mimetype = mimetype + @number = number + @size = size + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "mimetype": mimetype, "number": number, "size": size, "url": url } + end +# Deserialize a JSON object to an instance of PageSchema3 + # + # @param json_object [String] + # @return [Monite::PageSchema3] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + mimetype = parsed_json["mimetype"] + number = parsed_json["number"] + size = parsed_json["size"] + url = parsed_json["url"] + new( + id: id, + mimetype: mimetype, + number: number, + size: size, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of PageSchema3 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.mimetype.is_a?(String) != false || raise("Passed value for field obj.mimetype is not the expected type, validation failed.") + obj.number.is_a?(Integer) != false || raise("Passed value for field obj.number is not the expected type, validation failed.") + obj.size.is_a?(Integer) != false || raise("Passed value for field obj.size is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/partner_metadata.rb b/lib/monite/types/partner_metadata.rb new file mode 100644 index 0000000..457f1ec --- /dev/null +++ b/lib/monite/types/partner_metadata.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PartnerMetadata + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :metadata + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param metadata [Hash{String => Object}] Metadata for partner needs + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PartnerMetadata] + def initialize(metadata:, additional_properties: nil) + @metadata = metadata + @additional_properties = additional_properties + @_field_set = { "metadata": metadata } + end +# Deserialize a JSON object to an instance of PartnerMetadata + # + # @param json_object [String] + # @return [Monite::PartnerMetadata] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + metadata = parsed_json["metadata"] + new(metadata: metadata, additional_properties: struct) + end +# Serialize an instance of PartnerMetadata to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.metadata.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/partner_metadata_response.rb b/lib/monite/types/partner_metadata_response.rb new file mode 100644 index 0000000..a6a24bc --- /dev/null +++ b/lib/monite/types/partner_metadata_response.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PartnerMetadataResponse + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :metadata + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param metadata [Hash{String => Object}] Metadata for partner needs + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PartnerMetadataResponse] + def initialize(metadata: OMIT, additional_properties: nil) + @metadata = metadata if metadata != OMIT + @additional_properties = additional_properties + @_field_set = { "metadata": metadata }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PartnerMetadataResponse + # + # @param json_object [String] + # @return [Monite::PartnerMetadataResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + metadata = parsed_json["metadata"] + new(metadata: metadata, additional_properties: struct) + end +# Serialize an instance of PartnerMetadataResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.metadata&.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/partner_project_settings_payload_output.rb b/lib/monite/types/partner_project_settings_payload_output.rb new file mode 100644 index 0000000..4569798 --- /dev/null +++ b/lib/monite/types/partner_project_settings_payload_output.rb @@ -0,0 +1,154 @@ +# frozen_string_literal: true +require_relative "currency_settings_output" +require_relative "payable_settings" +require_relative "receivable_settings" +require_relative "mail_settings" +require_relative "unit" +require_relative "payments_settings_output" +require_relative "api_version" +require "ostruct" +require "json" + +module Monite + class PartnerProjectSettingsPayloadOutput + # @return [Monite::CurrencySettingsOutput] Custom currency exchange rates. + attr_reader :currency + # @return [Monite::PayableSettings] Settings for the payables module. + attr_reader :payable + # @return [Monite::ReceivableSettings] Settings for the receivables module. + attr_reader :receivable + # @return [Monite::MailSettings] Settings for email and mailboxes. + attr_reader :mail + # @return [Array] Commercial conditions for receivables. + attr_reader :commercial_conditions + # @return [Array] Measurement units. + attr_reader :units + # @return [String] + attr_reader :website + # @return [Hash{String => Object}] A default role to provision upon new entity creation. + attr_reader :default_role + # @return [Monite::PaymentsSettingsOutput] Settings for the payments module. + attr_reader :payments + # @return [Monite::ApiVersion] Default API version for partner. + attr_reader :api_version + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param currency [Monite::CurrencySettingsOutput] Custom currency exchange rates. + # @param payable [Monite::PayableSettings] Settings for the payables module. + # @param receivable [Monite::ReceivableSettings] Settings for the receivables module. + # @param mail [Monite::MailSettings] Settings for email and mailboxes. + # @param commercial_conditions [Array] Commercial conditions for receivables. + # @param units [Array] Measurement units. + # @param website [String] + # @param default_role [Hash{String => Object}] A default role to provision upon new entity creation. + # @param payments [Monite::PaymentsSettingsOutput] Settings for the payments module. + # @param api_version [Monite::ApiVersion] Default API version for partner. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PartnerProjectSettingsPayloadOutput] + def initialize(currency: OMIT, payable: OMIT, receivable: OMIT, mail: OMIT, commercial_conditions: OMIT, units: OMIT, website: OMIT, default_role: OMIT, payments: OMIT, api_version: OMIT, additional_properties: nil) + @currency = currency if currency != OMIT + @payable = payable if payable != OMIT + @receivable = receivable if receivable != OMIT + @mail = mail if mail != OMIT + @commercial_conditions = commercial_conditions if commercial_conditions != OMIT + @units = units if units != OMIT + @website = website if website != OMIT + @default_role = default_role if default_role != OMIT + @payments = payments if payments != OMIT + @api_version = api_version if api_version != OMIT + @additional_properties = additional_properties + @_field_set = { "currency": currency, "payable": payable, "receivable": receivable, "mail": mail, "commercial_conditions": commercial_conditions, "units": units, "website": website, "default_role": default_role, "payments": payments, "api_version": api_version }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PartnerProjectSettingsPayloadOutput + # + # @param json_object [String] + # @return [Monite::PartnerProjectSettingsPayloadOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["currency"].nil? + currency = parsed_json["currency"].to_json + currency = Monite::CurrencySettingsOutput.from_json(json_object: currency) + else + currency = nil + end + unless parsed_json["payable"].nil? + payable = parsed_json["payable"].to_json + payable = Monite::PayableSettings.from_json(json_object: payable) + else + payable = nil + end + unless parsed_json["receivable"].nil? + receivable = parsed_json["receivable"].to_json + receivable = Monite::ReceivableSettings.from_json(json_object: receivable) + else + receivable = nil + end + unless parsed_json["mail"].nil? + mail = parsed_json["mail"].to_json + mail = Monite::MailSettings.from_json(json_object: mail) + else + mail = nil + end + commercial_conditions = parsed_json["commercial_conditions"] + units = parsed_json["units"]&.map do | item | + item = item.to_json + Monite::Unit.from_json(json_object: item) +end + website = parsed_json["website"] + default_role = parsed_json["default_role"] + unless parsed_json["payments"].nil? + payments = parsed_json["payments"].to_json + payments = Monite::PaymentsSettingsOutput.from_json(json_object: payments) + else + payments = nil + end + api_version = parsed_json["api_version"] + new( + currency: currency, + payable: payable, + receivable: receivable, + mail: mail, + commercial_conditions: commercial_conditions, + units: units, + website: website, + default_role: default_role, + payments: payments, + api_version: api_version, + additional_properties: struct + ) + end +# Serialize an instance of PartnerProjectSettingsPayloadOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.currency.nil? || Monite::CurrencySettingsOutput.validate_raw(obj: obj.currency) + obj.payable.nil? || Monite::PayableSettings.validate_raw(obj: obj.payable) + obj.receivable.nil? || Monite::ReceivableSettings.validate_raw(obj: obj.receivable) + obj.mail.nil? || Monite::MailSettings.validate_raw(obj: obj.mail) + obj.commercial_conditions&.is_a?(Array) != false || raise("Passed value for field obj.commercial_conditions is not the expected type, validation failed.") + obj.units&.is_a?(Array) != false || raise("Passed value for field obj.units is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + obj.default_role&.is_a?(Hash) != false || raise("Passed value for field obj.default_role is not the expected type, validation failed.") + obj.payments.nil? || Monite::PaymentsSettingsOutput.validate_raw(obj: obj.payments) + obj.api_version&.is_a?(Monite::ApiVersion) != false || raise("Passed value for field obj.api_version is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_action_enum.rb b/lib/monite/types/payable_action_enum.rb new file mode 100644 index 0000000..8a2c285 --- /dev/null +++ b/lib/monite/types/payable_action_enum.rb @@ -0,0 +1,18 @@ +# frozen_string_literal: true + +module Monite + class PayableActionEnum + + CREATE = "create" + READ = "read" + UPDATE = "update" + DELETE = "delete" + PAY = "pay" + APPROVE = "approve" + CANCEL = "cancel" + SUBMIT = "submit" + CREATE_FROM_MAIL = "create_from_mail" + REOPEN = "reopen" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_action_schema.rb b/lib/monite/types/payable_action_schema.rb new file mode 100644 index 0000000..e8b4886 --- /dev/null +++ b/lib/monite/types/payable_action_schema.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true +require_relative "payable_action_enum" +require_relative "permission_enum" +require "ostruct" +require "json" + +module Monite + class PayableActionSchema + # @return [Monite::PayableActionEnum] Action name + attr_reader :action_name + # @return [Monite::PermissionEnum] Permission type + attr_reader :permission + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param action_name [Monite::PayableActionEnum] Action name + # @param permission [Monite::PermissionEnum] Permission type + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableActionSchema] + def initialize(action_name: OMIT, permission: OMIT, additional_properties: nil) + @action_name = action_name if action_name != OMIT + @permission = permission if permission != OMIT + @additional_properties = additional_properties + @_field_set = { "action_name": action_name, "permission": permission }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableActionSchema + # + # @param json_object [String] + # @return [Monite::PayableActionSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + action_name = parsed_json["action_name"] + permission = parsed_json["permission"] + new( + action_name: action_name, + permission: permission, + additional_properties: struct + ) + end +# Serialize an instance of PayableActionSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.action_name&.is_a?(Monite::PayableActionEnum) != false || raise("Passed value for field obj.action_name is not the expected type, validation failed.") + obj.permission&.is_a?(Monite::PermissionEnum) != false || raise("Passed value for field obj.permission is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_aggregated_data_response.rb b/lib/monite/types/payable_aggregated_data_response.rb new file mode 100644 index 0000000..09eff48 --- /dev/null +++ b/lib/monite/types/payable_aggregated_data_response.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require_relative "payable_aggregated_item" +require "ostruct" +require "json" + +module Monite + class PayableAggregatedDataResponse + # @return [Integer] The total count of payables across all statuses. + attr_reader :count + # @return [Array] A list of aggregated items, each representing a status with its associated sum +# of the amount field and count. + attr_reader :data + # @return [Integer] The total sum of the amount field for all payables across all statuses. + attr_reader :sum_total_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param count [Integer] The total count of payables across all statuses. + # @param data [Array] A list of aggregated items, each representing a status with its associated sum +# of the amount field and count. + # @param sum_total_amount [Integer] The total sum of the amount field for all payables across all statuses. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableAggregatedDataResponse] + def initialize(count:, data:, sum_total_amount:, additional_properties: nil) + @count = count + @data = data + @sum_total_amount = sum_total_amount + @additional_properties = additional_properties + @_field_set = { "count": count, "data": data, "sum_total_amount": sum_total_amount } + end +# Deserialize a JSON object to an instance of PayableAggregatedDataResponse + # + # @param json_object [String] + # @return [Monite::PayableAggregatedDataResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + count = parsed_json["count"] + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PayableAggregatedItem.from_json(json_object: item) +end + sum_total_amount = parsed_json["sum_total_amount"] + new( + count: count, + data: data, + sum_total_amount: sum_total_amount, + additional_properties: struct + ) + end +# Serialize an instance of PayableAggregatedDataResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.count.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.") + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.sum_total_amount.is_a?(Integer) != false || raise("Passed value for field obj.sum_total_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_aggregated_item.rb b/lib/monite/types/payable_aggregated_item.rb new file mode 100644 index 0000000..e3700e2 --- /dev/null +++ b/lib/monite/types/payable_aggregated_item.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true +require_relative "payable_state_enum" +require "ostruct" +require "json" + +module Monite + class PayableAggregatedItem + # @return [Integer] The total count of payables with this specific status. + attr_reader :count + # @return [Monite::PayableStateEnum] The status of the payable (e.g., paid, draft, etc.). + attr_reader :status + # @return [Integer] The total sum of the amount field for all payables with this specific status. + attr_reader :sum_total_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param count [Integer] The total count of payables with this specific status. + # @param status [Monite::PayableStateEnum] The status of the payable (e.g., paid, draft, etc.). + # @param sum_total_amount [Integer] The total sum of the amount field for all payables with this specific status. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableAggregatedItem] + def initialize(count:, status:, sum_total_amount:, additional_properties: nil) + @count = count + @status = status + @sum_total_amount = sum_total_amount + @additional_properties = additional_properties + @_field_set = { "count": count, "status": status, "sum_total_amount": sum_total_amount } + end +# Deserialize a JSON object to an instance of PayableAggregatedItem + # + # @param json_object [String] + # @return [Monite::PayableAggregatedItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + count = parsed_json["count"] + status = parsed_json["status"] + sum_total_amount = parsed_json["sum_total_amount"] + new( + count: count, + status: status, + sum_total_amount: sum_total_amount, + additional_properties: struct + ) + end +# Serialize an instance of PayableAggregatedItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.count.is_a?(Integer) != false || raise("Passed value for field obj.count is not the expected type, validation failed.") + obj.status.is_a?(Monite::PayableStateEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.sum_total_amount.is_a?(Integer) != false || raise("Passed value for field obj.sum_total_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_analytics_response.rb b/lib/monite/types/payable_analytics_response.rb new file mode 100644 index 0000000..8b0afa7 --- /dev/null +++ b/lib/monite/types/payable_analytics_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "analytics_data_point" +require "ostruct" +require "json" + +module Monite + class PayableAnalyticsResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableAnalyticsResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of PayableAnalyticsResponse + # + # @param json_object [String] + # @return [Monite::PayableAnalyticsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::AnalyticsDataPoint.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of PayableAnalyticsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_credit_note_data.rb b/lib/monite/types/payable_credit_note_data.rb new file mode 100644 index 0000000..04da915 --- /dev/null +++ b/lib/monite/types/payable_credit_note_data.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PayableCreditNoteData + # @return [String] The unique identifier of the credit note. + attr_reader :id + # @return [String] The credit note's unique document number. + attr_reader :document_id + # @return [String] The date when the credit note was issued, in the YYYY-MM-DD format + attr_reader :issued_at + # @return [String] The current status of the credit note in its lifecycle + attr_reader :status + # @return [Integer] Credit note total amount. + attr_reader :total_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] The unique identifier of the credit note. + # @param document_id [String] The credit note's unique document number. + # @param issued_at [String] The date when the credit note was issued, in the YYYY-MM-DD format + # @param status [String] The current status of the credit note in its lifecycle + # @param total_amount [Integer] Credit note total amount. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableCreditNoteData] + def initialize(id:, document_id: OMIT, issued_at: OMIT, status:, total_amount: OMIT, additional_properties: nil) + @id = id + @document_id = document_id if document_id != OMIT + @issued_at = issued_at if issued_at != OMIT + @status = status + @total_amount = total_amount if total_amount != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "document_id": document_id, "issued_at": issued_at, "status": status, "total_amount": total_amount }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableCreditNoteData + # + # @param json_object [String] + # @return [Monite::PayableCreditNoteData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + document_id = parsed_json["document_id"] + issued_at = parsed_json["issued_at"] + status = parsed_json["status"] + total_amount = parsed_json["total_amount"] + new( + id: id, + document_id: document_id, + issued_at: issued_at, + status: status, + total_amount: total_amount, + additional_properties: struct + ) + end +# Serialize an instance of PayableCreditNoteData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.issued_at&.is_a?(String) != false || raise("Passed value for field obj.issued_at is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_cursor_fields.rb b/lib/monite/types/payable_cursor_fields.rb new file mode 100644 index 0000000..9f9d82a --- /dev/null +++ b/lib/monite/types/payable_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PayableCursorFields + + ID = "id" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_dimension_enum.rb b/lib/monite/types/payable_dimension_enum.rb new file mode 100644 index 0000000..6021172 --- /dev/null +++ b/lib/monite/types/payable_dimension_enum.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Monite + class PayableDimensionEnum + + CREATED_AT = "created_at" + STATUS = "status" + COUNTERPART_ID = "counterpart_id" + CURRENCY = "currency" + ISSUED_AT = "issued_at" + DUE_DATE = "due_date" + PROJECT_ID = "project_id" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_entity_address_schema.rb b/lib/monite/types/payable_entity_address_schema.rb new file mode 100644 index 0000000..2352472 --- /dev/null +++ b/lib/monite/types/payable_entity_address_schema.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# A schema represents address info of the entity + class PayableEntityAddressSchema + # @return [String] A city (a full name) where the entity is registered + attr_reader :city + # @return [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + attr_reader :country + # @return [String] A street where the entity is registered + attr_reader :line_1 + # @return [String] An alternative street used by the entity + attr_reader :line_2 + # @return [String] A postal code of the address where the entity is registered + attr_reader :postal_code + # @return [String] A state in a country where the entity is registered + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] A city (a full name) where the entity is registered + # @param country [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + # @param line_1 [String] A street where the entity is registered + # @param line_2 [String] An alternative street used by the entity + # @param postal_code [String] A postal code of the address where the entity is registered + # @param state [String] A state in a country where the entity is registered + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableEntityAddressSchema] + def initialize(city:, country: OMIT, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country if country != OMIT + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableEntityAddressSchema + # + # @param json_object [String] + # @return [Monite::PayableEntityAddressSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of PayableEntityAddressSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_entity_individual_response.rb b/lib/monite/types/payable_entity_individual_response.rb new file mode 100644 index 0000000..ace4cef --- /dev/null +++ b/lib/monite/types/payable_entity_individual_response.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "payable_entity_address_schema" +require_relative "payable_individual_schema" +require_relative "file_schema_4" +require_relative "status_enum" +require "ostruct" +require "json" + +module Monite +# A base for an entity response schema + class PayableEntityIndividualResponse + # @return [String] UUID entity ID + attr_reader :id + # @return [DateTime] UTC datetime + attr_reader :created_at + # @return [DateTime] UTC datetime + attr_reader :updated_at + # @return [Monite::PayableEntityAddressSchema] + attr_reader :address + # @return [String] An official email address of the entity + attr_reader :email + # @return [Monite::PayableIndividualSchema] A set of metadata describing an individual + attr_reader :individual + # @return [Monite::FileSchema4] A logo image of the entity + attr_reader :logo + # @return [String] A phone number of the entity + attr_reader :phone + # @return [Monite::StatusEnum] record status, 'active' by default + attr_reader :status + # @return [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] UUID entity ID + # @param created_at [DateTime] UTC datetime + # @param updated_at [DateTime] UTC datetime + # @param address [Monite::PayableEntityAddressSchema] + # @param email [String] An official email address of the entity + # @param individual [Monite::PayableIndividualSchema] A set of metadata describing an individual + # @param logo [Monite::FileSchema4] A logo image of the entity + # @param phone [String] A phone number of the entity + # @param status [Monite::StatusEnum] record status, 'active' by default + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableEntityIndividualResponse] + def initialize(id:, created_at:, updated_at:, address:, email: OMIT, individual:, logo: OMIT, phone: OMIT, status:, tax_id: OMIT, website: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @address = address + @email = email if email != OMIT + @individual = individual + @logo = logo if logo != OMIT + @phone = phone if phone != OMIT + @status = status + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "address": address, "email": email, "individual": individual, "logo": logo, "phone": phone, "status": status, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableEntityIndividualResponse + # + # @param json_object [String] + # @return [Monite::PayableEntityIndividualResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::PayableEntityAddressSchema.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::PayableIndividualSchema.from_json(json_object: individual) + else + individual = nil + end + unless parsed_json["logo"].nil? + logo = parsed_json["logo"].to_json + logo = Monite::FileSchema4.from_json(json_object: logo) + else + logo = nil + end + phone = parsed_json["phone"] + status = parsed_json["status"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + address: address, + email: email, + individual: individual, + logo: logo, + phone: phone, + status: status, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of PayableEntityIndividualResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + Monite::PayableEntityAddressSchema.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + Monite::PayableIndividualSchema.validate_raw(obj: obj.individual) + obj.logo.nil? || Monite::FileSchema4.validate_raw(obj: obj.logo) + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.status.is_a?(Monite::StatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_entity_organization_response.rb b/lib/monite/types/payable_entity_organization_response.rb new file mode 100644 index 0000000..deb17a7 --- /dev/null +++ b/lib/monite/types/payable_entity_organization_response.rb @@ -0,0 +1,158 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "payable_entity_address_schema" +require_relative "file_schema_4" +require_relative "payable_organization_schema" +require_relative "status_enum" +require "ostruct" +require "json" + +module Monite +# A base for an entity response schema + class PayableEntityOrganizationResponse + # @return [String] UUID entity ID + attr_reader :id + # @return [DateTime] UTC datetime + attr_reader :created_at + # @return [DateTime] UTC datetime + attr_reader :updated_at + # @return [Monite::PayableEntityAddressSchema] + attr_reader :address + # @return [String] An official email address of the entity + attr_reader :email + # @return [Monite::FileSchema4] A logo image of the entity + attr_reader :logo + # @return [Monite::PayableOrganizationSchema] A set of metadata describing an organization + attr_reader :organization + # @return [String] A phone number of the entity + attr_reader :phone + # @return [Monite::StatusEnum] record status, 'active' by default + attr_reader :status + # @return [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] UUID entity ID + # @param created_at [DateTime] UTC datetime + # @param updated_at [DateTime] UTC datetime + # @param address [Monite::PayableEntityAddressSchema] + # @param email [String] An official email address of the entity + # @param logo [Monite::FileSchema4] A logo image of the entity + # @param organization [Monite::PayableOrganizationSchema] A set of metadata describing an organization + # @param phone [String] A phone number of the entity + # @param status [Monite::StatusEnum] record status, 'active' by default + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableEntityOrganizationResponse] + def initialize(id:, created_at:, updated_at:, address:, email: OMIT, logo: OMIT, organization:, phone: OMIT, status:, tax_id: OMIT, website: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @address = address + @email = email if email != OMIT + @logo = logo if logo != OMIT + @organization = organization + @phone = phone if phone != OMIT + @status = status + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "address": address, "email": email, "logo": logo, "organization": organization, "phone": phone, "status": status, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableEntityOrganizationResponse + # + # @param json_object [String] + # @return [Monite::PayableEntityOrganizationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::PayableEntityAddressSchema.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + unless parsed_json["logo"].nil? + logo = parsed_json["logo"].to_json + logo = Monite::FileSchema4.from_json(json_object: logo) + else + logo = nil + end + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::PayableOrganizationSchema.from_json(json_object: organization) + else + organization = nil + end + phone = parsed_json["phone"] + status = parsed_json["status"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + address: address, + email: email, + logo: logo, + organization: organization, + phone: phone, + status: status, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of PayableEntityOrganizationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + Monite::PayableEntityAddressSchema.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.logo.nil? || Monite::FileSchema4.validate_raw(obj: obj.logo) + Monite::PayableOrganizationSchema.validate_raw(obj: obj.organization) + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.status.is_a?(Monite::StatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_individual_schema.rb b/lib/monite/types/payable_individual_schema.rb new file mode 100644 index 0000000..279b113 --- /dev/null +++ b/lib/monite/types/payable_individual_schema.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema contains metadata for an individual + class PayableIndividualSchema + # @return [String] + attr_reader :date_of_birth + # @return [String] A first name of an individual + attr_reader :first_name + # @return [String] + attr_reader :id_number + # @return [String] A last name of an individual + attr_reader :last_name + # @return [String] The last four digits of the individual's Social Security number + attr_reader :ssn_last_4 + # @return [String] A title of an individual + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date_of_birth [String] + # @param first_name [String] A first name of an individual + # @param id_number [String] + # @param last_name [String] A last name of an individual + # @param ssn_last_4 [String] The last four digits of the individual's Social Security number + # @param title [String] A title of an individual + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableIndividualSchema] + def initialize(date_of_birth: OMIT, first_name:, id_number: OMIT, last_name:, ssn_last_4: OMIT, title: OMIT, additional_properties: nil) + @date_of_birth = date_of_birth if date_of_birth != OMIT + @first_name = first_name + @id_number = id_number if id_number != OMIT + @last_name = last_name + @ssn_last_4 = ssn_last_4 if ssn_last_4 != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "date_of_birth": date_of_birth, "first_name": first_name, "id_number": id_number, "last_name": last_name, "ssn_last_4": ssn_last_4, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableIndividualSchema + # + # @param json_object [String] + # @return [Monite::PayableIndividualSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date_of_birth = parsed_json["date_of_birth"] + first_name = parsed_json["first_name"] + id_number = parsed_json["id_number"] + last_name = parsed_json["last_name"] + ssn_last_4 = parsed_json["ssn_last_4"] + title = parsed_json["title"] + new( + date_of_birth: date_of_birth, + first_name: first_name, + id_number: id_number, + last_name: last_name, + ssn_last_4: ssn_last_4, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of PayableIndividualSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date_of_birth&.is_a?(String) != false || raise("Passed value for field obj.date_of_birth is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.id_number&.is_a?(String) != false || raise("Passed value for field obj.id_number is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.ssn_last_4&.is_a?(String) != false || raise("Passed value for field obj.ssn_last_4 is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_metric_enum.rb b/lib/monite/types/payable_metric_enum.rb new file mode 100644 index 0000000..896eaa1 --- /dev/null +++ b/lib/monite/types/payable_metric_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PayableMetricEnum + + ID = "id" + TOTAL_AMOUNT = "total_amount" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_organization_schema.rb b/lib/monite/types/payable_organization_schema.rb new file mode 100644 index 0000000..f3f1bae --- /dev/null +++ b/lib/monite/types/payable_organization_schema.rb @@ -0,0 +1,100 @@ +# frozen_string_literal: true +require_relative "entity_business_structure" +require "ostruct" +require "json" + +module Monite +# A schema contains metadata for an organization + class PayableOrganizationSchema + # @return [Monite::EntityBusinessStructure] Business structure of the company + attr_reader :business_structure + # @return [Boolean] + attr_reader :directors_provided + # @return [Boolean] + attr_reader :executives_provided + # @return [String] A code which identifies uniquely a party of a transaction worldwide + attr_reader :legal_entity_id + # @return [String] A legal name of an organization + attr_reader :legal_name + # @return [Boolean] + attr_reader :owners_provided + # @return [Boolean] + attr_reader :representative_provided + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param business_structure [Monite::EntityBusinessStructure] Business structure of the company + # @param directors_provided [Boolean] + # @param executives_provided [Boolean] + # @param legal_entity_id [String] A code which identifies uniquely a party of a transaction worldwide + # @param legal_name [String] A legal name of an organization + # @param owners_provided [Boolean] + # @param representative_provided [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableOrganizationSchema] + def initialize(business_structure: OMIT, directors_provided: OMIT, executives_provided: OMIT, legal_entity_id: OMIT, legal_name:, owners_provided: OMIT, representative_provided: OMIT, additional_properties: nil) + @business_structure = business_structure if business_structure != OMIT + @directors_provided = directors_provided if directors_provided != OMIT + @executives_provided = executives_provided if executives_provided != OMIT + @legal_entity_id = legal_entity_id if legal_entity_id != OMIT + @legal_name = legal_name + @owners_provided = owners_provided if owners_provided != OMIT + @representative_provided = representative_provided if representative_provided != OMIT + @additional_properties = additional_properties + @_field_set = { "business_structure": business_structure, "directors_provided": directors_provided, "executives_provided": executives_provided, "legal_entity_id": legal_entity_id, "legal_name": legal_name, "owners_provided": owners_provided, "representative_provided": representative_provided }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableOrganizationSchema + # + # @param json_object [String] + # @return [Monite::PayableOrganizationSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + business_structure = parsed_json["business_structure"] + directors_provided = parsed_json["directors_provided"] + executives_provided = parsed_json["executives_provided"] + legal_entity_id = parsed_json["legal_entity_id"] + legal_name = parsed_json["legal_name"] + owners_provided = parsed_json["owners_provided"] + representative_provided = parsed_json["representative_provided"] + new( + business_structure: business_structure, + directors_provided: directors_provided, + executives_provided: executives_provided, + legal_entity_id: legal_entity_id, + legal_name: legal_name, + owners_provided: owners_provided, + representative_provided: representative_provided, + additional_properties: struct + ) + end +# Serialize an instance of PayableOrganizationSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.business_structure&.is_a?(Monite::EntityBusinessStructure) != false || raise("Passed value for field obj.business_structure is not the expected type, validation failed.") + obj.directors_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.directors_provided is not the expected type, validation failed.") + obj.executives_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.executives_provided is not the expected type, validation failed.") + obj.legal_entity_id&.is_a?(String) != false || raise("Passed value for field obj.legal_entity_id is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.owners_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.owners_provided is not the expected type, validation failed.") + obj.representative_provided&.is_a?(Boolean) != false || raise("Passed value for field obj.representative_provided is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_origin_enum.rb b/lib/monite/types/payable_origin_enum.rb new file mode 100644 index 0000000..6a0219c --- /dev/null +++ b/lib/monite/types/payable_origin_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class PayableOriginEnum + + UPLOAD = "upload" + EMAIL = "email" + EINVOICING = "einvoicing" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_pagination_response.rb b/lib/monite/types/payable_pagination_response.rb new file mode 100644 index 0000000..0a2f18c --- /dev/null +++ b/lib/monite/types/payable_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "payable_response_schema" +require "ostruct" +require "json" + +module Monite +# A paginated list of payables. + class PayablePaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayablePaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayablePaginationResponse + # + # @param json_object [String] + # @return [Monite::PayablePaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PayableResponseSchema.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of PayablePaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_payment_term_discount.rb b/lib/monite/types/payable_payment_term_discount.rb new file mode 100644 index 0000000..c08b32b --- /dev/null +++ b/lib/monite/types/payable_payment_term_discount.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PayablePaymentTermDiscount + # @return [Integer] The discount percentage in minor units. E.g., 200 means 2%, 1050 means 10.5%. + attr_reader :discount + # @return [Integer] The amount of days after the invoice issue date. + attr_reader :number_of_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param discount [Integer] The discount percentage in minor units. E.g., 200 means 2%, 1050 means 10.5%. + # @param number_of_days [Integer] The amount of days after the invoice issue date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayablePaymentTermDiscount] + def initialize(discount:, number_of_days:, additional_properties: nil) + @discount = discount + @number_of_days = number_of_days + @additional_properties = additional_properties + @_field_set = { "discount": discount, "number_of_days": number_of_days } + end +# Deserialize a JSON object to an instance of PayablePaymentTermDiscount + # + # @param json_object [String] + # @return [Monite::PayablePaymentTermDiscount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + discount = parsed_json["discount"] + number_of_days = parsed_json["number_of_days"] + new( + discount: discount, + number_of_days: number_of_days, + additional_properties: struct + ) + end +# Serialize an instance of PayablePaymentTermDiscount to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.discount.is_a?(Integer) != false || raise("Passed value for field obj.discount is not the expected type, validation failed.") + obj.number_of_days.is_a?(Integer) != false || raise("Passed value for field obj.number_of_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_payment_term_final.rb b/lib/monite/types/payable_payment_term_final.rb new file mode 100644 index 0000000..9782a38 --- /dev/null +++ b/lib/monite/types/payable_payment_term_final.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PayablePaymentTermFinal + # @return [Integer] The amount of days after the invoice issue date. + attr_reader :number_of_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param number_of_days [Integer] The amount of days after the invoice issue date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayablePaymentTermFinal] + def initialize(number_of_days:, additional_properties: nil) + @number_of_days = number_of_days + @additional_properties = additional_properties + @_field_set = { "number_of_days": number_of_days } + end +# Deserialize a JSON object to an instance of PayablePaymentTermFinal + # + # @param json_object [String] + # @return [Monite::PayablePaymentTermFinal] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + number_of_days = parsed_json["number_of_days"] + new(number_of_days: number_of_days, additional_properties: struct) + end +# Serialize an instance of PayablePaymentTermFinal to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.number_of_days.is_a?(Integer) != false || raise("Passed value for field obj.number_of_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_payment_terms_create_payload.rb b/lib/monite/types/payable_payment_terms_create_payload.rb new file mode 100644 index 0000000..cb8e199 --- /dev/null +++ b/lib/monite/types/payable_payment_terms_create_payload.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true +require_relative "payable_payment_term_discount" +require_relative "payable_payment_term_final" +require "ostruct" +require "json" + +module Monite + class PayablePaymentTermsCreatePayload + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [Monite::PayablePaymentTermDiscount] + attr_reader :term_1 + # @return [Monite::PayablePaymentTermDiscount] + attr_reader :term_2 + # @return [Monite::PayablePaymentTermFinal] + attr_reader :term_final + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] + # @param name [String] + # @param term_1 [Monite::PayablePaymentTermDiscount] + # @param term_2 [Monite::PayablePaymentTermDiscount] + # @param term_final [Monite::PayablePaymentTermFinal] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayablePaymentTermsCreatePayload] + def initialize(description: OMIT, name:, term_1: OMIT, term_2: OMIT, term_final:, additional_properties: nil) + @description = description if description != OMIT + @name = name + @term_1 = term_1 if term_1 != OMIT + @term_2 = term_2 if term_2 != OMIT + @term_final = term_final + @additional_properties = additional_properties + @_field_set = { "description": description, "name": name, "term_1": term_1, "term_2": term_2, "term_final": term_final }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayablePaymentTermsCreatePayload + # + # @param json_object [String] + # @return [Monite::PayablePaymentTermsCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + name = parsed_json["name"] + unless parsed_json["term_1"].nil? + term_1 = parsed_json["term_1"].to_json + term_1 = Monite::PayablePaymentTermDiscount.from_json(json_object: term_1) + else + term_1 = nil + end + unless parsed_json["term_2"].nil? + term_2 = parsed_json["term_2"].to_json + term_2 = Monite::PayablePaymentTermDiscount.from_json(json_object: term_2) + else + term_2 = nil + end + unless parsed_json["term_final"].nil? + term_final = parsed_json["term_final"].to_json + term_final = Monite::PayablePaymentTermFinal.from_json(json_object: term_final) + else + term_final = nil + end + new( + description: description, + name: name, + term_1: term_1, + term_2: term_2, + term_final: term_final, + additional_properties: struct + ) + end +# Serialize an instance of PayablePaymentTermsCreatePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.term_1.nil? || Monite::PayablePaymentTermDiscount.validate_raw(obj: obj.term_1) + obj.term_2.nil? || Monite::PayablePaymentTermDiscount.validate_raw(obj: obj.term_2) + Monite::PayablePaymentTermFinal.validate_raw(obj: obj.term_final) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_response_schema.rb b/lib/monite/types/payable_response_schema.rb new file mode 100644 index 0000000..b70f462 --- /dev/null +++ b/lib/monite/types/payable_response_schema.rb @@ -0,0 +1,524 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "counterpart_raw_data" +require_relative "payable_credit_note_data" +require_relative "currency_enum" +require_relative "currency_exchange_schema_2" +require_relative "file_schema_2" +require_relative "ocr_status_enum" +require_relative "payable_response_schema_other_extracted_data" +require "date" +require_relative "payable_origin_enum" +require_relative "payable_payment_terms_create_payload" +require_relative "source_of_payable_data_enum" +require_relative "payable_state_enum" +require_relative "suggested_payment_term" +require_relative "tag_read_schema" +require "ostruct" +require "json" + +module Monite +# Represents an Accounts Payable document received from a vendor or supplier. + class PayableResponseSchema + # @return [String] A unique ID assigned to this payable. + attr_reader :id + # @return [DateTime] UTC date and time when this payable was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + attr_reader :created_at + # @return [DateTime] UTC date and time when this payable was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + attr_reader :updated_at + # @return [Integer] How much is left to be paid on the invoice (in minor units). + attr_reader :amount_due + # @return [Integer] How much was paid on the invoice (in minor units). + attr_reader :amount_paid + # @return [Integer] How much is left to be paid on the invoice (in minor units) with discounts from +# payment terms. + attr_reader :amount_to_pay + # @return [String] Id of existing approval policy that applies to this payable, if any. A policy is +# applied if the payable matches the policy trigger conditions. + attr_reader :approval_policy_id + # @return [Monite::CounterpartRawData] Object representing de-normalized counterpart data. Filled at the moment of +# invoice submitting for approval or payment. + attr_reader :counterpart + # @return [String] The ID of counterpart address object stored in counterparts service + attr_reader :counterpart_address_id + # @return [String] The ID of counterpart bank account object stored in counterparts service + attr_reader :counterpart_bank_account_id + # @return [String] The ID of the counterpart object that represents the vendor or supplier. + attr_reader :counterpart_id + # @return [Monite::CounterpartRawData] Object representing counterpart data which was extracted by OCR. Used for +# informational purposes. + attr_reader :counterpart_raw_data + # @return [String] The ID of counterpart VAT ID object stored in counterparts service + attr_reader :counterpart_vat_id_id + # @return [String] The ID of the role that the entity user who created this payable had at that +# time. If the payable was created using a partner access token, the value is +# `null`. + attr_reader :created_by_role_id + # @return [Array] The list of linked credit notes of the payable. + attr_reader :credit_notes + # @return [Monite::CurrencyEnum] The [currency code](https://docs.monite.com/references/currencies) of the +# currency used in the payable. + attr_reader :currency + # @return [Monite::CurrencyExchangeSchema2] + attr_reader :currency_exchange + # @return [String] An arbitrary description of this payable. + attr_reader :description + # @return [Integer] The value of the additional discount that will be applied to the total amount. +# in [minor units](https://docs.monite.com/references/currencies#minor-units). For +# example, $12.50 is represented as 1250. + attr_reader :discount + # @return [String] A unique invoice number assigned by the invoice issuer for payment tracking +# purposes. This is different from `id` which is an internal ID created +# automatically by Monite. + attr_reader :document_id + # @return [String] The date by which the payable must be paid, in the YYYY-MM-DD format. If the +# payable specifies payment terms with early payment discounts, this is the final +# payment date. + attr_reader :due_date + # @return [String] The ID of the entity to which the payable was issued. + attr_reader :entity_id + # @return [Monite::FileSchema2] The original file from which this payable was created. + attr_reader :file + # @return [String] File id to retrieve file info from file saver. + attr_reader :file_id + # @return [String] The date when the payable was issued, in the YYYY-MM-DD format. + attr_reader :issued_at + # @return [String] The ID of the entity user who marked this document as paid. + attr_reader :marked_as_paid_by_entity_user_id + # @return [String] An arbitrary comment that describes how and when this payable was paid. + attr_reader :marked_as_paid_with_comment + # @return [String] Id of OCR request to match asynchronous result of processing payable. + attr_reader :ocr_request_id + # @return [Monite::OcrStatusEnum] The status of the data recognition process using OCR. The 'processing' status +# means that the data recognition is in progress and the user needs to wait for +# the data enrichment. The 'error' status indicates that some error occurred on +# the OCR side and the user can fill in the data manually. The 'success' status +# means the data recognition has been successfully completed, after which the user +# can check the data if desired and enrich or correct it. + attr_reader :ocr_status + # @return [Monite::PayableResponseSchemaOtherExtractedData] Data extracted from the uploaded payable by OCR. + attr_reader :other_extracted_data + # @return [DateTime] The date by which the payable was paid + attr_reader :paid_at + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [Monite::PayableOriginEnum] Specifies how this payable was created in Monite: `upload` - created via an API +# call, `email` - sent via email to the entity's mailbox. + attr_reader :payable_origin + # @return [Monite::PayablePaymentTermsCreatePayload] The number of days to pay with potential discount for options shorter than +# due_date + attr_reader :payment_terms + # @return [String] Project ID of a payable. + attr_reader :project_id + # @return [String] The identifier of the purchase order to which this payable belongs. + attr_reader :purchase_order_id + # @return [String] The email address from which the invoice was sent to the entity. + attr_reader :sender + # @return [Monite::SourceOfPayableDataEnum] Specifies how the property values of this payable were provided: `ocr` - Monite +# OCR service extracted the values from the provided PDF or image file, +# `user_specified` - values were added or updated via an API call. + attr_reader :source_of_payable_data + # @return [Monite::PayableStateEnum] The [status](https://docs.monite.com/accounts-payable/payables/index) of the +# payable. + attr_reader :status + # @return [Integer] The subtotal amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :subtotal + # @return [Monite::SuggestedPaymentTerm] The suggested date and corresponding discount in which payable could be paid. +# The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) +# - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on +# the payment terms and may even be equal to the due date with discount 0. + attr_reader :suggested_payment_term + # @return [Array] A list of user-defined tags (labels) assigned to this payable. Tags can be used +# to trigger a specific approval policy for this payable. + attr_reader :tags + # @return [Integer] Registered tax percentage applied for a service price in minor units, e.g. 200 +# means 2%, 1050 means 10.5%. + attr_reader :tax + # @return [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :tax_amount + # @return [Integer] The total amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + attr_reader :total_amount + # @return [Integer] The total price of the payable in [minor +# units](https://docs.monite.com/references/currencies#minor-units), excluding all +# issued credit notes. + attr_reader :total_amount_with_credit_notes + # @return [String] + attr_reader :was_created_by_user_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID assigned to this payable. + # @param created_at [DateTime] UTC date and time when this payable was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param updated_at [DateTime] UTC date and time when this payable was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) format. + # @param amount_due [Integer] How much is left to be paid on the invoice (in minor units). + # @param amount_paid [Integer] How much was paid on the invoice (in minor units). + # @param amount_to_pay [Integer] How much is left to be paid on the invoice (in minor units) with discounts from +# payment terms. + # @param approval_policy_id [String] Id of existing approval policy that applies to this payable, if any. A policy is +# applied if the payable matches the policy trigger conditions. + # @param counterpart [Monite::CounterpartRawData] Object representing de-normalized counterpart data. Filled at the moment of +# invoice submitting for approval or payment. + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service + # @param counterpart_bank_account_id [String] The ID of counterpart bank account object stored in counterparts service + # @param counterpart_id [String] The ID of the counterpart object that represents the vendor or supplier. + # @param counterpart_raw_data [Monite::CounterpartRawData] Object representing counterpart data which was extracted by OCR. Used for +# informational purposes. + # @param counterpart_vat_id_id [String] The ID of counterpart VAT ID object stored in counterparts service + # @param created_by_role_id [String] The ID of the role that the entity user who created this payable had at that +# time. If the payable was created using a partner access token, the value is +# `null`. + # @param credit_notes [Array] The list of linked credit notes of the payable. + # @param currency [Monite::CurrencyEnum] The [currency code](https://docs.monite.com/references/currencies) of the +# currency used in the payable. + # @param currency_exchange [Monite::CurrencyExchangeSchema2] + # @param description [String] An arbitrary description of this payable. + # @param discount [Integer] The value of the additional discount that will be applied to the total amount. +# in [minor units](https://docs.monite.com/references/currencies#minor-units). For +# example, $12.50 is represented as 1250. + # @param document_id [String] A unique invoice number assigned by the invoice issuer for payment tracking +# purposes. This is different from `id` which is an internal ID created +# automatically by Monite. + # @param due_date [String] The date by which the payable must be paid, in the YYYY-MM-DD format. If the +# payable specifies payment terms with early payment discounts, this is the final +# payment date. + # @param entity_id [String] The ID of the entity to which the payable was issued. + # @param file [Monite::FileSchema2] The original file from which this payable was created. + # @param file_id [String] File id to retrieve file info from file saver. + # @param issued_at [String] The date when the payable was issued, in the YYYY-MM-DD format. + # @param marked_as_paid_by_entity_user_id [String] The ID of the entity user who marked this document as paid. + # @param marked_as_paid_with_comment [String] An arbitrary comment that describes how and when this payable was paid. + # @param ocr_request_id [String] Id of OCR request to match asynchronous result of processing payable. + # @param ocr_status [Monite::OcrStatusEnum] The status of the data recognition process using OCR. The 'processing' status +# means that the data recognition is in progress and the user needs to wait for +# the data enrichment. The 'error' status indicates that some error occurred on +# the OCR side and the user can fill in the data manually. The 'success' status +# means the data recognition has been successfully completed, after which the user +# can check the data if desired and enrich or correct it. + # @param other_extracted_data [Monite::PayableResponseSchemaOtherExtractedData] Data extracted from the uploaded payable by OCR. + # @param paid_at [DateTime] The date by which the payable was paid + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payable_origin [Monite::PayableOriginEnum] Specifies how this payable was created in Monite: `upload` - created via an API +# call, `email` - sent via email to the entity's mailbox. + # @param payment_terms [Monite::PayablePaymentTermsCreatePayload] The number of days to pay with potential discount for options shorter than +# due_date + # @param project_id [String] Project ID of a payable. + # @param purchase_order_id [String] The identifier of the purchase order to which this payable belongs. + # @param sender [String] The email address from which the invoice was sent to the entity. + # @param source_of_payable_data [Monite::SourceOfPayableDataEnum] Specifies how the property values of this payable were provided: `ocr` - Monite +# OCR service extracted the values from the provided PDF or image file, +# `user_specified` - values were added or updated via an API call. + # @param status [Monite::PayableStateEnum] The [status](https://docs.monite.com/accounts-payable/payables/index) of the +# payable. + # @param subtotal [Integer] The subtotal amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param suggested_payment_term [Monite::SuggestedPaymentTerm] The suggested date and corresponding discount in which payable could be paid. +# The date is in the YYYY-MM-DD format. The discount is calculated as X * (10^-4) +# - for example, 100 is 1%, 25 is 0,25%, 10000 is 100 %. Date varies depending on +# the payment terms and may even be equal to the due date with discount 0. + # @param tags [Array] A list of user-defined tags (labels) assigned to this payable. Tags can be used +# to trigger a specific approval policy for this payable. + # @param tax [Integer] Registered tax percentage applied for a service price in minor units, e.g. 200 +# means 2%, 1050 means 10.5%. + # @param tax_amount [Integer] Tax amount in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total_amount [Integer] The total amount to be paid, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). For example, +# $12.50 is represented as 1250. + # @param total_amount_with_credit_notes [Integer] The total price of the payable in [minor +# units](https://docs.monite.com/references/currencies#minor-units), excluding all +# issued credit notes. + # @param was_created_by_user_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableResponseSchema] + def initialize(id:, created_at:, updated_at:, amount_due: OMIT, amount_paid: OMIT, amount_to_pay: OMIT, approval_policy_id: OMIT, counterpart: OMIT, counterpart_address_id: OMIT, counterpart_bank_account_id: OMIT, counterpart_id: OMIT, counterpart_raw_data: OMIT, counterpart_vat_id_id: OMIT, created_by_role_id: OMIT, credit_notes:, currency: OMIT, currency_exchange: OMIT, description: OMIT, discount: OMIT, document_id: OMIT, due_date: OMIT, entity_id:, file: OMIT, file_id: OMIT, issued_at: OMIT, marked_as_paid_by_entity_user_id: OMIT, marked_as_paid_with_comment: OMIT, ocr_request_id: OMIT, ocr_status: OMIT, other_extracted_data: OMIT, paid_at: OMIT, partner_metadata: OMIT, payable_origin:, payment_terms: OMIT, project_id: OMIT, purchase_order_id: OMIT, sender: OMIT, source_of_payable_data:, status:, subtotal: OMIT, suggested_payment_term: OMIT, tags: OMIT, tax: OMIT, tax_amount: OMIT, total_amount: OMIT, total_amount_with_credit_notes: OMIT, was_created_by_user_id: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @amount_due = amount_due if amount_due != OMIT + @amount_paid = amount_paid if amount_paid != OMIT + @amount_to_pay = amount_to_pay if amount_to_pay != OMIT + @approval_policy_id = approval_policy_id if approval_policy_id != OMIT + @counterpart = counterpart if counterpart != OMIT + @counterpart_address_id = counterpart_address_id if counterpart_address_id != OMIT + @counterpart_bank_account_id = counterpart_bank_account_id if counterpart_bank_account_id != OMIT + @counterpart_id = counterpart_id if counterpart_id != OMIT + @counterpart_raw_data = counterpart_raw_data if counterpart_raw_data != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @created_by_role_id = created_by_role_id if created_by_role_id != OMIT + @credit_notes = credit_notes + @currency = currency if currency != OMIT + @currency_exchange = currency_exchange if currency_exchange != OMIT + @description = description if description != OMIT + @discount = discount if discount != OMIT + @document_id = document_id if document_id != OMIT + @due_date = due_date if due_date != OMIT + @entity_id = entity_id + @file = file if file != OMIT + @file_id = file_id if file_id != OMIT + @issued_at = issued_at if issued_at != OMIT + @marked_as_paid_by_entity_user_id = marked_as_paid_by_entity_user_id if marked_as_paid_by_entity_user_id != OMIT + @marked_as_paid_with_comment = marked_as_paid_with_comment if marked_as_paid_with_comment != OMIT + @ocr_request_id = ocr_request_id if ocr_request_id != OMIT + @ocr_status = ocr_status if ocr_status != OMIT + @other_extracted_data = other_extracted_data if other_extracted_data != OMIT + @paid_at = paid_at if paid_at != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @payable_origin = payable_origin + @payment_terms = payment_terms if payment_terms != OMIT + @project_id = project_id if project_id != OMIT + @purchase_order_id = purchase_order_id if purchase_order_id != OMIT + @sender = sender if sender != OMIT + @source_of_payable_data = source_of_payable_data + @status = status + @subtotal = subtotal if subtotal != OMIT + @suggested_payment_term = suggested_payment_term if suggested_payment_term != OMIT + @tags = tags if tags != OMIT + @tax = tax if tax != OMIT + @tax_amount = tax_amount if tax_amount != OMIT + @total_amount = total_amount if total_amount != OMIT + @total_amount_with_credit_notes = total_amount_with_credit_notes if total_amount_with_credit_notes != OMIT + @was_created_by_user_id = was_created_by_user_id if was_created_by_user_id != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "amount_due": amount_due, "amount_paid": amount_paid, "amount_to_pay": amount_to_pay, "approval_policy_id": approval_policy_id, "counterpart": counterpart, "counterpart_address_id": counterpart_address_id, "counterpart_bank_account_id": counterpart_bank_account_id, "counterpart_id": counterpart_id, "counterpart_raw_data": counterpart_raw_data, "counterpart_vat_id_id": counterpart_vat_id_id, "created_by_role_id": created_by_role_id, "credit_notes": credit_notes, "currency": currency, "currency_exchange": currency_exchange, "description": description, "discount": discount, "document_id": document_id, "due_date": due_date, "entity_id": entity_id, "file": file, "file_id": file_id, "issued_at": issued_at, "marked_as_paid_by_entity_user_id": marked_as_paid_by_entity_user_id, "marked_as_paid_with_comment": marked_as_paid_with_comment, "ocr_request_id": ocr_request_id, "ocr_status": ocr_status, "other_extracted_data": other_extracted_data, "paid_at": paid_at, "partner_metadata": partner_metadata, "payable_origin": payable_origin, "payment_terms": payment_terms, "project_id": project_id, "purchase_order_id": purchase_order_id, "sender": sender, "source_of_payable_data": source_of_payable_data, "status": status, "subtotal": subtotal, "suggested_payment_term": suggested_payment_term, "tags": tags, "tax": tax, "tax_amount": tax_amount, "total_amount": total_amount, "total_amount_with_credit_notes": total_amount_with_credit_notes, "was_created_by_user_id": was_created_by_user_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableResponseSchema + # + # @param json_object [String] + # @return [Monite::PayableResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + amount_due = parsed_json["amount_due"] + amount_paid = parsed_json["amount_paid"] + amount_to_pay = parsed_json["amount_to_pay"] + approval_policy_id = parsed_json["approval_policy_id"] + unless parsed_json["counterpart"].nil? + counterpart = parsed_json["counterpart"].to_json + counterpart = Monite::CounterpartRawData.from_json(json_object: counterpart) + else + counterpart = nil + end + counterpart_address_id = parsed_json["counterpart_address_id"] + counterpart_bank_account_id = parsed_json["counterpart_bank_account_id"] + counterpart_id = parsed_json["counterpart_id"] + unless parsed_json["counterpart_raw_data"].nil? + counterpart_raw_data = parsed_json["counterpart_raw_data"].to_json + counterpart_raw_data = Monite::CounterpartRawData.from_json(json_object: counterpart_raw_data) + else + counterpart_raw_data = nil + end + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + created_by_role_id = parsed_json["created_by_role_id"] + credit_notes = parsed_json["credit_notes"]&.map do | item | + item = item.to_json + Monite::PayableCreditNoteData.from_json(json_object: item) +end + currency = parsed_json["currency"] + unless parsed_json["currency_exchange"].nil? + currency_exchange = parsed_json["currency_exchange"].to_json + currency_exchange = Monite::CurrencyExchangeSchema2.from_json(json_object: currency_exchange) + else + currency_exchange = nil + end + description = parsed_json["description"] + discount = parsed_json["discount"] + document_id = parsed_json["document_id"] + due_date = parsed_json["due_date"] + entity_id = parsed_json["entity_id"] + unless parsed_json["file"].nil? + file = parsed_json["file"].to_json + file = Monite::FileSchema2.from_json(json_object: file) + else + file = nil + end + file_id = parsed_json["file_id"] + issued_at = parsed_json["issued_at"] + marked_as_paid_by_entity_user_id = parsed_json["marked_as_paid_by_entity_user_id"] + marked_as_paid_with_comment = parsed_json["marked_as_paid_with_comment"] + ocr_request_id = parsed_json["ocr_request_id"] + ocr_status = parsed_json["ocr_status"] + unless parsed_json["other_extracted_data"].nil? + other_extracted_data = parsed_json["other_extracted_data"].to_json + other_extracted_data = Monite::PayableResponseSchemaOtherExtractedData.from_json(json_object: other_extracted_data) + else + other_extracted_data = nil + end + paid_at = unless parsed_json["paid_at"].nil? + DateTime.parse(parsed_json["paid_at"]) +else + nil +end + partner_metadata = parsed_json["partner_metadata"] + payable_origin = parsed_json["payable_origin"] + unless parsed_json["payment_terms"].nil? + payment_terms = parsed_json["payment_terms"].to_json + payment_terms = Monite::PayablePaymentTermsCreatePayload.from_json(json_object: payment_terms) + else + payment_terms = nil + end + project_id = parsed_json["project_id"] + purchase_order_id = parsed_json["purchase_order_id"] + sender = parsed_json["sender"] + source_of_payable_data = parsed_json["source_of_payable_data"] + status = parsed_json["status"] + subtotal = parsed_json["subtotal"] + unless parsed_json["suggested_payment_term"].nil? + suggested_payment_term = parsed_json["suggested_payment_term"].to_json + suggested_payment_term = Monite::SuggestedPaymentTerm.from_json(json_object: suggested_payment_term) + else + suggested_payment_term = nil + end + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + tax = parsed_json["tax"] + tax_amount = parsed_json["tax_amount"] + total_amount = parsed_json["total_amount"] + total_amount_with_credit_notes = parsed_json["total_amount_with_credit_notes"] + was_created_by_user_id = parsed_json["was_created_by_user_id"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + amount_due: amount_due, + amount_paid: amount_paid, + amount_to_pay: amount_to_pay, + approval_policy_id: approval_policy_id, + counterpart: counterpart, + counterpart_address_id: counterpart_address_id, + counterpart_bank_account_id: counterpart_bank_account_id, + counterpart_id: counterpart_id, + counterpart_raw_data: counterpart_raw_data, + counterpart_vat_id_id: counterpart_vat_id_id, + created_by_role_id: created_by_role_id, + credit_notes: credit_notes, + currency: currency, + currency_exchange: currency_exchange, + description: description, + discount: discount, + document_id: document_id, + due_date: due_date, + entity_id: entity_id, + file: file, + file_id: file_id, + issued_at: issued_at, + marked_as_paid_by_entity_user_id: marked_as_paid_by_entity_user_id, + marked_as_paid_with_comment: marked_as_paid_with_comment, + ocr_request_id: ocr_request_id, + ocr_status: ocr_status, + other_extracted_data: other_extracted_data, + paid_at: paid_at, + partner_metadata: partner_metadata, + payable_origin: payable_origin, + payment_terms: payment_terms, + project_id: project_id, + purchase_order_id: purchase_order_id, + sender: sender, + source_of_payable_data: source_of_payable_data, + status: status, + subtotal: subtotal, + suggested_payment_term: suggested_payment_term, + tags: tags, + tax: tax, + tax_amount: tax_amount, + total_amount: total_amount, + total_amount_with_credit_notes: total_amount_with_credit_notes, + was_created_by_user_id: was_created_by_user_id, + additional_properties: struct + ) + end +# Serialize an instance of PayableResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.amount_due&.is_a?(Integer) != false || raise("Passed value for field obj.amount_due is not the expected type, validation failed.") + obj.amount_paid&.is_a?(Integer) != false || raise("Passed value for field obj.amount_paid is not the expected type, validation failed.") + obj.amount_to_pay&.is_a?(Integer) != false || raise("Passed value for field obj.amount_to_pay is not the expected type, validation failed.") + obj.approval_policy_id&.is_a?(String) != false || raise("Passed value for field obj.approval_policy_id is not the expected type, validation failed.") + obj.counterpart.nil? || Monite::CounterpartRawData.validate_raw(obj: obj.counterpart) + obj.counterpart_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_address_id is not the expected type, validation failed.") + obj.counterpart_bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_bank_account_id is not the expected type, validation failed.") + obj.counterpart_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_raw_data.nil? || Monite::CounterpartRawData.validate_raw(obj: obj.counterpart_raw_data) + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.created_by_role_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_role_id is not the expected type, validation failed.") + obj.credit_notes.is_a?(Array) != false || raise("Passed value for field obj.credit_notes is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.currency_exchange.nil? || Monite::CurrencyExchangeSchema2.validate_raw(obj: obj.currency_exchange) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.discount&.is_a?(Integer) != false || raise("Passed value for field obj.discount is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.due_date&.is_a?(String) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.file.nil? || Monite::FileSchema2.validate_raw(obj: obj.file) + obj.file_id&.is_a?(String) != false || raise("Passed value for field obj.file_id is not the expected type, validation failed.") + obj.issued_at&.is_a?(String) != false || raise("Passed value for field obj.issued_at is not the expected type, validation failed.") + obj.marked_as_paid_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.marked_as_paid_by_entity_user_id is not the expected type, validation failed.") + obj.marked_as_paid_with_comment&.is_a?(String) != false || raise("Passed value for field obj.marked_as_paid_with_comment is not the expected type, validation failed.") + obj.ocr_request_id&.is_a?(String) != false || raise("Passed value for field obj.ocr_request_id is not the expected type, validation failed.") + obj.ocr_status&.is_a?(Monite::OcrStatusEnum) != false || raise("Passed value for field obj.ocr_status is not the expected type, validation failed.") + obj.other_extracted_data.nil? || Monite::PayableResponseSchemaOtherExtractedData.validate_raw(obj: obj.other_extracted_data) + obj.paid_at&.is_a?(DateTime) != false || raise("Passed value for field obj.paid_at is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.payable_origin.is_a?(Monite::PayableOriginEnum) != false || raise("Passed value for field obj.payable_origin is not the expected type, validation failed.") + obj.payment_terms.nil? || Monite::PayablePaymentTermsCreatePayload.validate_raw(obj: obj.payment_terms) + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.purchase_order_id&.is_a?(String) != false || raise("Passed value for field obj.purchase_order_id is not the expected type, validation failed.") + obj.sender&.is_a?(String) != false || raise("Passed value for field obj.sender is not the expected type, validation failed.") + obj.source_of_payable_data.is_a?(Monite::SourceOfPayableDataEnum) != false || raise("Passed value for field obj.source_of_payable_data is not the expected type, validation failed.") + obj.status.is_a?(Monite::PayableStateEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.suggested_payment_term.nil? || Monite::SuggestedPaymentTerm.validate_raw(obj: obj.suggested_payment_term) + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + obj.tax&.is_a?(Integer) != false || raise("Passed value for field obj.tax is not the expected type, validation failed.") + obj.tax_amount&.is_a?(Integer) != false || raise("Passed value for field obj.tax_amount is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.total_amount_with_credit_notes&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount_with_credit_notes is not the expected type, validation failed.") + obj.was_created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.was_created_by_user_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_response_schema_other_extracted_data.rb b/lib/monite/types/payable_response_schema_other_extracted_data.rb new file mode 100644 index 0000000..2f55444 --- /dev/null +++ b/lib/monite/types/payable_response_schema_other_extracted_data.rb @@ -0,0 +1,60 @@ +# frozen_string_literal: true +require "json" +require_relative "ocr_response_invoice_receipt_data" +require_relative "ocr_recognition_response" + +module Monite +# Data extracted from the uploaded payable by OCR. + class PayableResponseSchemaOtherExtractedData + + +# Deserialize a JSON object to an instance of +# PayableResponseSchemaOtherExtractedData + # + # @param json_object [String] + # @return [Monite::PayableResponseSchemaOtherExtractedData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::OcrResponseInvoiceReceiptData.validate_raw(obj: struct) + unless struct.nil? + return Monite::OcrResponseInvoiceReceiptData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::OcrRecognitionResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::OcrRecognitionResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::OcrResponseInvoiceReceiptData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::OcrRecognitionResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_schema_input.rb b/lib/monite/types/payable_schema_input.rb new file mode 100644 index 0000000..616442a --- /dev/null +++ b/lib/monite/types/payable_schema_input.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "payable_action_schema" +require "ostruct" +require "json" + +module Monite + class PayableSchemaInput + # @return [Array] List of actions + attr_reader :actions + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param actions [Array] List of actions + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableSchemaInput] + def initialize(actions: OMIT, additional_properties: nil) + @actions = actions if actions != OMIT + @additional_properties = additional_properties + @_field_set = { "actions": actions }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableSchemaInput + # + # @param json_object [String] + # @return [Monite::PayableSchemaInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + actions = parsed_json["actions"]&.map do | item | + item = item.to_json + Monite::PayableActionSchema.from_json(json_object: item) +end + new(actions: actions, additional_properties: struct) + end +# Serialize an instance of PayableSchemaInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.actions&.is_a?(Array) != false || raise("Passed value for field obj.actions is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_schema_output.rb b/lib/monite/types/payable_schema_output.rb new file mode 100644 index 0000000..af71a63 --- /dev/null +++ b/lib/monite/types/payable_schema_output.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "payable_action_schema" +require "ostruct" +require "json" + +module Monite + class PayableSchemaOutput + # @return [Array] List of actions + attr_reader :actions + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param actions [Array] List of actions + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableSchemaOutput] + def initialize(actions: OMIT, additional_properties: nil) + @actions = actions if actions != OMIT + @additional_properties = additional_properties + @_field_set = { "actions": actions }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableSchemaOutput + # + # @param json_object [String] + # @return [Monite::PayableSchemaOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + actions = parsed_json["actions"]&.map do | item | + item = item.to_json + Monite::PayableActionSchema.from_json(json_object: item) +end + new(actions: actions, additional_properties: struct) + end +# Serialize an instance of PayableSchemaOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.actions&.is_a?(Array) != false || raise("Passed value for field obj.actions is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_settings.rb b/lib/monite/types/payable_settings.rb new file mode 100644 index 0000000..6a2908f --- /dev/null +++ b/lib/monite/types/payable_settings.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PayableSettings + # @return [Boolean] + attr_reader :allow_cancel_duplicates_automatically + # @return [Boolean] + attr_reader :allow_counterpart_autocreation + # @return [Boolean] + attr_reader :allow_counterpart_autolinking + # @return [Boolean] + attr_reader :allow_credit_note_autolinking + # @return [String] + attr_reader :approve_page_url + # @return [String] A state each new payable will have upon creation + attr_reader :default_state + # @return [Boolean] Starting from version 2024-05-25 by default is always set to True. + attr_reader :enable_line_items + # @return [Boolean] + attr_reader :skip_approval_for_paid_invoice + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param allow_cancel_duplicates_automatically [Boolean] + # @param allow_counterpart_autocreation [Boolean] + # @param allow_counterpart_autolinking [Boolean] + # @param allow_credit_note_autolinking [Boolean] + # @param approve_page_url [String] + # @param default_state [String] A state each new payable will have upon creation + # @param enable_line_items [Boolean] Starting from version 2024-05-25 by default is always set to True. + # @param skip_approval_for_paid_invoice [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableSettings] + def initialize(allow_cancel_duplicates_automatically: OMIT, allow_counterpart_autocreation: OMIT, allow_counterpart_autolinking: OMIT, allow_credit_note_autolinking: OMIT, approve_page_url:, default_state: OMIT, enable_line_items: OMIT, skip_approval_for_paid_invoice: OMIT, additional_properties: nil) + @allow_cancel_duplicates_automatically = allow_cancel_duplicates_automatically if allow_cancel_duplicates_automatically != OMIT + @allow_counterpart_autocreation = allow_counterpart_autocreation if allow_counterpart_autocreation != OMIT + @allow_counterpart_autolinking = allow_counterpart_autolinking if allow_counterpart_autolinking != OMIT + @allow_credit_note_autolinking = allow_credit_note_autolinking if allow_credit_note_autolinking != OMIT + @approve_page_url = approve_page_url + @default_state = default_state if default_state != OMIT + @enable_line_items = enable_line_items if enable_line_items != OMIT + @skip_approval_for_paid_invoice = skip_approval_for_paid_invoice if skip_approval_for_paid_invoice != OMIT + @additional_properties = additional_properties + @_field_set = { "allow_cancel_duplicates_automatically": allow_cancel_duplicates_automatically, "allow_counterpart_autocreation": allow_counterpart_autocreation, "allow_counterpart_autolinking": allow_counterpart_autolinking, "allow_credit_note_autolinking": allow_credit_note_autolinking, "approve_page_url": approve_page_url, "default_state": default_state, "enable_line_items": enable_line_items, "skip_approval_for_paid_invoice": skip_approval_for_paid_invoice }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableSettings + # + # @param json_object [String] + # @return [Monite::PayableSettings] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + allow_cancel_duplicates_automatically = parsed_json["allow_cancel_duplicates_automatically"] + allow_counterpart_autocreation = parsed_json["allow_counterpart_autocreation"] + allow_counterpart_autolinking = parsed_json["allow_counterpart_autolinking"] + allow_credit_note_autolinking = parsed_json["allow_credit_note_autolinking"] + approve_page_url = parsed_json["approve_page_url"] + default_state = parsed_json["default_state"] + enable_line_items = parsed_json["enable_line_items"] + skip_approval_for_paid_invoice = parsed_json["skip_approval_for_paid_invoice"] + new( + allow_cancel_duplicates_automatically: allow_cancel_duplicates_automatically, + allow_counterpart_autocreation: allow_counterpart_autocreation, + allow_counterpart_autolinking: allow_counterpart_autolinking, + allow_credit_note_autolinking: allow_credit_note_autolinking, + approve_page_url: approve_page_url, + default_state: default_state, + enable_line_items: enable_line_items, + skip_approval_for_paid_invoice: skip_approval_for_paid_invoice, + additional_properties: struct + ) + end +# Serialize an instance of PayableSettings to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.allow_cancel_duplicates_automatically&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_cancel_duplicates_automatically is not the expected type, validation failed.") + obj.allow_counterpart_autocreation&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_counterpart_autocreation is not the expected type, validation failed.") + obj.allow_counterpart_autolinking&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_counterpart_autolinking is not the expected type, validation failed.") + obj.allow_credit_note_autolinking&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_credit_note_autolinking is not the expected type, validation failed.") + obj.approve_page_url.is_a?(String) != false || raise("Passed value for field obj.approve_page_url is not the expected type, validation failed.") + obj.default_state&.is_a?(String) != false || raise("Passed value for field obj.default_state is not the expected type, validation failed.") + obj.enable_line_items&.is_a?(Boolean) != false || raise("Passed value for field obj.enable_line_items is not the expected type, validation failed.") + obj.skip_approval_for_paid_invoice&.is_a?(Boolean) != false || raise("Passed value for field obj.skip_approval_for_paid_invoice is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_state_enum.rb b/lib/monite/types/payable_state_enum.rb new file mode 100644 index 0000000..e02a8f2 --- /dev/null +++ b/lib/monite/types/payable_state_enum.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Monite + class PayableStateEnum + + DRAFT = "draft" + NEW = "new" + APPROVE_IN_PROGRESS = "approve_in_progress" + WAITING_TO_BE_PAID = "waiting_to_be_paid" + PARTIALLY_PAID = "partially_paid" + PAID = "paid" + CANCELED = "canceled" + REJECTED = "rejected" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_templates_variable.rb b/lib/monite/types/payable_templates_variable.rb new file mode 100644 index 0000000..a7223c5 --- /dev/null +++ b/lib/monite/types/payable_templates_variable.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PayableTemplatesVariable + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableTemplatesVariable] + def initialize(description:, name:, additional_properties: nil) + @description = description + @name = name + @additional_properties = additional_properties + @_field_set = { "description": description, "name": name } + end +# Deserialize a JSON object to an instance of PayableTemplatesVariable + # + # @param json_object [String] + # @return [Monite::PayableTemplatesVariable] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + name = parsed_json["name"] + new( + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of PayableTemplatesVariable to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_templates_variables_object.rb b/lib/monite/types/payable_templates_variables_object.rb new file mode 100644 index 0000000..7cd9a21 --- /dev/null +++ b/lib/monite/types/payable_templates_variables_object.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require_relative "payables_variable_type" +require_relative "object_type" +require_relative "payable_templates_variable" +require "ostruct" +require "json" + +module Monite + class PayableTemplatesVariablesObject + # @return [Monite::PayablesVariableType] + attr_reader :object_subtype + # @return [Monite::ObjectType] + attr_reader :object_type + # @return [Array] + attr_reader :variables + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object_subtype [Monite::PayablesVariableType] + # @param object_type [Monite::ObjectType] + # @param variables [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableTemplatesVariablesObject] + def initialize(object_subtype:, object_type:, variables:, additional_properties: nil) + @object_subtype = object_subtype + @object_type = object_type + @variables = variables + @additional_properties = additional_properties + @_field_set = { "object_subtype": object_subtype, "object_type": object_type, "variables": variables } + end +# Deserialize a JSON object to an instance of PayableTemplatesVariablesObject + # + # @param json_object [String] + # @return [Monite::PayableTemplatesVariablesObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + object_subtype = parsed_json["object_subtype"] + object_type = parsed_json["object_type"] + variables = parsed_json["variables"]&.map do | item | + item = item.to_json + Monite::PayableTemplatesVariable.from_json(json_object: item) +end + new( + object_subtype: object_subtype, + object_type: object_type, + variables: variables, + additional_properties: struct + ) + end +# Serialize an instance of PayableTemplatesVariablesObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.object_subtype.is_a?(Monite::PayablesVariableType) != false || raise("Passed value for field obj.object_subtype is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::ObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.variables.is_a?(Array) != false || raise("Passed value for field obj.variables is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_templates_variables_object_list.rb b/lib/monite/types/payable_templates_variables_object_list.rb new file mode 100644 index 0000000..2b18b39 --- /dev/null +++ b/lib/monite/types/payable_templates_variables_object_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "payable_templates_variables_object" +require "ostruct" +require "json" + +module Monite + class PayableTemplatesVariablesObjectList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableTemplatesVariablesObjectList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of PayableTemplatesVariablesObjectList + # + # @param json_object [String] + # @return [Monite::PayableTemplatesVariablesObjectList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PayableTemplatesVariablesObject.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of PayableTemplatesVariablesObjectList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_validation_response.rb b/lib/monite/types/payable_validation_response.rb new file mode 100644 index 0000000..fe54ec6 --- /dev/null +++ b/lib/monite/types/payable_validation_response.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PayableValidationResponse + # @return [String] A unique ID assigned to this payable. + attr_reader :id + # @return [Array Object}>] + attr_reader :validation_errors + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID assigned to this payable. + # @param validation_errors [Array Object}>] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableValidationResponse] + def initialize(id:, validation_errors: OMIT, additional_properties: nil) + @id = id + @validation_errors = validation_errors if validation_errors != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "validation_errors": validation_errors }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayableValidationResponse + # + # @param json_object [String] + # @return [Monite::PayableValidationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + validation_errors = parsed_json["validation_errors"] + new( + id: id, + validation_errors: validation_errors, + additional_properties: struct + ) + end +# Serialize an instance of PayableValidationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.validation_errors&.is_a?(Array) != false || raise("Passed value for field obj.validation_errors is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payable_validations_resource.rb b/lib/monite/types/payable_validations_resource.rb new file mode 100644 index 0000000..ff5393e --- /dev/null +++ b/lib/monite/types/payable_validations_resource.rb @@ -0,0 +1,52 @@ +# frozen_string_literal: true +require_relative "payables_fields_allowed_for_validate" +require "ostruct" +require "json" + +module Monite + class PayableValidationsResource + # @return [Array] + attr_reader :required_fields + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param required_fields [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayableValidationsResource] + def initialize(required_fields:, additional_properties: nil) + @required_fields = required_fields + @additional_properties = additional_properties + @_field_set = { "required_fields": required_fields } + end +# Deserialize a JSON object to an instance of PayableValidationsResource + # + # @param json_object [String] + # @return [Monite::PayableValidationsResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + required_fields = parsed_json["required_fields"] + new(required_fields: required_fields, additional_properties: struct) + end +# Serialize an instance of PayableValidationsResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.required_fields.is_a?(Array) != false || raise("Passed value for field obj.required_fields is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payables_fields_allowed_for_validate.rb b/lib/monite/types/payables_fields_allowed_for_validate.rb new file mode 100644 index 0000000..c40dd89 --- /dev/null +++ b/lib/monite/types/payables_fields_allowed_for_validate.rb @@ -0,0 +1,37 @@ +# frozen_string_literal: true + +module Monite + class PayablesFieldsAllowedForValidate + + CURRENCY = "currency" + DOCUMENT_ID = "document_id" + DUE_DATE = "due_date" + ISSUED_AT = "issued_at" + TAX_AMOUNT = "tax_amount" + TOTAL_AMOUNT = "total_amount" + SUBTOTAL = "subtotal" + DESCRIPTION = "description" + SUGGESTED_PAYMENT_TERM = "suggested_payment_term" + PAYMENT_TERMS = "payment_terms" + TAX = "tax" + SENDER = "sender" + FILE_ID = "file_id" + COUNTERPART_ID = "counterpart_id" + COUNTERPART_BANK_ACCOUNT_ID = "counterpart_bank_account_id" + COUNTERPART_ADDRESS_ID = "counterpart_address_id" + COUNTERPART_VAT_ID_ID = "counterpart_vat_id_id" + LINE_ITEMS = "line_items" + LINE_ITEMS_QUANTITY = "line_items.quantity" + LINE_ITEMS_UNIT_PRICE = "line_items.unit_price" + LINE_ITEMS_TAX = "line_items.tax" + LINE_ITEMS_LEDGER_ACCOUNT_ID = "line_items.ledger_account_id" + LINE_ITEMS_ACCOUNTING_TAX_RATE_ID = "line_items.accounting_tax_rate_id" + LINE_ITEMS_UNIT = "line_items.unit" + LINE_ITEMS_NAME = "line_items.name" + LINE_ITEMS_DESCRIPTION = "line_items.description" + LINE_ITEMS_SUBTOTAL = "line_items.subtotal" + LINE_ITEMS_TOTAL = "line_items.total" + LINE_ITEMS_TAX_AMOUNT = "line_items.tax_amount" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payables_variable_type.rb b/lib/monite/types/payables_variable_type.rb new file mode 100644 index 0000000..b42cecb --- /dev/null +++ b/lib/monite/types/payables_variable_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PayablesVariableType + + PAYABLES_PURCHASE_ORDER = "payables_purchase_order" + PAYABLES_NOTIFY_APPROVER = "payables_notify_approver" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payer_account_response.rb b/lib/monite/types/payer_account_response.rb new file mode 100644 index 0000000..48765f7 --- /dev/null +++ b/lib/monite/types/payer_account_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "bank_account" +require_relative "payment_account_type" +require "ostruct" +require "json" + +module Monite + class PayerAccountResponse + # @return [String] ID of a payment account + attr_reader :id + # @return [Array] List of bank accounts + attr_reader :bank_accounts + # @return [String] Display name of a payment account + attr_reader :name + # @return [Monite::PaymentAccountType] Type of a payment account. Can be `entity` or `counterpart` + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of a payment account + # @param bank_accounts [Array] List of bank accounts + # @param name [String] Display name of a payment account + # @param type [Monite::PaymentAccountType] Type of a payment account. Can be `entity` or `counterpart` + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PayerAccountResponse] + def initialize(id:, bank_accounts: OMIT, name: OMIT, type:, additional_properties: nil) + @id = id + @bank_accounts = bank_accounts if bank_accounts != OMIT + @name = name if name != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "bank_accounts": bank_accounts, "name": name, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PayerAccountResponse + # + # @param json_object [String] + # @return [Monite::PayerAccountResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + bank_accounts = parsed_json["bank_accounts"]&.map do | item | + item = item.to_json + Monite::BankAccount.from_json(json_object: item) +end + name = parsed_json["name"] + type = parsed_json["type"] + new( + id: id, + bank_accounts: bank_accounts, + name: name, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PayerAccountResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.bank_accounts&.is_a?(Array) != false || raise("Passed value for field obj.bank_accounts is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.type.is_a?(Monite::PaymentAccountType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_account_object.rb b/lib/monite/types/payment_account_object.rb new file mode 100644 index 0000000..2782f06 --- /dev/null +++ b/lib/monite/types/payment_account_object.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "payment_account_type" +require "ostruct" +require "json" + +module Monite + class PaymentAccountObject + # @return [String] ID of a payment account + attr_reader :id + # @return [Monite::PaymentAccountType] Type of a payment account. Can be `entity` or `counterpart` + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of a payment account + # @param type [Monite::PaymentAccountType] Type of a payment account. Can be `entity` or `counterpart` + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentAccountObject] + def initialize(id:, type:, additional_properties: nil) + @id = id + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "type": type } + end +# Deserialize a JSON object to an instance of PaymentAccountObject + # + # @param json_object [String] + # @return [Monite::PaymentAccountObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + type = parsed_json["type"] + new( + id: id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentAccountObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.type.is_a?(Monite::PaymentAccountType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_account_type.rb b/lib/monite/types/payment_account_type.rb new file mode 100644 index 0000000..4149a09 --- /dev/null +++ b/lib/monite/types/payment_account_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PaymentAccountType + + ENTITY = "entity" + COUNTERPART = "counterpart" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intent.rb b/lib/monite/types/payment_intent.rb new file mode 100644 index 0000000..eaaa787 --- /dev/null +++ b/lib/monite/types/payment_intent.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true +require "date" +require_relative "payment_object" +require "ostruct" +require "json" + +module Monite + class PaymentIntent + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :updated_at + # @return [Integer] + attr_reader :application_fee_amount + # @return [Monite::PaymentObject] + attr_reader :object + # @return [String] + attr_reader :provider + # @return [String] + attr_reader :selected_payment_method + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param updated_at [DateTime] + # @param application_fee_amount [Integer] + # @param object [Monite::PaymentObject] + # @param provider [String] + # @param selected_payment_method [String] + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentIntent] + def initialize(id:, updated_at:, application_fee_amount: OMIT, object: OMIT, provider: OMIT, selected_payment_method: OMIT, status:, additional_properties: nil) + @id = id + @updated_at = updated_at + @application_fee_amount = application_fee_amount if application_fee_amount != OMIT + @object = object if object != OMIT + @provider = provider if provider != OMIT + @selected_payment_method = selected_payment_method if selected_payment_method != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "updated_at": updated_at, "application_fee_amount": application_fee_amount, "object": object, "provider": provider, "selected_payment_method": selected_payment_method, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentIntent + # + # @param json_object [String] + # @return [Monite::PaymentIntent] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + application_fee_amount = parsed_json["application_fee_amount"] + unless parsed_json["object"].nil? + object = parsed_json["object"].to_json + object = Monite::PaymentObject.from_json(json_object: object) + else + object = nil + end + provider = parsed_json["provider"] + selected_payment_method = parsed_json["selected_payment_method"] + status = parsed_json["status"] + new( + id: id, + updated_at: updated_at, + application_fee_amount: application_fee_amount, + object: object, + provider: provider, + selected_payment_method: selected_payment_method, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of PaymentIntent to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.application_fee_amount&.is_a?(Integer) != false || raise("Passed value for field obj.application_fee_amount is not the expected type, validation failed.") + obj.object.nil? || Monite::PaymentObject.validate_raw(obj: obj.object) + obj.provider&.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") + obj.selected_payment_method&.is_a?(String) != false || raise("Passed value for field obj.selected_payment_method is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intent_cursor_fields.rb b/lib/monite/types/payment_intent_cursor_fields.rb new file mode 100644 index 0000000..c1fe5f8 --- /dev/null +++ b/lib/monite/types/payment_intent_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PaymentIntentCursorFields + + ID = "id" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intent_history.rb b/lib/monite/types/payment_intent_history.rb new file mode 100644 index 0000000..bed11b7 --- /dev/null +++ b/lib/monite/types/payment_intent_history.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class PaymentIntentHistory + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :payment_intent_id + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param payment_intent_id [String] + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentIntentHistory] + def initialize(id:, created_at:, updated_at:, payment_intent_id:, status:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @payment_intent_id = payment_intent_id + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "payment_intent_id": payment_intent_id, "status": status } + end +# Deserialize a JSON object to an instance of PaymentIntentHistory + # + # @param json_object [String] + # @return [Monite::PaymentIntentHistory] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + payment_intent_id = parsed_json["payment_intent_id"] + status = parsed_json["status"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + payment_intent_id: payment_intent_id, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of PaymentIntentHistory to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.payment_intent_id.is_a?(String) != false || raise("Passed value for field obj.payment_intent_id is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intent_history_response.rb b/lib/monite/types/payment_intent_history_response.rb new file mode 100644 index 0000000..94bb4ba --- /dev/null +++ b/lib/monite/types/payment_intent_history_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "payment_intent_history" +require "ostruct" +require "json" + +module Monite + class PaymentIntentHistoryResponse + # @return [Array] Payment intent history + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] Payment intent history + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentIntentHistoryResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of PaymentIntentHistoryResponse + # + # @param json_object [String] + # @return [Monite::PaymentIntentHistoryResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PaymentIntentHistory.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of PaymentIntentHistoryResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intent_payout_method.rb b/lib/monite/types/payment_intent_payout_method.rb new file mode 100644 index 0000000..f264497 --- /dev/null +++ b/lib/monite/types/payment_intent_payout_method.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PaymentIntentPayoutMethod + + BANK_ACCOUNT = "bank_account" + PAPER_CHECK = "paper_check" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intent_response.rb b/lib/monite/types/payment_intent_response.rb new file mode 100644 index 0000000..27c509d --- /dev/null +++ b/lib/monite/types/payment_intent_response.rb @@ -0,0 +1,191 @@ +# frozen_string_literal: true +require "date" +require_relative "invoice" +require_relative "payment_object" +require_relative "payer_account_response" +require_relative "monite_all_payment_methods_types" +require_relative "recipient_account_response" +require "ostruct" +require "json" + +module Monite + class PaymentIntentResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :updated_at + # @return [Integer] + attr_reader :amount + # @return [Integer] + attr_reader :application_fee_amount + # @return [String] + attr_reader :batch_payment_id + # @return [String] + attr_reader :currency + # @return [Monite::Invoice] + attr_reader :invoice + # @return [Monite::PaymentObject] + attr_reader :object + # @return [Monite::PayerAccountResponse] + attr_reader :payer + # @return [String] + attr_reader :payment_link_id + # @return [Array] + attr_reader :payment_methods + # @return [String] + attr_reader :payment_reference + # @return [String] + attr_reader :provider + # @return [Monite::RecipientAccountResponse] + attr_reader :recipient + # @return [Monite::MoniteAllPaymentMethodsTypes] + attr_reader :selected_payment_method + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param updated_at [DateTime] + # @param amount [Integer] + # @param application_fee_amount [Integer] + # @param batch_payment_id [String] + # @param currency [String] + # @param invoice [Monite::Invoice] + # @param object [Monite::PaymentObject] + # @param payer [Monite::PayerAccountResponse] + # @param payment_link_id [String] + # @param payment_methods [Array] + # @param payment_reference [String] + # @param provider [String] + # @param recipient [Monite::RecipientAccountResponse] + # @param selected_payment_method [Monite::MoniteAllPaymentMethodsTypes] + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentIntentResponse] + def initialize(id:, updated_at:, amount:, application_fee_amount: OMIT, batch_payment_id: OMIT, currency:, invoice: OMIT, object: OMIT, payer: OMIT, payment_link_id: OMIT, payment_methods:, payment_reference: OMIT, provider: OMIT, recipient:, selected_payment_method: OMIT, status:, additional_properties: nil) + @id = id + @updated_at = updated_at + @amount = amount + @application_fee_amount = application_fee_amount if application_fee_amount != OMIT + @batch_payment_id = batch_payment_id if batch_payment_id != OMIT + @currency = currency + @invoice = invoice if invoice != OMIT + @object = object if object != OMIT + @payer = payer if payer != OMIT + @payment_link_id = payment_link_id if payment_link_id != OMIT + @payment_methods = payment_methods + @payment_reference = payment_reference if payment_reference != OMIT + @provider = provider if provider != OMIT + @recipient = recipient + @selected_payment_method = selected_payment_method if selected_payment_method != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "updated_at": updated_at, "amount": amount, "application_fee_amount": application_fee_amount, "batch_payment_id": batch_payment_id, "currency": currency, "invoice": invoice, "object": object, "payer": payer, "payment_link_id": payment_link_id, "payment_methods": payment_methods, "payment_reference": payment_reference, "provider": provider, "recipient": recipient, "selected_payment_method": selected_payment_method, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentIntentResponse + # + # @param json_object [String] + # @return [Monite::PaymentIntentResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + amount = parsed_json["amount"] + application_fee_amount = parsed_json["application_fee_amount"] + batch_payment_id = parsed_json["batch_payment_id"] + currency = parsed_json["currency"] + unless parsed_json["invoice"].nil? + invoice = parsed_json["invoice"].to_json + invoice = Monite::Invoice.from_json(json_object: invoice) + else + invoice = nil + end + unless parsed_json["object"].nil? + object = parsed_json["object"].to_json + object = Monite::PaymentObject.from_json(json_object: object) + else + object = nil + end + unless parsed_json["payer"].nil? + payer = parsed_json["payer"].to_json + payer = Monite::PayerAccountResponse.from_json(json_object: payer) + else + payer = nil + end + payment_link_id = parsed_json["payment_link_id"] + payment_methods = parsed_json["payment_methods"] + payment_reference = parsed_json["payment_reference"] + provider = parsed_json["provider"] + unless parsed_json["recipient"].nil? + recipient = parsed_json["recipient"].to_json + recipient = Monite::RecipientAccountResponse.from_json(json_object: recipient) + else + recipient = nil + end + selected_payment_method = parsed_json["selected_payment_method"] + status = parsed_json["status"] + new( + id: id, + updated_at: updated_at, + amount: amount, + application_fee_amount: application_fee_amount, + batch_payment_id: batch_payment_id, + currency: currency, + invoice: invoice, + object: object, + payer: payer, + payment_link_id: payment_link_id, + payment_methods: payment_methods, + payment_reference: payment_reference, + provider: provider, + recipient: recipient, + selected_payment_method: selected_payment_method, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of PaymentIntentResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.amount.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.application_fee_amount&.is_a?(Integer) != false || raise("Passed value for field obj.application_fee_amount is not the expected type, validation failed.") + obj.batch_payment_id&.is_a?(String) != false || raise("Passed value for field obj.batch_payment_id is not the expected type, validation failed.") + obj.currency.is_a?(String) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.invoice.nil? || Monite::Invoice.validate_raw(obj: obj.invoice) + obj.object.nil? || Monite::PaymentObject.validate_raw(obj: obj.object) + obj.payer.nil? || Monite::PayerAccountResponse.validate_raw(obj: obj.payer) + obj.payment_link_id&.is_a?(String) != false || raise("Passed value for field obj.payment_link_id is not the expected type, validation failed.") + obj.payment_methods.is_a?(Array) != false || raise("Passed value for field obj.payment_methods is not the expected type, validation failed.") + obj.payment_reference&.is_a?(String) != false || raise("Passed value for field obj.payment_reference is not the expected type, validation failed.") + obj.provider&.is_a?(String) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") + Monite::RecipientAccountResponse.validate_raw(obj: obj.recipient) + obj.selected_payment_method&.is_a?(Monite::MoniteAllPaymentMethodsTypes) != false || raise("Passed value for field obj.selected_payment_method is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intents_list_response.rb b/lib/monite/types/payment_intents_list_response.rb new file mode 100644 index 0000000..d3fb3eb --- /dev/null +++ b/lib/monite/types/payment_intents_list_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "payment_intent_response" +require "ostruct" +require "json" + +module Monite + class PaymentIntentsListResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentIntentsListResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentIntentsListResponse + # + # @param json_object [String] + # @return [Monite::PaymentIntentsListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PaymentIntentResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of PaymentIntentsListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_intents_recipient.rb b/lib/monite/types/payment_intents_recipient.rb new file mode 100644 index 0000000..10eced6 --- /dev/null +++ b/lib/monite/types/payment_intents_recipient.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true +require_relative "payment_intent_payout_method" +require "ostruct" +require "json" + +module Monite + class PaymentIntentsRecipient + # @return [String] + attr_reader :id + # @return [String] + attr_reader :bank_account_id + # @return [Monite::PaymentIntentPayoutMethod] + attr_reader :payout_method + # @return [String] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param bank_account_id [String] + # @param payout_method [Monite::PaymentIntentPayoutMethod] + # @param type [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentIntentsRecipient] + def initialize(id:, bank_account_id: OMIT, payout_method: OMIT, type:, additional_properties: nil) + @id = id + @bank_account_id = bank_account_id if bank_account_id != OMIT + @payout_method = payout_method if payout_method != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "bank_account_id": bank_account_id, "payout_method": payout_method, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentIntentsRecipient + # + # @param json_object [String] + # @return [Monite::PaymentIntentsRecipient] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + bank_account_id = parsed_json["bank_account_id"] + payout_method = parsed_json["payout_method"] + type = parsed_json["type"] + new( + id: id, + bank_account_id: bank_account_id, + payout_method: payout_method, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentIntentsRecipient to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.bank_account_id is not the expected type, validation failed.") + obj.payout_method&.is_a?(Monite::PaymentIntentPayoutMethod) != false || raise("Passed value for field obj.payout_method is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_method.rb b/lib/monite/types/payment_method.rb new file mode 100644 index 0000000..02ec173 --- /dev/null +++ b/lib/monite/types/payment_method.rb @@ -0,0 +1,79 @@ +# frozen_string_literal: true +require_relative "payment_method_direction" +require_relative "monite_all_payment_methods" +require_relative "payment_method_status" +require_relative "monite_all_payment_methods_types" +require "ostruct" +require "json" + +module Monite + class PaymentMethod + # @return [Monite::PaymentMethodDirection] + attr_reader :direction + # @return [Monite::MoniteAllPaymentMethods] + attr_reader :name + # @return [Monite::PaymentMethodStatus] + attr_reader :status + # @return [Monite::MoniteAllPaymentMethodsTypes] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param direction [Monite::PaymentMethodDirection] + # @param name [Monite::MoniteAllPaymentMethods] + # @param status [Monite::PaymentMethodStatus] + # @param type [Monite::MoniteAllPaymentMethodsTypes] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentMethod] + def initialize(direction:, name:, status:, type:, additional_properties: nil) + @direction = direction + @name = name + @status = status + @type = type + @additional_properties = additional_properties + @_field_set = { "direction": direction, "name": name, "status": status, "type": type } + end +# Deserialize a JSON object to an instance of PaymentMethod + # + # @param json_object [String] + # @return [Monite::PaymentMethod] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + direction = parsed_json["direction"] + name = parsed_json["name"] + status = parsed_json["status"] + type = parsed_json["type"] + new( + direction: direction, + name: name, + status: status, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentMethod to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.direction.is_a?(Monite::PaymentMethodDirection) != false || raise("Passed value for field obj.direction is not the expected type, validation failed.") + obj.name.is_a?(Monite::MoniteAllPaymentMethods) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.status.is_a?(Monite::PaymentMethodStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.type.is_a?(Monite::MoniteAllPaymentMethodsTypes) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_method_direction.rb b/lib/monite/types/payment_method_direction.rb new file mode 100644 index 0000000..8425315 --- /dev/null +++ b/lib/monite/types/payment_method_direction.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PaymentMethodDirection + + RECEIVE = "receive" + SEND = "send" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_method_requirements.rb b/lib/monite/types/payment_method_requirements.rb new file mode 100644 index 0000000..ae22165 --- /dev/null +++ b/lib/monite/types/payment_method_requirements.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class PaymentMethodRequirements + # @return [DateTime] + attr_reader :current_deadline + # @return [Array] + attr_reader :currently_due + # @return [Array] + attr_reader :eventually_due + # @return [Array] + attr_reader :past_due + # @return [Array] + attr_reader :pending_verification + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param current_deadline [DateTime] + # @param currently_due [Array] + # @param eventually_due [Array] + # @param past_due [Array] + # @param pending_verification [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentMethodRequirements] + def initialize(current_deadline: OMIT, currently_due:, eventually_due:, past_due:, pending_verification:, additional_properties: nil) + @current_deadline = current_deadline if current_deadline != OMIT + @currently_due = currently_due + @eventually_due = eventually_due + @past_due = past_due + @pending_verification = pending_verification + @additional_properties = additional_properties + @_field_set = { "current_deadline": current_deadline, "currently_due": currently_due, "eventually_due": eventually_due, "past_due": past_due, "pending_verification": pending_verification }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentMethodRequirements + # + # @param json_object [String] + # @return [Monite::PaymentMethodRequirements] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + current_deadline = unless parsed_json["current_deadline"].nil? + DateTime.parse(parsed_json["current_deadline"]) +else + nil +end + currently_due = parsed_json["currently_due"] + eventually_due = parsed_json["eventually_due"] + past_due = parsed_json["past_due"] + pending_verification = parsed_json["pending_verification"] + new( + current_deadline: current_deadline, + currently_due: currently_due, + eventually_due: eventually_due, + past_due: past_due, + pending_verification: pending_verification, + additional_properties: struct + ) + end +# Serialize an instance of PaymentMethodRequirements to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.current_deadline&.is_a?(DateTime) != false || raise("Passed value for field obj.current_deadline is not the expected type, validation failed.") + obj.currently_due.is_a?(Array) != false || raise("Passed value for field obj.currently_due is not the expected type, validation failed.") + obj.eventually_due.is_a?(Array) != false || raise("Passed value for field obj.eventually_due is not the expected type, validation failed.") + obj.past_due.is_a?(Array) != false || raise("Passed value for field obj.past_due is not the expected type, validation failed.") + obj.pending_verification.is_a?(Array) != false || raise("Passed value for field obj.pending_verification is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_method_status.rb b/lib/monite/types/payment_method_status.rb new file mode 100644 index 0000000..df8cf72 --- /dev/null +++ b/lib/monite/types/payment_method_status.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PaymentMethodStatus + + ACTIVE = "active" + INACTIVE = "inactive" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_object.rb b/lib/monite/types/payment_object.rb new file mode 100644 index 0000000..15693f5 --- /dev/null +++ b/lib/monite/types/payment_object.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "payment_object_type" +require "ostruct" +require "json" + +module Monite + class PaymentObject + # @return [String] + attr_reader :id + # @return [Monite::PaymentObjectType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param type [Monite::PaymentObjectType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentObject] + def initialize(id:, type:, additional_properties: nil) + @id = id + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "type": type } + end +# Deserialize a JSON object to an instance of PaymentObject + # + # @param json_object [String] + # @return [Monite::PaymentObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + type = parsed_json["type"] + new( + id: id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.type.is_a?(Monite::PaymentObjectType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_object_payable.rb b/lib/monite/types/payment_object_payable.rb new file mode 100644 index 0000000..e423e06 --- /dev/null +++ b/lib/monite/types/payment_object_payable.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PaymentObjectPayable + # @return [String] + attr_reader :id + # @return [String] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param type [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentObjectPayable] + def initialize(id:, type:, additional_properties: nil) + @id = id + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "type": type } + end +# Deserialize a JSON object to an instance of PaymentObjectPayable + # + # @param json_object [String] + # @return [Monite::PaymentObjectPayable] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + type = parsed_json["type"] + new( + id: id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentObjectPayable to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_object_type.rb b/lib/monite/types/payment_object_type.rb new file mode 100644 index 0000000..905817b --- /dev/null +++ b/lib/monite/types/payment_object_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PaymentObjectType + + PAYABLE = "payable" + RECEIVABLE = "receivable" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_page_theme.rb b/lib/monite/types/payment_page_theme.rb new file mode 100644 index 0000000..0512bda --- /dev/null +++ b/lib/monite/types/payment_page_theme.rb @@ -0,0 +1,117 @@ +# frozen_string_literal: true +require_relative "button_theme" +require_relative "card_theme" +require "ostruct" +require "json" + +module Monite + class PaymentPageTheme + # @return [String] + attr_reader :background_color + # @return [String] + attr_reader :border_radius + # @return [Monite::ButtonTheme] + attr_reader :button + # @return [Monite::CardTheme] + attr_reader :card + # @return [String] + attr_reader :font_color + # @return [String] + attr_reader :font_family + # @return [String] + attr_reader :font_link_href + # @return [String] + attr_reader :logo_src + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param background_color [String] + # @param border_radius [String] + # @param button [Monite::ButtonTheme] + # @param card [Monite::CardTheme] + # @param font_color [String] + # @param font_family [String] + # @param font_link_href [String] + # @param logo_src [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentPageTheme] + def initialize(background_color: OMIT, border_radius: OMIT, button: OMIT, card: OMIT, font_color: OMIT, font_family: OMIT, font_link_href: OMIT, logo_src: OMIT, additional_properties: nil) + @background_color = background_color if background_color != OMIT + @border_radius = border_radius if border_radius != OMIT + @button = button if button != OMIT + @card = card if card != OMIT + @font_color = font_color if font_color != OMIT + @font_family = font_family if font_family != OMIT + @font_link_href = font_link_href if font_link_href != OMIT + @logo_src = logo_src if logo_src != OMIT + @additional_properties = additional_properties + @_field_set = { "background_color": background_color, "border_radius": border_radius, "button": button, "card": card, "font_color": font_color, "font_family": font_family, "font_link_href": font_link_href, "logo_src": logo_src }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentPageTheme + # + # @param json_object [String] + # @return [Monite::PaymentPageTheme] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + background_color = parsed_json["background_color"] + border_radius = parsed_json["border_radius"] + unless parsed_json["button"].nil? + button = parsed_json["button"].to_json + button = Monite::ButtonTheme.from_json(json_object: button) + else + button = nil + end + unless parsed_json["card"].nil? + card = parsed_json["card"].to_json + card = Monite::CardTheme.from_json(json_object: card) + else + card = nil + end + font_color = parsed_json["font_color"] + font_family = parsed_json["font_family"] + font_link_href = parsed_json["font_link_href"] + logo_src = parsed_json["logo_src"] + new( + background_color: background_color, + border_radius: border_radius, + button: button, + card: card, + font_color: font_color, + font_family: font_family, + font_link_href: font_link_href, + logo_src: logo_src, + additional_properties: struct + ) + end +# Serialize an instance of PaymentPageTheme to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.background_color&.is_a?(String) != false || raise("Passed value for field obj.background_color is not the expected type, validation failed.") + obj.border_radius&.is_a?(String) != false || raise("Passed value for field obj.border_radius is not the expected type, validation failed.") + obj.button.nil? || Monite::ButtonTheme.validate_raw(obj: obj.button) + obj.card.nil? || Monite::CardTheme.validate_raw(obj: obj.card) + obj.font_color&.is_a?(String) != false || raise("Passed value for field obj.font_color is not the expected type, validation failed.") + obj.font_family&.is_a?(String) != false || raise("Passed value for field obj.font_family is not the expected type, validation failed.") + obj.font_link_href&.is_a?(String) != false || raise("Passed value for field obj.font_link_href is not the expected type, validation failed.") + obj.logo_src&.is_a?(String) != false || raise("Passed value for field obj.logo_src is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_priority_enum.rb b/lib/monite/types/payment_priority_enum.rb new file mode 100644 index 0000000..ff676db --- /dev/null +++ b/lib/monite/types/payment_priority_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class PaymentPriorityEnum + + WORKING_CAPITAL = "working_capital" + BALANCED = "balanced" + BOTTOM_LINE = "bottom_line" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_received_event_data.rb b/lib/monite/types/payment_received_event_data.rb new file mode 100644 index 0000000..46abc6b --- /dev/null +++ b/lib/monite/types/payment_received_event_data.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Contains information about a payment received for an invoice. + class PaymentReceivedEventData + # @return [Integer] The remainimg amount due of the invoice, in [minor +# units](https://docs.monite.com/references/currencies#minor-units) of the +# currency. For example, $12.5 is represented as 1250. + attr_reader :amount_due + # @return [Integer] The payment amount, in minor units of the currency. + attr_reader :amount_paid + # @return [String] A user-defined comment about this payment, or `null` if no comment was provided. +# Comments are available only for payments recorded via `POST +# /receivables/{receivable_id}/mark_as_paid` and `POST +# /receivables/{receivable_id}/mark_as_partially_paid`. + attr_reader :comment + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param amount_due [Integer] The remainimg amount due of the invoice, in [minor +# units](https://docs.monite.com/references/currencies#minor-units) of the +# currency. For example, $12.5 is represented as 1250. + # @param amount_paid [Integer] The payment amount, in minor units of the currency. + # @param comment [String] A user-defined comment about this payment, or `null` if no comment was provided. +# Comments are available only for payments recorded via `POST +# /receivables/{receivable_id}/mark_as_paid` and `POST +# /receivables/{receivable_id}/mark_as_partially_paid`. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentReceivedEventData] + def initialize(amount_due:, amount_paid:, comment: OMIT, additional_properties: nil) + @amount_due = amount_due + @amount_paid = amount_paid + @comment = comment if comment != OMIT + @additional_properties = additional_properties + @_field_set = { "amount_due": amount_due, "amount_paid": amount_paid, "comment": comment }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentReceivedEventData + # + # @param json_object [String] + # @return [Monite::PaymentReceivedEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + amount_due = parsed_json["amount_due"] + amount_paid = parsed_json["amount_paid"] + comment = parsed_json["comment"] + new( + amount_due: amount_due, + amount_paid: amount_paid, + comment: comment, + additional_properties: struct + ) + end +# Serialize an instance of PaymentReceivedEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.amount_due.is_a?(Integer) != false || raise("Passed value for field obj.amount_due is not the expected type, validation failed.") + obj.amount_paid.is_a?(Integer) != false || raise("Passed value for field obj.amount_paid is not the expected type, validation failed.") + obj.comment&.is_a?(String) != false || raise("Passed value for field obj.comment is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_record_cursor_fields.rb b/lib/monite/types/payment_record_cursor_fields.rb new file mode 100644 index 0000000..8cded54 --- /dev/null +++ b/lib/monite/types/payment_record_cursor_fields.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class PaymentRecordCursorFields + + PAID_AT = "paid_at" + AMOUNT = "amount" + OVERPAID_AMOUNT = "overpaid_amount" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_record_object_request.rb b/lib/monite/types/payment_record_object_request.rb new file mode 100644 index 0000000..1fe2a88 --- /dev/null +++ b/lib/monite/types/payment_record_object_request.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "object_type_enum" +require "ostruct" +require "json" + +module Monite + class PaymentRecordObjectRequest + # @return [String] ID of the invoice + attr_reader :id + # @return [Monite::ObjectTypeEnum] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of the invoice + # @param type [Monite::ObjectTypeEnum] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentRecordObjectRequest] + def initialize(id:, type:, additional_properties: nil) + @id = id + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "type": type } + end +# Deserialize a JSON object to an instance of PaymentRecordObjectRequest + # + # @param json_object [String] + # @return [Monite::PaymentRecordObjectRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + type = parsed_json["type"] + new( + id: id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentRecordObjectRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.type.is_a?(Monite::ObjectTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_record_object_response.rb b/lib/monite/types/payment_record_object_response.rb new file mode 100644 index 0000000..b9cc2c9 --- /dev/null +++ b/lib/monite/types/payment_record_object_response.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "object_type_enum" +require "ostruct" +require "json" + +module Monite + class PaymentRecordObjectResponse + # @return [String] ID of the invoice + attr_reader :id + # @return [String] Status, in which object has been moved + attr_reader :new_status + # @return [String] Status, in which object was before payment + attr_reader :old_status + # @return [Monite::ObjectTypeEnum] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of the invoice + # @param new_status [String] Status, in which object has been moved + # @param old_status [String] Status, in which object was before payment + # @param type [Monite::ObjectTypeEnum] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentRecordObjectResponse] + def initialize(id:, new_status:, old_status:, type:, additional_properties: nil) + @id = id + @new_status = new_status + @old_status = old_status + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "new_status": new_status, "old_status": old_status, "type": type } + end +# Deserialize a JSON object to an instance of PaymentRecordObjectResponse + # + # @param json_object [String] + # @return [Monite::PaymentRecordObjectResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + new_status = parsed_json["new_status"] + old_status = parsed_json["old_status"] + type = parsed_json["type"] + new( + id: id, + new_status: new_status, + old_status: old_status, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PaymentRecordObjectResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.new_status.is_a?(String) != false || raise("Passed value for field obj.new_status is not the expected type, validation failed.") + obj.old_status.is_a?(String) != false || raise("Passed value for field obj.old_status is not the expected type, validation failed.") + obj.type.is_a?(Monite::ObjectTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_record_response.rb b/lib/monite/types/payment_record_response.rb new file mode 100644 index 0000000..8b109d0 --- /dev/null +++ b/lib/monite/types/payment_record_response.rb @@ -0,0 +1,124 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "payment_record_object_response" +require "date" +require "ostruct" +require "json" + +module Monite + class PaymentRecordResponse + # @return [String] + attr_reader :id + # @return [Integer] + attr_reader :amount + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [String] + attr_reader :entity_user_id + # @return [Boolean] + attr_reader :is_external + # @return [Monite::PaymentRecordObjectResponse] + attr_reader :object + # @return [Integer] Filled in a case, if payment amount is more, than total_amount + attr_reader :overpaid_amount + # @return [DateTime] + attr_reader :paid_at + # @return [String] + attr_reader :payment_intent_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param amount [Integer] + # @param currency [Monite::CurrencyEnum] + # @param entity_user_id [String] + # @param is_external [Boolean] + # @param object [Monite::PaymentRecordObjectResponse] + # @param overpaid_amount [Integer] Filled in a case, if payment amount is more, than total_amount + # @param paid_at [DateTime] + # @param payment_intent_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentRecordResponse] + def initialize(id:, amount:, currency:, entity_user_id: OMIT, is_external:, object:, overpaid_amount: OMIT, paid_at:, payment_intent_id:, additional_properties: nil) + @id = id + @amount = amount + @currency = currency + @entity_user_id = entity_user_id if entity_user_id != OMIT + @is_external = is_external + @object = object + @overpaid_amount = overpaid_amount if overpaid_amount != OMIT + @paid_at = paid_at + @payment_intent_id = payment_intent_id + @additional_properties = additional_properties + @_field_set = { "id": id, "amount": amount, "currency": currency, "entity_user_id": entity_user_id, "is_external": is_external, "object": object, "overpaid_amount": overpaid_amount, "paid_at": paid_at, "payment_intent_id": payment_intent_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentRecordResponse + # + # @param json_object [String] + # @return [Monite::PaymentRecordResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + amount = parsed_json["amount"] + currency = parsed_json["currency"] + entity_user_id = parsed_json["entity_user_id"] + is_external = parsed_json["is_external"] + unless parsed_json["object"].nil? + object = parsed_json["object"].to_json + object = Monite::PaymentRecordObjectResponse.from_json(json_object: object) + else + object = nil + end + overpaid_amount = parsed_json["overpaid_amount"] + paid_at = unless parsed_json["paid_at"].nil? + DateTime.parse(parsed_json["paid_at"]) +else + nil +end + payment_intent_id = parsed_json["payment_intent_id"] + new( + id: id, + amount: amount, + currency: currency, + entity_user_id: entity_user_id, + is_external: is_external, + object: object, + overpaid_amount: overpaid_amount, + paid_at: paid_at, + payment_intent_id: payment_intent_id, + additional_properties: struct + ) + end +# Serialize an instance of PaymentRecordResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.amount.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.entity_user_id is not the expected type, validation failed.") + obj.is_external.is_a?(Boolean) != false || raise("Passed value for field obj.is_external is not the expected type, validation failed.") + Monite::PaymentRecordObjectResponse.validate_raw(obj: obj.object) + obj.overpaid_amount&.is_a?(Integer) != false || raise("Passed value for field obj.overpaid_amount is not the expected type, validation failed.") + obj.paid_at.is_a?(DateTime) != false || raise("Passed value for field obj.paid_at is not the expected type, validation failed.") + obj.payment_intent_id.is_a?(String) != false || raise("Passed value for field obj.payment_intent_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_record_response_list.rb b/lib/monite/types/payment_record_response_list.rb new file mode 100644 index 0000000..7baaccc --- /dev/null +++ b/lib/monite/types/payment_record_response_list.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "payment_record_response" +require "ostruct" +require "json" + +module Monite + class PaymentRecordResponseList + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentRecordResponseList] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentRecordResponseList + # + # @param json_object [String] + # @return [Monite::PaymentRecordResponseList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PaymentRecordResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of PaymentRecordResponseList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_reminder_response.rb b/lib/monite/types/payment_reminder_response.rb new file mode 100644 index 0000000..89c57c1 --- /dev/null +++ b/lib/monite/types/payment_reminder_response.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "recipients" +require_relative "status_enum" +require_relative "reminder" +require "ostruct" +require "json" + +module Monite + class PaymentReminderResponse + # @return [String] + attr_reader :id + # @return [DateTime] Time at which the PaymentReminder was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the PaymentReminder was last updated. Timestamps follow the ISO +# 8601 standard. + attr_reader :updated_at + # @return [String] + attr_reader :entity_id + # @return [String] + attr_reader :name + # @return [Monite::Recipients] + attr_reader :recipients + # @return [Monite::StatusEnum] + attr_reader :status + # @return [Monite::Reminder] Reminder to send for first payment term + attr_reader :term_1_reminder + # @return [Monite::Reminder] Reminder to send for second payment term + attr_reader :term_2_reminder + # @return [Monite::Reminder] Reminder to send for final payment term + attr_reader :term_final_reminder + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Time at which the PaymentReminder was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the PaymentReminder was last updated. Timestamps follow the ISO +# 8601 standard. + # @param entity_id [String] + # @param name [String] + # @param recipients [Monite::Recipients] + # @param status [Monite::StatusEnum] + # @param term_1_reminder [Monite::Reminder] Reminder to send for first payment term + # @param term_2_reminder [Monite::Reminder] Reminder to send for second payment term + # @param term_final_reminder [Monite::Reminder] Reminder to send for final payment term + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentReminderResponse] + def initialize(id:, created_at:, updated_at:, entity_id:, name:, recipients: OMIT, status:, term_1_reminder: OMIT, term_2_reminder: OMIT, term_final_reminder: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @entity_id = entity_id + @name = name + @recipients = recipients if recipients != OMIT + @status = status + @term_1_reminder = term_1_reminder if term_1_reminder != OMIT + @term_2_reminder = term_2_reminder if term_2_reminder != OMIT + @term_final_reminder = term_final_reminder if term_final_reminder != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "entity_id": entity_id, "name": name, "recipients": recipients, "status": status, "term_1_reminder": term_1_reminder, "term_2_reminder": term_2_reminder, "term_final_reminder": term_final_reminder }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentReminderResponse + # + # @param json_object [String] + # @return [Monite::PaymentReminderResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + entity_id = parsed_json["entity_id"] + name = parsed_json["name"] + unless parsed_json["recipients"].nil? + recipients = parsed_json["recipients"].to_json + recipients = Monite::Recipients.from_json(json_object: recipients) + else + recipients = nil + end + status = parsed_json["status"] + unless parsed_json["term_1_reminder"].nil? + term_1_reminder = parsed_json["term_1_reminder"].to_json + term_1_reminder = Monite::Reminder.from_json(json_object: term_1_reminder) + else + term_1_reminder = nil + end + unless parsed_json["term_2_reminder"].nil? + term_2_reminder = parsed_json["term_2_reminder"].to_json + term_2_reminder = Monite::Reminder.from_json(json_object: term_2_reminder) + else + term_2_reminder = nil + end + unless parsed_json["term_final_reminder"].nil? + term_final_reminder = parsed_json["term_final_reminder"].to_json + term_final_reminder = Monite::Reminder.from_json(json_object: term_final_reminder) + else + term_final_reminder = nil + end + new( + id: id, + created_at: created_at, + updated_at: updated_at, + entity_id: entity_id, + name: name, + recipients: recipients, + status: status, + term_1_reminder: term_1_reminder, + term_2_reminder: term_2_reminder, + term_final_reminder: term_final_reminder, + additional_properties: struct + ) + end +# Serialize an instance of PaymentReminderResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.recipients.nil? || Monite::Recipients.validate_raw(obj: obj.recipients) + obj.status.is_a?(Monite::StatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.term_1_reminder.nil? || Monite::Reminder.validate_raw(obj: obj.term_1_reminder) + obj.term_2_reminder.nil? || Monite::Reminder.validate_raw(obj: obj.term_2_reminder) + obj.term_final_reminder.nil? || Monite::Reminder.validate_raw(obj: obj.term_final_reminder) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_requirements.rb b/lib/monite/types/payment_requirements.rb new file mode 100644 index 0000000..e287016 --- /dev/null +++ b/lib/monite/types/payment_requirements.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class PaymentRequirements + # @return [DateTime] + attr_reader :current_deadline + # @return [Array] + attr_reader :currently_due + # @return [Array] + attr_reader :eventually_due + # @return [Array] + attr_reader :pending_verification + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param current_deadline [DateTime] + # @param currently_due [Array] + # @param eventually_due [Array] + # @param pending_verification [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentRequirements] + def initialize(current_deadline: OMIT, currently_due:, eventually_due:, pending_verification:, additional_properties: nil) + @current_deadline = current_deadline if current_deadline != OMIT + @currently_due = currently_due + @eventually_due = eventually_due + @pending_verification = pending_verification + @additional_properties = additional_properties + @_field_set = { "current_deadline": current_deadline, "currently_due": currently_due, "eventually_due": eventually_due, "pending_verification": pending_verification }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentRequirements + # + # @param json_object [String] + # @return [Monite::PaymentRequirements] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + current_deadline = unless parsed_json["current_deadline"].nil? + DateTime.parse(parsed_json["current_deadline"]) +else + nil +end + currently_due = parsed_json["currently_due"] + eventually_due = parsed_json["eventually_due"] + pending_verification = parsed_json["pending_verification"] + new( + current_deadline: current_deadline, + currently_due: currently_due, + eventually_due: eventually_due, + pending_verification: pending_verification, + additional_properties: struct + ) + end +# Serialize an instance of PaymentRequirements to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.current_deadline&.is_a?(DateTime) != false || raise("Passed value for field obj.current_deadline is not the expected type, validation failed.") + obj.currently_due.is_a?(Array) != false || raise("Passed value for field obj.currently_due is not the expected type, validation failed.") + obj.eventually_due.is_a?(Array) != false || raise("Passed value for field obj.eventually_due is not the expected type, validation failed.") + obj.pending_verification.is_a?(Array) != false || raise("Passed value for field obj.pending_verification is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_term.rb b/lib/monite/types/payment_term.rb new file mode 100644 index 0000000..bf17b3c --- /dev/null +++ b/lib/monite/types/payment_term.rb @@ -0,0 +1,51 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PaymentTerm + # @return [Integer] The amount of days after the invoice issue date. + attr_reader :number_of_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param number_of_days [Integer] The amount of days after the invoice issue date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentTerm] + def initialize(number_of_days:, additional_properties: nil) + @number_of_days = number_of_days + @additional_properties = additional_properties + @_field_set = { "number_of_days": number_of_days } + end +# Deserialize a JSON object to an instance of PaymentTerm + # + # @param json_object [String] + # @return [Monite::PaymentTerm] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + number_of_days = parsed_json["number_of_days"] + new(number_of_days: number_of_days, additional_properties: struct) + end +# Serialize an instance of PaymentTerm to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.number_of_days.is_a?(Integer) != false || raise("Passed value for field obj.number_of_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_term_discount.rb b/lib/monite/types/payment_term_discount.rb new file mode 100644 index 0000000..e5253d9 --- /dev/null +++ b/lib/monite/types/payment_term_discount.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PaymentTermDiscount + # @return [Integer] The discount percentage in minor units. E.g., 200 means 2%. 1050 means 10.5%. + attr_reader :discount + # @return [Integer] The amount of days after the invoice issue date. + attr_reader :number_of_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param discount [Integer] The discount percentage in minor units. E.g., 200 means 2%. 1050 means 10.5%. + # @param number_of_days [Integer] The amount of days after the invoice issue date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentTermDiscount] + def initialize(discount:, number_of_days:, additional_properties: nil) + @discount = discount + @number_of_days = number_of_days + @additional_properties = additional_properties + @_field_set = { "discount": discount, "number_of_days": number_of_days } + end +# Deserialize a JSON object to an instance of PaymentTermDiscount + # + # @param json_object [String] + # @return [Monite::PaymentTermDiscount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + discount = parsed_json["discount"] + number_of_days = parsed_json["number_of_days"] + new( + discount: discount, + number_of_days: number_of_days, + additional_properties: struct + ) + end +# Serialize an instance of PaymentTermDiscount to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.discount.is_a?(Integer) != false || raise("Passed value for field obj.discount is not the expected type, validation failed.") + obj.number_of_days.is_a?(Integer) != false || raise("Passed value for field obj.number_of_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_term_discount_with_date.rb b/lib/monite/types/payment_term_discount_with_date.rb new file mode 100644 index 0000000..3396382 --- /dev/null +++ b/lib/monite/types/payment_term_discount_with_date.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PaymentTermDiscountWithDate + # @return [Integer] The discount percentage in minor units. E.g., 200 means 2%. 1050 means 10.5%. + attr_reader :discount + # @return [String] + attr_reader :end_date + # @return [Integer] The amount of days after the invoice issue date. + attr_reader :number_of_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param discount [Integer] The discount percentage in minor units. E.g., 200 means 2%. 1050 means 10.5%. + # @param end_date [String] + # @param number_of_days [Integer] The amount of days after the invoice issue date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentTermDiscountWithDate] + def initialize(discount:, end_date: OMIT, number_of_days:, additional_properties: nil) + @discount = discount + @end_date = end_date if end_date != OMIT + @number_of_days = number_of_days + @additional_properties = additional_properties + @_field_set = { "discount": discount, "end_date": end_date, "number_of_days": number_of_days }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentTermDiscountWithDate + # + # @param json_object [String] + # @return [Monite::PaymentTermDiscountWithDate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + discount = parsed_json["discount"] + end_date = parsed_json["end_date"] + number_of_days = parsed_json["number_of_days"] + new( + discount: discount, + end_date: end_date, + number_of_days: number_of_days, + additional_properties: struct + ) + end +# Serialize an instance of PaymentTermDiscountWithDate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.discount.is_a?(Integer) != false || raise("Passed value for field obj.discount is not the expected type, validation failed.") + obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.") + obj.number_of_days.is_a?(Integer) != false || raise("Passed value for field obj.number_of_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_terms.rb b/lib/monite/types/payment_terms.rb new file mode 100644 index 0000000..96191c6 --- /dev/null +++ b/lib/monite/types/payment_terms.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true +require_relative "payment_term_discount_with_date" +require_relative "term_final_with_date" +require "ostruct" +require "json" + +module Monite + class PaymentTerms + # @return [String] + attr_reader :id + # @return [String] + attr_reader :name + # @return [Monite::PaymentTermDiscountWithDate] The first tier of the payment term. Represents the terms of the first early +# discount. + attr_reader :term_1 + # @return [Monite::PaymentTermDiscountWithDate] The second tier of the payment term. Defines the terms of the second early +# discount. + attr_reader :term_2 + # @return [Monite::TermFinalWithDate] The final tier of the payment term. Defines the invoice due date. + attr_reader :term_final + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param name [String] + # @param term_1 [Monite::PaymentTermDiscountWithDate] The first tier of the payment term. Represents the terms of the first early +# discount. + # @param term_2 [Monite::PaymentTermDiscountWithDate] The second tier of the payment term. Defines the terms of the second early +# discount. + # @param term_final [Monite::TermFinalWithDate] The final tier of the payment term. Defines the invoice due date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentTerms] + def initialize(id:, name: OMIT, term_1: OMIT, term_2: OMIT, term_final:, additional_properties: nil) + @id = id + @name = name if name != OMIT + @term_1 = term_1 if term_1 != OMIT + @term_2 = term_2 if term_2 != OMIT + @term_final = term_final + @additional_properties = additional_properties + @_field_set = { "id": id, "name": name, "term_1": term_1, "term_2": term_2, "term_final": term_final }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentTerms + # + # @param json_object [String] + # @return [Monite::PaymentTerms] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + name = parsed_json["name"] + unless parsed_json["term_1"].nil? + term_1 = parsed_json["term_1"].to_json + term_1 = Monite::PaymentTermDiscountWithDate.from_json(json_object: term_1) + else + term_1 = nil + end + unless parsed_json["term_2"].nil? + term_2 = parsed_json["term_2"].to_json + term_2 = Monite::PaymentTermDiscountWithDate.from_json(json_object: term_2) + else + term_2 = nil + end + unless parsed_json["term_final"].nil? + term_final = parsed_json["term_final"].to_json + term_final = Monite::TermFinalWithDate.from_json(json_object: term_final) + else + term_final = nil + end + new( + id: id, + name: name, + term_1: term_1, + term_2: term_2, + term_final: term_final, + additional_properties: struct + ) + end +# Serialize an instance of PaymentTerms to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.term_1.nil? || Monite::PaymentTermDiscountWithDate.validate_raw(obj: obj.term_1) + obj.term_2.nil? || Monite::PaymentTermDiscountWithDate.validate_raw(obj: obj.term_2) + Monite::TermFinalWithDate.validate_raw(obj: obj.term_final) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_terms_list_response.rb b/lib/monite/types/payment_terms_list_response.rb new file mode 100644 index 0000000..335b0be --- /dev/null +++ b/lib/monite/types/payment_terms_list_response.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "payment_terms_response" +require "ostruct" +require "json" + +module Monite + class PaymentTermsListResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentTermsListResponse] + def initialize(data: OMIT, additional_properties: nil) + @data = data if data != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentTermsListResponse + # + # @param json_object [String] + # @return [Monite::PaymentTermsListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PaymentTermsResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of PaymentTermsListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data&.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payment_terms_response.rb b/lib/monite/types/payment_terms_response.rb new file mode 100644 index 0000000..4408479 --- /dev/null +++ b/lib/monite/types/payment_terms_response.rb @@ -0,0 +1,112 @@ +# frozen_string_literal: true +require_relative "payment_term_discount" +require_relative "payment_term" +require "ostruct" +require "json" + +module Monite + class PaymentTermsResponse + # @return [String] + attr_reader :id + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [Monite::PaymentTermDiscount] The first tier of the payment term. Represents the terms of the first early +# discount. + attr_reader :term_1 + # @return [Monite::PaymentTermDiscount] The second tier of the payment term. Defines the terms of the second early +# discount. + attr_reader :term_2 + # @return [Monite::PaymentTerm] The final tier of the payment term. Defines the invoice due date. + attr_reader :term_final + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param description [String] + # @param name [String] + # @param term_1 [Monite::PaymentTermDiscount] The first tier of the payment term. Represents the terms of the first early +# discount. + # @param term_2 [Monite::PaymentTermDiscount] The second tier of the payment term. Defines the terms of the second early +# discount. + # @param term_final [Monite::PaymentTerm] The final tier of the payment term. Defines the invoice due date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentTermsResponse] + def initialize(id:, description: OMIT, name:, term_1: OMIT, term_2: OMIT, term_final:, additional_properties: nil) + @id = id + @description = description if description != OMIT + @name = name + @term_1 = term_1 if term_1 != OMIT + @term_2 = term_2 if term_2 != OMIT + @term_final = term_final + @additional_properties = additional_properties + @_field_set = { "id": id, "description": description, "name": name, "term_1": term_1, "term_2": term_2, "term_final": term_final }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentTermsResponse + # + # @param json_object [String] + # @return [Monite::PaymentTermsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + description = parsed_json["description"] + name = parsed_json["name"] + unless parsed_json["term_1"].nil? + term_1 = parsed_json["term_1"].to_json + term_1 = Monite::PaymentTermDiscount.from_json(json_object: term_1) + else + term_1 = nil + end + unless parsed_json["term_2"].nil? + term_2 = parsed_json["term_2"].to_json + term_2 = Monite::PaymentTermDiscount.from_json(json_object: term_2) + else + term_2 = nil + end + unless parsed_json["term_final"].nil? + term_final = parsed_json["term_final"].to_json + term_final = Monite::PaymentTerm.from_json(json_object: term_final) + else + term_final = nil + end + new( + id: id, + description: description, + name: name, + term_1: term_1, + term_2: term_2, + term_final: term_final, + additional_properties: struct + ) + end +# Serialize an instance of PaymentTermsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.term_1.nil? || Monite::PaymentTermDiscount.validate_raw(obj: obj.term_1) + obj.term_2.nil? || Monite::PaymentTermDiscount.validate_raw(obj: obj.term_2) + Monite::PaymentTerm.validate_raw(obj: obj.term_final) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payments_batch_payment_request.rb b/lib/monite/types/payments_batch_payment_request.rb new file mode 100644 index 0000000..f6a1fbd --- /dev/null +++ b/lib/monite/types/payments_batch_payment_request.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true +require_relative "single_payment_intent" +require "ostruct" +require "json" + +module Monite + class PaymentsBatchPaymentRequest + # @return [String] + attr_reader :payer_bank_account_id + # @return [Array] + attr_reader :payment_intents + # @return [String] + attr_reader :payment_method + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param payer_bank_account_id [String] + # @param payment_intents [Array] + # @param payment_method [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentsBatchPaymentRequest] + def initialize(payer_bank_account_id:, payment_intents:, payment_method:, additional_properties: nil) + @payer_bank_account_id = payer_bank_account_id + @payment_intents = payment_intents + @payment_method = payment_method + @additional_properties = additional_properties + @_field_set = { "payer_bank_account_id": payer_bank_account_id, "payment_intents": payment_intents, "payment_method": payment_method } + end +# Deserialize a JSON object to an instance of PaymentsBatchPaymentRequest + # + # @param json_object [String] + # @return [Monite::PaymentsBatchPaymentRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + payer_bank_account_id = parsed_json["payer_bank_account_id"] + payment_intents = parsed_json["payment_intents"]&.map do | item | + item = item.to_json + Monite::SinglePaymentIntent.from_json(json_object: item) +end + payment_method = parsed_json["payment_method"] + new( + payer_bank_account_id: payer_bank_account_id, + payment_intents: payment_intents, + payment_method: payment_method, + additional_properties: struct + ) + end +# Serialize an instance of PaymentsBatchPaymentRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.payer_bank_account_id.is_a?(String) != false || raise("Passed value for field obj.payer_bank_account_id is not the expected type, validation failed.") + obj.payment_intents.is_a?(Array) != false || raise("Passed value for field obj.payment_intents is not the expected type, validation failed.") + obj.payment_method.is_a?(String) != false || raise("Passed value for field obj.payment_method is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payments_batch_payment_response.rb b/lib/monite/types/payments_batch_payment_response.rb new file mode 100644 index 0000000..1dbe1cb --- /dev/null +++ b/lib/monite/types/payments_batch_payment_response.rb @@ -0,0 +1,115 @@ +# frozen_string_literal: true +require "date" +require_relative "single_payment_intent_response" +require_relative "payments_batch_payment_status" +require "ostruct" +require "json" + +module Monite + class PaymentsBatchPaymentResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [Hash{String => Object}] + attr_reader :error + # @return [String] + attr_reader :payer_bank_account_id + # @return [Array] + attr_reader :payment_intents + # @return [String] + attr_reader :payment_method + # @return [Monite::PaymentsBatchPaymentStatus] + attr_reader :status + # @return [Integer] + attr_reader :total_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param error [Hash{String => Object}] + # @param payer_bank_account_id [String] + # @param payment_intents [Array] + # @param payment_method [String] + # @param status [Monite::PaymentsBatchPaymentStatus] + # @param total_amount [Integer] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentsBatchPaymentResponse] + def initialize(id:, created_at:, error: OMIT, payer_bank_account_id:, payment_intents:, payment_method:, status:, total_amount: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @error = error if error != OMIT + @payer_bank_account_id = payer_bank_account_id + @payment_intents = payment_intents + @payment_method = payment_method + @status = status + @total_amount = total_amount if total_amount != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "error": error, "payer_bank_account_id": payer_bank_account_id, "payment_intents": payment_intents, "payment_method": payment_method, "status": status, "total_amount": total_amount }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentsBatchPaymentResponse + # + # @param json_object [String] + # @return [Monite::PaymentsBatchPaymentResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + error = parsed_json["error"] + payer_bank_account_id = parsed_json["payer_bank_account_id"] + payment_intents = parsed_json["payment_intents"]&.map do | item | + item = item.to_json + Monite::SinglePaymentIntentResponse.from_json(json_object: item) +end + payment_method = parsed_json["payment_method"] + status = parsed_json["status"] + total_amount = parsed_json["total_amount"] + new( + id: id, + created_at: created_at, + error: error, + payer_bank_account_id: payer_bank_account_id, + payment_intents: payment_intents, + payment_method: payment_method, + status: status, + total_amount: total_amount, + additional_properties: struct + ) + end +# Serialize an instance of PaymentsBatchPaymentResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.error&.is_a?(Hash) != false || raise("Passed value for field obj.error is not the expected type, validation failed.") + obj.payer_bank_account_id.is_a?(String) != false || raise("Passed value for field obj.payer_bank_account_id is not the expected type, validation failed.") + obj.payment_intents.is_a?(Array) != false || raise("Passed value for field obj.payment_intents is not the expected type, validation failed.") + obj.payment_method.is_a?(String) != false || raise("Passed value for field obj.payment_method is not the expected type, validation failed.") + obj.status.is_a?(Monite::PaymentsBatchPaymentStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payments_batch_payment_status.rb b/lib/monite/types/payments_batch_payment_status.rb new file mode 100644 index 0000000..8524144 --- /dev/null +++ b/lib/monite/types/payments_batch_payment_status.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class PaymentsBatchPaymentStatus + + CREATED = "created" + PROCESSING = "processing" + PARTIALLY_SUCCESSFUL = "partially_successful" + SUCCEEDED = "succeeded" + FAILED = "failed" + + end +end \ No newline at end of file diff --git a/lib/monite/types/payments_settings_input.rb b/lib/monite/types/payments_settings_input.rb new file mode 100644 index 0000000..77d772b --- /dev/null +++ b/lib/monite/types/payments_settings_input.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "payment_page_theme" +require "ostruct" +require "json" + +module Monite + class PaymentsSettingsInput + # @return [String] + attr_reader :payment_page_domain + # @return [Monite::PaymentPageTheme] + attr_reader :payment_page_theme + # @return [String] The support email address + attr_reader :support_email + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param payment_page_domain [String] + # @param payment_page_theme [Monite::PaymentPageTheme] + # @param support_email [String] The support email address + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentsSettingsInput] + def initialize(payment_page_domain: OMIT, payment_page_theme: OMIT, support_email: OMIT, additional_properties: nil) + @payment_page_domain = payment_page_domain if payment_page_domain != OMIT + @payment_page_theme = payment_page_theme if payment_page_theme != OMIT + @support_email = support_email if support_email != OMIT + @additional_properties = additional_properties + @_field_set = { "payment_page_domain": payment_page_domain, "payment_page_theme": payment_page_theme, "support_email": support_email }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentsSettingsInput + # + # @param json_object [String] + # @return [Monite::PaymentsSettingsInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + payment_page_domain = parsed_json["payment_page_domain"] + unless parsed_json["payment_page_theme"].nil? + payment_page_theme = parsed_json["payment_page_theme"].to_json + payment_page_theme = Monite::PaymentPageTheme.from_json(json_object: payment_page_theme) + else + payment_page_theme = nil + end + support_email = parsed_json["support_email"] + new( + payment_page_domain: payment_page_domain, + payment_page_theme: payment_page_theme, + support_email: support_email, + additional_properties: struct + ) + end +# Serialize an instance of PaymentsSettingsInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.payment_page_domain&.is_a?(String) != false || raise("Passed value for field obj.payment_page_domain is not the expected type, validation failed.") + obj.payment_page_theme.nil? || Monite::PaymentPageTheme.validate_raw(obj: obj.payment_page_theme) + obj.support_email&.is_a?(String) != false || raise("Passed value for field obj.support_email is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/payments_settings_output.rb b/lib/monite/types/payments_settings_output.rb new file mode 100644 index 0000000..8e4733c --- /dev/null +++ b/lib/monite/types/payments_settings_output.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "payment_page_theme" +require "ostruct" +require "json" + +module Monite + class PaymentsSettingsOutput + # @return [String] + attr_reader :payment_page_domain + # @return [Monite::PaymentPageTheme] + attr_reader :payment_page_theme + # @return [String] The support email address + attr_reader :support_email + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param payment_page_domain [String] + # @param payment_page_theme [Monite::PaymentPageTheme] + # @param support_email [String] The support email address + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PaymentsSettingsOutput] + def initialize(payment_page_domain: OMIT, payment_page_theme: OMIT, support_email: OMIT, additional_properties: nil) + @payment_page_domain = payment_page_domain if payment_page_domain != OMIT + @payment_page_theme = payment_page_theme if payment_page_theme != OMIT + @support_email = support_email if support_email != OMIT + @additional_properties = additional_properties + @_field_set = { "payment_page_domain": payment_page_domain, "payment_page_theme": payment_page_theme, "support_email": support_email }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PaymentsSettingsOutput + # + # @param json_object [String] + # @return [Monite::PaymentsSettingsOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + payment_page_domain = parsed_json["payment_page_domain"] + unless parsed_json["payment_page_theme"].nil? + payment_page_theme = parsed_json["payment_page_theme"].to_json + payment_page_theme = Monite::PaymentPageTheme.from_json(json_object: payment_page_theme) + else + payment_page_theme = nil + end + support_email = parsed_json["support_email"] + new( + payment_page_domain: payment_page_domain, + payment_page_theme: payment_page_theme, + support_email: support_email, + additional_properties: struct + ) + end +# Serialize an instance of PaymentsSettingsOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.payment_page_domain&.is_a?(String) != false || raise("Passed value for field obj.payment_page_domain is not the expected type, validation failed.") + obj.payment_page_theme.nil? || Monite::PaymentPageTheme.validate_raw(obj: obj.payment_page_theme) + obj.support_email&.is_a?(String) != false || raise("Passed value for field obj.support_email is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/permission_enum.rb b/lib/monite/types/permission_enum.rb new file mode 100644 index 0000000..60015ff --- /dev/null +++ b/lib/monite/types/permission_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class PermissionEnum + + ALLOWED = "allowed" + ALLOWED_FOR_OWN = "allowed_for_own" + NOT_ALLOWED = "not_allowed" + + end +end \ No newline at end of file diff --git a/lib/monite/types/person_address_request.rb b/lib/monite/types/person_address_request.rb new file mode 100644 index 0000000..a70fbf0 --- /dev/null +++ b/lib/monite/types/person_address_request.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class PersonAddressRequest + # @return [String] City, district, suburb, town, or village + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter country code (ISO 3166-1 alpha-2) + attr_reader :country + # @return [String] Address line 1 (e.g., street, PO Box, or company name) + attr_reader :line_1 + # @return [String] Address line 2 (e.g., apartment, suite, unit, or building) + attr_reader :line_2 + # @return [String] ZIP or postal code + attr_reader :postal_code + # @return [String] State, county, province, or region + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City, district, suburb, town, or village + # @param country [Monite::AllowedCountries] Two-letter country code (ISO 3166-1 alpha-2) + # @param line_1 [String] Address line 1 (e.g., street, PO Box, or company name) + # @param line_2 [String] Address line 2 (e.g., apartment, suite, unit, or building) + # @param postal_code [String] ZIP or postal code + # @param state [String] State, county, province, or region + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonAddressRequest] + def initialize(city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PersonAddressRequest + # + # @param json_object [String] + # @return [Monite::PersonAddressRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of PersonAddressRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/person_address_response.rb b/lib/monite/types/person_address_response.rb new file mode 100644 index 0000000..e9011da --- /dev/null +++ b/lib/monite/types/person_address_response.rb @@ -0,0 +1,91 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PersonAddressResponse + # @return [String] City, district, suburb, town, or village + attr_reader :city + # @return [String] Two-letter country code (ISO 3166-1 alpha-2) + attr_reader :country + # @return [String] Address line 1 (e.g., street, PO Box, or company name) + attr_reader :line_1 + # @return [String] Address line 2 (e.g., apartment, suite, unit, or building) + attr_reader :line_2 + # @return [String] ZIP or postal code + attr_reader :postal_code + # @return [String] State, county, province, or region + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City, district, suburb, town, or village + # @param country [String] Two-letter country code (ISO 3166-1 alpha-2) + # @param line_1 [String] Address line 1 (e.g., street, PO Box, or company name) + # @param line_2 [String] Address line 2 (e.g., apartment, suite, unit, or building) + # @param postal_code [String] ZIP or postal code + # @param state [String] State, county, province, or region + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonAddressResponse] + def initialize(city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PersonAddressResponse + # + # @param json_object [String] + # @return [Monite::PersonAddressResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of PersonAddressResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(String) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/person_onboarding_documents.rb b/lib/monite/types/person_onboarding_documents.rb new file mode 100644 index 0000000..fa5d24f --- /dev/null +++ b/lib/monite/types/person_onboarding_documents.rb @@ -0,0 +1,77 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PersonOnboardingDocuments + # @return [String] + attr_reader :verification_document_front + # @return [String] + attr_reader :verification_document_back + # @return [String] + attr_reader :additional_verification_document_front + # @return [String] + attr_reader :additional_verification_document_back + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param verification_document_front [String] + # @param verification_document_back [String] + # @param additional_verification_document_front [String] + # @param additional_verification_document_back [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonOnboardingDocuments] + def initialize(verification_document_front: OMIT, verification_document_back: OMIT, additional_verification_document_front: OMIT, additional_verification_document_back: OMIT, additional_properties: nil) + @verification_document_front = verification_document_front if verification_document_front != OMIT + @verification_document_back = verification_document_back if verification_document_back != OMIT + @additional_verification_document_front = additional_verification_document_front if additional_verification_document_front != OMIT + @additional_verification_document_back = additional_verification_document_back if additional_verification_document_back != OMIT + @additional_properties = additional_properties + @_field_set = { "verification_document_front": verification_document_front, "verification_document_back": verification_document_back, "additional_verification_document_front": additional_verification_document_front, "additional_verification_document_back": additional_verification_document_back }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PersonOnboardingDocuments + # + # @param json_object [String] + # @return [Monite::PersonOnboardingDocuments] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + verification_document_front = parsed_json["verification_document_front"] + verification_document_back = parsed_json["verification_document_back"] + additional_verification_document_front = parsed_json["additional_verification_document_front"] + additional_verification_document_back = parsed_json["additional_verification_document_back"] + new( + verification_document_front: verification_document_front, + verification_document_back: verification_document_back, + additional_verification_document_front: additional_verification_document_front, + additional_verification_document_back: additional_verification_document_back, + additional_properties: struct + ) + end +# Serialize an instance of PersonOnboardingDocuments to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.verification_document_front&.is_a?(String) != false || raise("Passed value for field obj.verification_document_front is not the expected type, validation failed.") + obj.verification_document_back&.is_a?(String) != false || raise("Passed value for field obj.verification_document_back is not the expected type, validation failed.") + obj.additional_verification_document_front&.is_a?(String) != false || raise("Passed value for field obj.additional_verification_document_front is not the expected type, validation failed.") + obj.additional_verification_document_back&.is_a?(String) != false || raise("Passed value for field obj.additional_verification_document_back is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/person_relationship_request.rb b/lib/monite/types/person_relationship_request.rb new file mode 100644 index 0000000..89e47ae --- /dev/null +++ b/lib/monite/types/person_relationship_request.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PersonRelationshipRequest + # @return [Boolean] Whether the person is a director of the account's legal entity + attr_reader :director + # @return [Boolean] Whether the person has significant responsibility to control, manage, or direct +# the organization + attr_reader :executive + # @return [Boolean] Whether the person is an owner of the account's legal entity + attr_reader :owner + # @return [Float] The percent owned by the person of the account's legal entity + attr_reader :percent_ownership + # @return [Boolean] Whether the person is authorized as the primary representative of the account + attr_reader :representative + # @return [String] The person's title (e.g., CEO, Support Engineer) + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param director [Boolean] Whether the person is a director of the account's legal entity + # @param executive [Boolean] Whether the person has significant responsibility to control, manage, or direct +# the organization + # @param owner [Boolean] Whether the person is an owner of the account's legal entity + # @param percent_ownership [Float] The percent owned by the person of the account's legal entity + # @param representative [Boolean] Whether the person is authorized as the primary representative of the account + # @param title [String] The person's title (e.g., CEO, Support Engineer) + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonRelationshipRequest] + def initialize(director: OMIT, executive: OMIT, owner: OMIT, percent_ownership: OMIT, representative: OMIT, title: OMIT, additional_properties: nil) + @director = director if director != OMIT + @executive = executive if executive != OMIT + @owner = owner if owner != OMIT + @percent_ownership = percent_ownership if percent_ownership != OMIT + @representative = representative if representative != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "director": director, "executive": executive, "owner": owner, "percent_ownership": percent_ownership, "representative": representative, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PersonRelationshipRequest + # + # @param json_object [String] + # @return [Monite::PersonRelationshipRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + director = parsed_json["director"] + executive = parsed_json["executive"] + owner = parsed_json["owner"] + percent_ownership = parsed_json["percent_ownership"] + representative = parsed_json["representative"] + title = parsed_json["title"] + new( + director: director, + executive: executive, + owner: owner, + percent_ownership: percent_ownership, + representative: representative, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of PersonRelationshipRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.director&.is_a?(Boolean) != false || raise("Passed value for field obj.director is not the expected type, validation failed.") + obj.executive&.is_a?(Boolean) != false || raise("Passed value for field obj.executive is not the expected type, validation failed.") + obj.owner&.is_a?(Boolean) != false || raise("Passed value for field obj.owner is not the expected type, validation failed.") + obj.percent_ownership&.is_a?(Float) != false || raise("Passed value for field obj.percent_ownership is not the expected type, validation failed.") + obj.representative&.is_a?(Boolean) != false || raise("Passed value for field obj.representative is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/person_relationship_response.rb b/lib/monite/types/person_relationship_response.rb new file mode 100644 index 0000000..b0db6de --- /dev/null +++ b/lib/monite/types/person_relationship_response.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PersonRelationshipResponse + # @return [Boolean] Whether the person is a director of the account's legal entity + attr_reader :director + # @return [Boolean] Whether the person has significant responsibility to control, manage, or direct +# the organization + attr_reader :executive + # @return [Boolean] Whether the person is an owner of the account's legal entity + attr_reader :owner + # @return [Float] The percent owned by the person of the account's legal entity + attr_reader :percent_ownership + # @return [Boolean] Whether the person is authorized as the primary representative of the account + attr_reader :representative + # @return [String] The person's title (e.g., CEO, Support Engineer) + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param director [Boolean] Whether the person is a director of the account's legal entity + # @param executive [Boolean] Whether the person has significant responsibility to control, manage, or direct +# the organization + # @param owner [Boolean] Whether the person is an owner of the account's legal entity + # @param percent_ownership [Float] The percent owned by the person of the account's legal entity + # @param representative [Boolean] Whether the person is authorized as the primary representative of the account + # @param title [String] The person's title (e.g., CEO, Support Engineer) + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonRelationshipResponse] + def initialize(director: OMIT, executive: OMIT, owner: OMIT, percent_ownership: OMIT, representative: OMIT, title: OMIT, additional_properties: nil) + @director = director if director != OMIT + @executive = executive if executive != OMIT + @owner = owner if owner != OMIT + @percent_ownership = percent_ownership if percent_ownership != OMIT + @representative = representative if representative != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "director": director, "executive": executive, "owner": owner, "percent_ownership": percent_ownership, "representative": representative, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PersonRelationshipResponse + # + # @param json_object [String] + # @return [Monite::PersonRelationshipResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + director = parsed_json["director"] + executive = parsed_json["executive"] + owner = parsed_json["owner"] + percent_ownership = parsed_json["percent_ownership"] + representative = parsed_json["representative"] + title = parsed_json["title"] + new( + director: director, + executive: executive, + owner: owner, + percent_ownership: percent_ownership, + representative: representative, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of PersonRelationshipResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.director&.is_a?(Boolean) != false || raise("Passed value for field obj.director is not the expected type, validation failed.") + obj.executive&.is_a?(Boolean) != false || raise("Passed value for field obj.executive is not the expected type, validation failed.") + obj.owner&.is_a?(Boolean) != false || raise("Passed value for field obj.owner is not the expected type, validation failed.") + obj.percent_ownership&.is_a?(Float) != false || raise("Passed value for field obj.percent_ownership is not the expected type, validation failed.") + obj.representative&.is_a?(Boolean) != false || raise("Passed value for field obj.representative is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/person_response.rb b/lib/monite/types/person_response.rb new file mode 100644 index 0000000..6d822a4 --- /dev/null +++ b/lib/monite/types/person_response.rb @@ -0,0 +1,183 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "person_address_response" +require_relative "allowed_countries" +require_relative "person_relationship_response" +require "ostruct" +require "json" + +module Monite + class PersonResponse + # @return [String] The person's unique identifier + attr_reader :id + # @return [DateTime] Time at which the person was created + attr_reader :created_at + # @return [DateTime] Time at which the person was updated + attr_reader :updated_at + # @return [Monite::PersonAddressResponse] The person's address + attr_reader :address + # @return [Monite::AllowedCountries] Required for persons of US entities. The country of the person's citizenship, as +# a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple +# citizenship, specify any. + attr_reader :citizenship + # @return [String] ID of the entity user who created this person, or null if the person was created +# using a partner access token. + attr_reader :created_by_entity_user_id + # @return [String] The person's date of birth + attr_reader :date_of_birth + # @return [String] The person's email address + attr_reader :email + # @return [String] Entity ID + attr_reader :entity_id + # @return [String] The person's first name + attr_reader :first_name + # @return [String] The person's ID number, as appropriate for their country + attr_reader :id_number + # @return [String] The person's last name + attr_reader :last_name + # @return [String] The person's phone number + attr_reader :phone + # @return [Monite::PersonRelationshipResponse] Describes the person's relationship to the entity + attr_reader :relationship + # @return [String] The last four digits of the person's Social Security number + attr_reader :ssn_last_4 + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] The person's unique identifier + # @param created_at [DateTime] Time at which the person was created + # @param updated_at [DateTime] Time at which the person was updated + # @param address [Monite::PersonAddressResponse] The person's address + # @param citizenship [Monite::AllowedCountries] Required for persons of US entities. The country of the person's citizenship, as +# a two-letter country code (ISO 3166-1 alpha-2). In case of dual or multiple +# citizenship, specify any. + # @param created_by_entity_user_id [String] ID of the entity user who created this person, or null if the person was created +# using a partner access token. + # @param date_of_birth [String] The person's date of birth + # @param email [String] The person's email address + # @param entity_id [String] Entity ID + # @param first_name [String] The person's first name + # @param id_number [String] The person's ID number, as appropriate for their country + # @param last_name [String] The person's last name + # @param phone [String] The person's phone number + # @param relationship [Monite::PersonRelationshipResponse] Describes the person's relationship to the entity + # @param ssn_last_4 [String] The last four digits of the person's Social Security number + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonResponse] + def initialize(id:, created_at:, updated_at:, address: OMIT, citizenship: OMIT, created_by_entity_user_id: OMIT, date_of_birth: OMIT, email:, entity_id:, first_name:, id_number: OMIT, last_name:, phone: OMIT, relationship:, ssn_last_4: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @address = address if address != OMIT + @citizenship = citizenship if citizenship != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @date_of_birth = date_of_birth if date_of_birth != OMIT + @email = email + @entity_id = entity_id + @first_name = first_name + @id_number = id_number if id_number != OMIT + @last_name = last_name + @phone = phone if phone != OMIT + @relationship = relationship + @ssn_last_4 = ssn_last_4 if ssn_last_4 != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "address": address, "citizenship": citizenship, "created_by_entity_user_id": created_by_entity_user_id, "date_of_birth": date_of_birth, "email": email, "entity_id": entity_id, "first_name": first_name, "id_number": id_number, "last_name": last_name, "phone": phone, "relationship": relationship, "ssn_last_4": ssn_last_4 }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PersonResponse + # + # @param json_object [String] + # @return [Monite::PersonResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::PersonAddressResponse.from_json(json_object: address) + else + address = nil + end + citizenship = parsed_json["citizenship"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + date_of_birth = parsed_json["date_of_birth"] + email = parsed_json["email"] + entity_id = parsed_json["entity_id"] + first_name = parsed_json["first_name"] + id_number = parsed_json["id_number"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + unless parsed_json["relationship"].nil? + relationship = parsed_json["relationship"].to_json + relationship = Monite::PersonRelationshipResponse.from_json(json_object: relationship) + else + relationship = nil + end + ssn_last_4 = parsed_json["ssn_last_4"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + address: address, + citizenship: citizenship, + created_by_entity_user_id: created_by_entity_user_id, + date_of_birth: date_of_birth, + email: email, + entity_id: entity_id, + first_name: first_name, + id_number: id_number, + last_name: last_name, + phone: phone, + relationship: relationship, + ssn_last_4: ssn_last_4, + additional_properties: struct + ) + end +# Serialize an instance of PersonResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.address.nil? || Monite::PersonAddressResponse.validate_raw(obj: obj.address) + obj.citizenship&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.citizenship is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.date_of_birth&.is_a?(String) != false || raise("Passed value for field obj.date_of_birth is not the expected type, validation failed.") + obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.id_number&.is_a?(String) != false || raise("Passed value for field obj.id_number is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + Monite::PersonRelationshipResponse.validate_raw(obj: obj.relationship) + obj.ssn_last_4&.is_a?(String) != false || raise("Passed value for field obj.ssn_last_4 is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/persons_response.rb b/lib/monite/types/persons_response.rb new file mode 100644 index 0000000..c3b85a6 --- /dev/null +++ b/lib/monite/types/persons_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "person_response" +require "ostruct" +require "json" + +module Monite + class PersonsResponse + # @return [Array] array of objects of type person + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] array of objects of type person + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PersonsResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of PersonsResponse + # + # @param json_object [String] + # @return [Monite::PersonsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PersonResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of PersonsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/platform.rb b/lib/monite/types/platform.rb new file mode 100644 index 0000000..f7bb054 --- /dev/null +++ b/lib/monite/types/platform.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + class Platform + + XERO = "xero" + QUICKBOOKS = "quickbooks" + QUICKBOOKS_ONLINE = "quickbooks_online" + QUICKBOOKS_ONLINE_SANDBOX = "quickbooks_online_sandbox" + + end +end \ No newline at end of file diff --git a/lib/monite/types/preview_schema.rb b/lib/monite/types/preview_schema.rb new file mode 100644 index 0000000..f71d11b --- /dev/null +++ b/lib/monite/types/preview_schema.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A preview image generated for a file. + class PreviewSchema + # @return [Integer] The image height in pixels. + attr_reader :height + # @return [String] The image URL. + attr_reader :url + # @return [Integer] The image width in pixels. + attr_reader :width + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param height [Integer] The image height in pixels. + # @param url [String] The image URL. + # @param width [Integer] The image width in pixels. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PreviewSchema] + def initialize(height:, url:, width:, additional_properties: nil) + @height = height + @url = url + @width = width + @additional_properties = additional_properties + @_field_set = { "height": height, "url": url, "width": width } + end +# Deserialize a JSON object to an instance of PreviewSchema + # + # @param json_object [String] + # @return [Monite::PreviewSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + height = parsed_json["height"] + url = parsed_json["url"] + width = parsed_json["width"] + new( + height: height, + url: url, + width: width, + additional_properties: struct + ) + end +# Serialize an instance of PreviewSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.height.is_a?(Integer) != false || raise("Passed value for field obj.height is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + obj.width.is_a?(Integer) != false || raise("Passed value for field obj.width is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/preview_schema_2.rb b/lib/monite/types/preview_schema_2.rb new file mode 100644 index 0000000..38b4886 --- /dev/null +++ b/lib/monite/types/preview_schema_2.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A preview image generated for a file. + class PreviewSchema2 + # @return [String] The image URL. + attr_reader :url + # @return [Integer] The image width in pixels. + attr_reader :width + # @return [Integer] The image height in pixels. + attr_reader :height + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param url [String] The image URL. + # @param width [Integer] The image width in pixels. + # @param height [Integer] The image height in pixels. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PreviewSchema2] + def initialize(url:, width:, height:, additional_properties: nil) + @url = url + @width = width + @height = height + @additional_properties = additional_properties + @_field_set = { "url": url, "width": width, "height": height } + end +# Deserialize a JSON object to an instance of PreviewSchema2 + # + # @param json_object [String] + # @return [Monite::PreviewSchema2] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + url = parsed_json["url"] + width = parsed_json["width"] + height = parsed_json["height"] + new( + url: url, + width: width, + height: height, + additional_properties: struct + ) + end +# Serialize an instance of PreviewSchema2 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + obj.width.is_a?(Integer) != false || raise("Passed value for field obj.width is not the expected type, validation failed.") + obj.height.is_a?(Integer) != false || raise("Passed value for field obj.height is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/preview_schema_3.rb b/lib/monite/types/preview_schema_3.rb new file mode 100644 index 0000000..579a153 --- /dev/null +++ b/lib/monite/types/preview_schema_3.rb @@ -0,0 +1,69 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A preview image generated for a file. + class PreviewSchema3 + # @return [Integer] The image height in pixels. + attr_reader :height + # @return [String] The image URL. + attr_reader :url + # @return [Integer] The image width in pixels. + attr_reader :width + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param height [Integer] The image height in pixels. + # @param url [String] The image URL. + # @param width [Integer] The image width in pixels. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PreviewSchema3] + def initialize(height:, url:, width:, additional_properties: nil) + @height = height + @url = url + @width = width + @additional_properties = additional_properties + @_field_set = { "height": height, "url": url, "width": width } + end +# Deserialize a JSON object to an instance of PreviewSchema3 + # + # @param json_object [String] + # @return [Monite::PreviewSchema3] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + height = parsed_json["height"] + url = parsed_json["url"] + width = parsed_json["width"] + new( + height: height, + url: url, + width: width, + additional_properties: struct + ) + end +# Serialize an instance of PreviewSchema3 to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.height.is_a?(Integer) != false || raise("Passed value for field obj.height is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + obj.width.is_a?(Integer) != false || raise("Passed value for field obj.width is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/preview_template_response.rb b/lib/monite/types/preview_template_response.rb new file mode 100644 index 0000000..9937718 --- /dev/null +++ b/lib/monite/types/preview_template_response.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PreviewTemplateResponse + # @return [String] + attr_reader :body_preview + # @return [String] + attr_reader :subject_preview + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param body_preview [String] + # @param subject_preview [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PreviewTemplateResponse] + def initialize(body_preview:, subject_preview:, additional_properties: nil) + @body_preview = body_preview + @subject_preview = subject_preview + @additional_properties = additional_properties + @_field_set = { "body_preview": body_preview, "subject_preview": subject_preview } + end +# Deserialize a JSON object to an instance of PreviewTemplateResponse + # + # @param json_object [String] + # @return [Monite::PreviewTemplateResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + body_preview = parsed_json["body_preview"] + subject_preview = parsed_json["subject_preview"] + new( + body_preview: body_preview, + subject_preview: subject_preview, + additional_properties: struct + ) + end +# Serialize an instance of PreviewTemplateResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body_preview.is_a?(String) != false || raise("Passed value for field obj.body_preview is not the expected type, validation failed.") + obj.subject_preview.is_a?(String) != false || raise("Passed value for field obj.subject_preview is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/price.rb b/lib/monite/types/price.rb new file mode 100644 index 0000000..57eba7e --- /dev/null +++ b/lib/monite/types/price.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite + class Price + # @return [Monite::CurrencyEnum] The currency in which the price of the product is set. + attr_reader :currency + # @return [Integer] The actual price of the product. + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param currency [Monite::CurrencyEnum] The currency in which the price of the product is set. + # @param value [Integer] The actual price of the product. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Price] + def initialize(currency:, value:, additional_properties: nil) + @currency = currency + @value = value + @additional_properties = additional_properties + @_field_set = { "currency": currency, "value": value } + end +# Deserialize a JSON object to an instance of Price + # + # @param json_object [String] + # @return [Monite::Price] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + currency = parsed_json["currency"] + value = parsed_json["value"] + new( + currency: currency, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of Price to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.value.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/pricing_plan.rb b/lib/monite/types/pricing_plan.rb new file mode 100644 index 0000000..b800a72 --- /dev/null +++ b/lib/monite/types/pricing_plan.rb @@ -0,0 +1,81 @@ +# frozen_string_literal: true +require_relative "wc_repayment_type" +require "ostruct" +require "json" + +module Monite +# A pricing plan of a financing offer + class PricingPlan + # @return [Integer] Advance rate percentage. 10000 means 100% + attr_reader :advance_rate_percentage + # @return [Integer] Transaction fee percentage. 300 means 3.00% + attr_reader :fee_percentage + # @return [Monite::WcRepaymentType] Repayment type of the loan. + attr_reader :repayment_type + # @return [Integer] This amount of days after which the repayment duration is due. This is only +# applicable for FIXED_DURATION repayment type + attr_reader :repayment_duration_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param advance_rate_percentage [Integer] Advance rate percentage. 10000 means 100% + # @param fee_percentage [Integer] Transaction fee percentage. 300 means 3.00% + # @param repayment_type [Monite::WcRepaymentType] Repayment type of the loan. + # @param repayment_duration_days [Integer] This amount of days after which the repayment duration is due. This is only +# applicable for FIXED_DURATION repayment type + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PricingPlan] + def initialize(advance_rate_percentage:, fee_percentage:, repayment_type:, repayment_duration_days: OMIT, additional_properties: nil) + @advance_rate_percentage = advance_rate_percentage + @fee_percentage = fee_percentage + @repayment_type = repayment_type + @repayment_duration_days = repayment_duration_days if repayment_duration_days != OMIT + @additional_properties = additional_properties + @_field_set = { "advance_rate_percentage": advance_rate_percentage, "fee_percentage": fee_percentage, "repayment_type": repayment_type, "repayment_duration_days": repayment_duration_days }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PricingPlan + # + # @param json_object [String] + # @return [Monite::PricingPlan] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + advance_rate_percentage = parsed_json["advance_rate_percentage"] + fee_percentage = parsed_json["fee_percentage"] + repayment_type = parsed_json["repayment_type"] + repayment_duration_days = parsed_json["repayment_duration_days"] + new( + advance_rate_percentage: advance_rate_percentage, + fee_percentage: fee_percentage, + repayment_type: repayment_type, + repayment_duration_days: repayment_duration_days, + additional_properties: struct + ) + end +# Serialize an instance of PricingPlan to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.advance_rate_percentage.is_a?(Integer) != false || raise("Passed value for field obj.advance_rate_percentage is not the expected type, validation failed.") + obj.fee_percentage.is_a?(Integer) != false || raise("Passed value for field obj.fee_percentage is not the expected type, validation failed.") + obj.repayment_type.is_a?(Monite::WcRepaymentType) != false || raise("Passed value for field obj.repayment_type is not the expected type, validation failed.") + obj.repayment_duration_days&.is_a?(Integer) != false || raise("Passed value for field obj.repayment_duration_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/process_resource.rb b/lib/monite/types/process_resource.rb new file mode 100644 index 0000000..907cca5 --- /dev/null +++ b/lib/monite/types/process_resource.rb @@ -0,0 +1,136 @@ +# frozen_string_literal: true +require_relative "process_status_enum" +require_relative "process_resource_script_snapshot" +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class ProcessResource + # @return [String] + attr_reader :id + # @return [Monite::ProcessStatusEnum] Tthe current status of the approval policy process. + attr_reader :status + # @return [Hash{String => Object}] The input for the script. + attr_reader :input + # @return [Hash{String => Object}] The error for the process. + attr_reader :error + # @return [Monite::ProcessResourceScriptSnapshot] The script snapshot taken when script started. + attr_reader :script_snapshot + # @return [Hash{String => Object}] The metadata for the process. + attr_reader :metadata + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :created_by + # @return [String] + attr_reader :updated_by + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param status [Monite::ProcessStatusEnum] Tthe current status of the approval policy process. + # @param input [Hash{String => Object}] The input for the script. + # @param error [Hash{String => Object}] The error for the process. + # @param script_snapshot [Monite::ProcessResourceScriptSnapshot] The script snapshot taken when script started. + # @param metadata [Hash{String => Object}] The metadata for the process. + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param created_by [String] + # @param updated_by [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ProcessResource] + def initialize(id:, status:, input:, error: OMIT, script_snapshot: OMIT, metadata:, created_at:, updated_at: OMIT, created_by: OMIT, updated_by: OMIT, additional_properties: nil) + @id = id + @status = status + @input = input + @error = error if error != OMIT + @script_snapshot = script_snapshot if script_snapshot != OMIT + @metadata = metadata + @created_at = created_at + @updated_at = updated_at if updated_at != OMIT + @created_by = created_by if created_by != OMIT + @updated_by = updated_by if updated_by != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "status": status, "input": input, "error": error, "script_snapshot": script_snapshot, "metadata": metadata, "created_at": created_at, "updated_at": updated_at, "created_by": created_by, "updated_by": updated_by }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ProcessResource + # + # @param json_object [String] + # @return [Monite::ProcessResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + status = parsed_json["status"] + input = parsed_json["input"] + error = parsed_json["error"] + unless parsed_json["script_snapshot"].nil? + script_snapshot = parsed_json["script_snapshot"].to_json + script_snapshot = Monite::ProcessResourceScriptSnapshot.from_json(json_object: script_snapshot) + else + script_snapshot = nil + end + metadata = parsed_json["metadata"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_by = parsed_json["created_by"] + updated_by = parsed_json["updated_by"] + new( + id: id, + status: status, + input: input, + error: error, + script_snapshot: script_snapshot, + metadata: metadata, + created_at: created_at, + updated_at: updated_at, + created_by: created_by, + updated_by: updated_by, + additional_properties: struct + ) + end +# Serialize an instance of ProcessResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.status.is_a?(Monite::ProcessStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.input.is_a?(Hash) != false || raise("Passed value for field obj.input is not the expected type, validation failed.") + obj.error&.is_a?(Hash) != false || raise("Passed value for field obj.error is not the expected type, validation failed.") + obj.script_snapshot.nil? || Monite::ProcessResourceScriptSnapshot.validate_raw(obj: obj.script_snapshot) + obj.metadata.is_a?(Hash) != false || raise("Passed value for field obj.metadata is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_by&.is_a?(String) != false || raise("Passed value for field obj.created_by is not the expected type, validation failed.") + obj.updated_by&.is_a?(String) != false || raise("Passed value for field obj.updated_by is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/process_resource_script_snapshot.rb b/lib/monite/types/process_resource_script_snapshot.rb new file mode 100644 index 0000000..92fd1d9 --- /dev/null +++ b/lib/monite/types/process_resource_script_snapshot.rb @@ -0,0 +1,102 @@ +# frozen_string_literal: true +require "json" + +module Monite +# The script snapshot taken when script started. + class ProcessResourceScriptSnapshot + + +# Deserialize a JSON object to an instance of ProcessResourceScriptSnapshot + # + # @param json_object [String] + # @return [Monite::ProcessResourceScriptSnapshot] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(Boolean) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Float) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Array) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Hash) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(Boolean) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Float) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Array) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Hash) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/process_status_enum.rb b/lib/monite/types/process_status_enum.rb new file mode 100644 index 0000000..e862963 --- /dev/null +++ b/lib/monite/types/process_status_enum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite + class ProcessStatusEnum + + SUCCEEDED = "succeeded" + WAITING = "waiting" + FAILED = "failed" + RUNNING = "running" + CANCELED = "canceled" + TIMED_OUT = "timed_out" + + end +end \ No newline at end of file diff --git a/lib/monite/types/product_cursor_fields.rb b/lib/monite/types/product_cursor_fields.rb new file mode 100644 index 0000000..56e3d4d --- /dev/null +++ b/lib/monite/types/product_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + PRODUCT_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/product_service_pagination_response.rb b/lib/monite/types/product_service_pagination_response.rb new file mode 100644 index 0000000..d28460d --- /dev/null +++ b/lib/monite/types/product_service_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "product_service_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of products and services + class ProductServicePaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ProductServicePaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ProductServicePaginationResponse + # + # @param json_object [String] + # @return [Monite::ProductServicePaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ProductServiceResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ProductServicePaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/product_service_response.rb b/lib/monite/types/product_service_response.rb new file mode 100644 index 0000000..ca72140 --- /dev/null +++ b/lib/monite/types/product_service_response.rb @@ -0,0 +1,156 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "price" +require_relative "product_service_type_enum" +require "ostruct" +require "json" + +module Monite + class ProductServiceResponse + # @return [String] Unique ID of the product. + attr_reader :id + # @return [DateTime] Time at which the product was created. Timestamps follow the ISO 8601 standard. + attr_reader :created_at + # @return [DateTime] Time at which the product was last updated. Timestamps follow the ISO 8601 +# standard. + attr_reader :updated_at + # @return [String] Description of the product. + attr_reader :description + # @return [String] + attr_reader :entity_id + # @return [String] + attr_reader :entity_user_id + # @return [String] + attr_reader :ledger_account_id + # @return [String] The unique ID reference of the unit used to measure the quantity of this product +# (e.g. items, meters, kilograms). + attr_reader :measure_unit_id + # @return [String] Name of the product. + attr_reader :name + # @return [Monite::Price] + attr_reader :price + # @return [Float] The smallest amount allowed for this product. + attr_reader :smallest_amount + # @return [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the product. + # @param created_at [DateTime] Time at which the product was created. Timestamps follow the ISO 8601 standard. + # @param updated_at [DateTime] Time at which the product was last updated. Timestamps follow the ISO 8601 +# standard. + # @param description [String] Description of the product. + # @param entity_id [String] + # @param entity_user_id [String] + # @param ledger_account_id [String] + # @param measure_unit_id [String] The unique ID reference of the unit used to measure the quantity of this product +# (e.g. items, meters, kilograms). + # @param name [String] Name of the product. + # @param price [Monite::Price] + # @param smallest_amount [Float] The smallest amount allowed for this product. + # @param type [Monite::ProductServiceTypeEnum] Specifies whether this offering is a product or service. This may affect the +# applicable tax rates. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ProductServiceResponse] + def initialize(id:, created_at:, updated_at:, description: OMIT, entity_id:, entity_user_id: OMIT, ledger_account_id: OMIT, measure_unit_id: OMIT, name:, price: OMIT, smallest_amount: OMIT, type: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @description = description if description != OMIT + @entity_id = entity_id + @entity_user_id = entity_user_id if entity_user_id != OMIT + @ledger_account_id = ledger_account_id if ledger_account_id != OMIT + @measure_unit_id = measure_unit_id if measure_unit_id != OMIT + @name = name + @price = price if price != OMIT + @smallest_amount = smallest_amount if smallest_amount != OMIT + @type = type if type != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "description": description, "entity_id": entity_id, "entity_user_id": entity_user_id, "ledger_account_id": ledger_account_id, "measure_unit_id": measure_unit_id, "name": name, "price": price, "smallest_amount": smallest_amount, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ProductServiceResponse + # + # @param json_object [String] + # @return [Monite::ProductServiceResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + description = parsed_json["description"] + entity_id = parsed_json["entity_id"] + entity_user_id = parsed_json["entity_user_id"] + ledger_account_id = parsed_json["ledger_account_id"] + measure_unit_id = parsed_json["measure_unit_id"] + name = parsed_json["name"] + unless parsed_json["price"].nil? + price = parsed_json["price"].to_json + price = Monite::Price.from_json(json_object: price) + else + price = nil + end + smallest_amount = parsed_json["smallest_amount"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + description: description, + entity_id: entity_id, + entity_user_id: entity_user_id, + ledger_account_id: ledger_account_id, + measure_unit_id: measure_unit_id, + name: name, + price: price, + smallest_amount: smallest_amount, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of ProductServiceResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.entity_user_id is not the expected type, validation failed.") + obj.ledger_account_id&.is_a?(String) != false || raise("Passed value for field obj.ledger_account_id is not the expected type, validation failed.") + obj.measure_unit_id&.is_a?(String) != false || raise("Passed value for field obj.measure_unit_id is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.price.nil? || Monite::Price.validate_raw(obj: obj.price) + obj.smallest_amount&.is_a?(Float) != false || raise("Passed value for field obj.smallest_amount is not the expected type, validation failed.") + obj.type&.is_a?(Monite::ProductServiceTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/product_service_type_enum.rb b/lib/monite/types/product_service_type_enum.rb new file mode 100644 index 0000000..f3f2857 --- /dev/null +++ b/lib/monite/types/product_service_type_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ProductServiceTypeEnum + + PRODUCT = "product" + SERVICE = "service" + + end +end \ No newline at end of file diff --git a/lib/monite/types/project_cursor_fields.rb b/lib/monite/types/project_cursor_fields.rb new file mode 100644 index 0000000..1190c72 --- /dev/null +++ b/lib/monite/types/project_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ProjectCursorFields + + ID = "id" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/project_pagination_response.rb b/lib/monite/types/project_pagination_response.rb new file mode 100644 index 0000000..3c6a7b5 --- /dev/null +++ b/lib/monite/types/project_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "project_resource" +require "ostruct" +require "json" + +module Monite +# A paginated list of projects. + class ProjectPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ProjectPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ProjectPaginationResponse + # + # @param json_object [String] + # @return [Monite::ProjectPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ProjectResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ProjectPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/project_resource.rb b/lib/monite/types/project_resource.rb new file mode 100644 index 0000000..9277f3d --- /dev/null +++ b/lib/monite/types/project_resource.rb @@ -0,0 +1,161 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "tag_read_schema" +require "ostruct" +require "json" + +module Monite + class ProjectResource + # @return [String] A unique ID assigned to this project. + attr_reader :id + # @return [DateTime] Project created at + attr_reader :created_at + # @return [DateTime] Last time project was updated at + attr_reader :updated_at + # @return [String] Project code + attr_reader :code + # @return [String] Project color + attr_reader :color + # @return [String] Project created by entity user + attr_reader :created_by_entity_user_id + # @return [String] Description of project + attr_reader :description + # @return [String] Project end date + attr_reader :end_date + # @return [String] The ID of the entity to which the project was issued. + attr_reader :entity_id + # @return [String] The project name. + attr_reader :name + # @return [String] Parent project ID + attr_reader :parent_id + # @return [Hash{String => Object}] Project metadata + attr_reader :partner_metadata + # @return [String] Project start date + attr_reader :start_date + # @return [Array] A list of user-defined tags (labels) assigned to this project. + attr_reader :tags + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID assigned to this project. + # @param created_at [DateTime] Project created at + # @param updated_at [DateTime] Last time project was updated at + # @param code [String] Project code + # @param color [String] Project color + # @param created_by_entity_user_id [String] Project created by entity user + # @param description [String] Description of project + # @param end_date [String] Project end date + # @param entity_id [String] The ID of the entity to which the project was issued. + # @param name [String] The project name. + # @param parent_id [String] Parent project ID + # @param partner_metadata [Hash{String => Object}] Project metadata + # @param start_date [String] Project start date + # @param tags [Array] A list of user-defined tags (labels) assigned to this project. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ProjectResource] + def initialize(id:, created_at:, updated_at:, code: OMIT, color: OMIT, created_by_entity_user_id: OMIT, description: OMIT, end_date: OMIT, entity_id:, name:, parent_id: OMIT, partner_metadata: OMIT, start_date: OMIT, tags: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @code = code if code != OMIT + @color = color if color != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @description = description if description != OMIT + @end_date = end_date if end_date != OMIT + @entity_id = entity_id + @name = name + @parent_id = parent_id if parent_id != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @start_date = start_date if start_date != OMIT + @tags = tags if tags != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "code": code, "color": color, "created_by_entity_user_id": created_by_entity_user_id, "description": description, "end_date": end_date, "entity_id": entity_id, "name": name, "parent_id": parent_id, "partner_metadata": partner_metadata, "start_date": start_date, "tags": tags }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ProjectResource + # + # @param json_object [String] + # @return [Monite::ProjectResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + code = parsed_json["code"] + color = parsed_json["color"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + description = parsed_json["description"] + end_date = parsed_json["end_date"] + entity_id = parsed_json["entity_id"] + name = parsed_json["name"] + parent_id = parsed_json["parent_id"] + partner_metadata = parsed_json["partner_metadata"] + start_date = parsed_json["start_date"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + new( + id: id, + created_at: created_at, + updated_at: updated_at, + code: code, + color: color, + created_by_entity_user_id: created_by_entity_user_id, + description: description, + end_date: end_date, + entity_id: entity_id, + name: name, + parent_id: parent_id, + partner_metadata: partner_metadata, + start_date: start_date, + tags: tags, + additional_properties: struct + ) + end +# Serialize an instance of ProjectResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.code&.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") + obj.color&.is_a?(String) != false || raise("Passed value for field obj.color is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.parent_id&.is_a?(String) != false || raise("Passed value for field obj.parent_id is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.start_date&.is_a?(String) != false || raise("Passed value for field obj.start_date is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/public_payment_link_response.rb b/lib/monite/types/public_payment_link_response.rb new file mode 100644 index 0000000..c2ba45f --- /dev/null +++ b/lib/monite/types/public_payment_link_response.rb @@ -0,0 +1,181 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require "date" +require_relative "invoice" +require_relative "payer_account_response" +require_relative "payment_intent" +require_relative "recipient_account_response" +require "ostruct" +require "json" + +module Monite + class PublicPaymentLinkResponse + # @return [String] + attr_reader :id + # @return [Integer] + attr_reader :amount + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [DateTime] + attr_reader :expires_at + # @return [Monite::Invoice] + attr_reader :invoice + # @return [Monite::PayerAccountResponse] + attr_reader :payer + # @return [Monite::PaymentIntent] + attr_reader :payment_intent + # @return [String] + attr_reader :payment_intent_id + # @return [Array] + attr_reader :payment_methods + # @return [String] + attr_reader :payment_page_url + # @return [String] + attr_reader :payment_reference + # @return [Monite::RecipientAccountResponse] + attr_reader :recipient + # @return [String] The URL where to redirect the payer after the payment. If `return_url` is +# specified, then after the payment is completed the payment page will display the +# "Return to platform" link that navigates to this URL. + attr_reader :return_url + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param amount [Integer] + # @param currency [Monite::CurrencyEnum] + # @param expires_at [DateTime] + # @param invoice [Monite::Invoice] + # @param payer [Monite::PayerAccountResponse] + # @param payment_intent [Monite::PaymentIntent] + # @param payment_intent_id [String] + # @param payment_methods [Array] + # @param payment_page_url [String] + # @param payment_reference [String] + # @param recipient [Monite::RecipientAccountResponse] + # @param return_url [String] The URL where to redirect the payer after the payment. If `return_url` is +# specified, then after the payment is completed the payment page will display the +# "Return to platform" link that navigates to this URL. + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PublicPaymentLinkResponse] + def initialize(id:, amount:, currency:, expires_at:, invoice: OMIT, payer: OMIT, payment_intent: OMIT, payment_intent_id:, payment_methods:, payment_page_url:, payment_reference: OMIT, recipient:, return_url: OMIT, status:, additional_properties: nil) + @id = id + @amount = amount + @currency = currency + @expires_at = expires_at + @invoice = invoice if invoice != OMIT + @payer = payer if payer != OMIT + @payment_intent = payment_intent if payment_intent != OMIT + @payment_intent_id = payment_intent_id + @payment_methods = payment_methods + @payment_page_url = payment_page_url + @payment_reference = payment_reference if payment_reference != OMIT + @recipient = recipient + @return_url = return_url if return_url != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "amount": amount, "currency": currency, "expires_at": expires_at, "invoice": invoice, "payer": payer, "payment_intent": payment_intent, "payment_intent_id": payment_intent_id, "payment_methods": payment_methods, "payment_page_url": payment_page_url, "payment_reference": payment_reference, "recipient": recipient, "return_url": return_url, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PublicPaymentLinkResponse + # + # @param json_object [String] + # @return [Monite::PublicPaymentLinkResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + amount = parsed_json["amount"] + currency = parsed_json["currency"] + expires_at = unless parsed_json["expires_at"].nil? + DateTime.parse(parsed_json["expires_at"]) +else + nil +end + unless parsed_json["invoice"].nil? + invoice = parsed_json["invoice"].to_json + invoice = Monite::Invoice.from_json(json_object: invoice) + else + invoice = nil + end + unless parsed_json["payer"].nil? + payer = parsed_json["payer"].to_json + payer = Monite::PayerAccountResponse.from_json(json_object: payer) + else + payer = nil + end + unless parsed_json["payment_intent"].nil? + payment_intent = parsed_json["payment_intent"].to_json + payment_intent = Monite::PaymentIntent.from_json(json_object: payment_intent) + else + payment_intent = nil + end + payment_intent_id = parsed_json["payment_intent_id"] + payment_methods = parsed_json["payment_methods"] + payment_page_url = parsed_json["payment_page_url"] + payment_reference = parsed_json["payment_reference"] + unless parsed_json["recipient"].nil? + recipient = parsed_json["recipient"].to_json + recipient = Monite::RecipientAccountResponse.from_json(json_object: recipient) + else + recipient = nil + end + return_url = parsed_json["return_url"] + status = parsed_json["status"] + new( + id: id, + amount: amount, + currency: currency, + expires_at: expires_at, + invoice: invoice, + payer: payer, + payment_intent: payment_intent, + payment_intent_id: payment_intent_id, + payment_methods: payment_methods, + payment_page_url: payment_page_url, + payment_reference: payment_reference, + recipient: recipient, + return_url: return_url, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of PublicPaymentLinkResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.amount.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.expires_at.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.") + obj.invoice.nil? || Monite::Invoice.validate_raw(obj: obj.invoice) + obj.payer.nil? || Monite::PayerAccountResponse.validate_raw(obj: obj.payer) + obj.payment_intent.nil? || Monite::PaymentIntent.validate_raw(obj: obj.payment_intent) + obj.payment_intent_id.is_a?(String) != false || raise("Passed value for field obj.payment_intent_id is not the expected type, validation failed.") + obj.payment_methods.is_a?(Array) != false || raise("Passed value for field obj.payment_methods is not the expected type, validation failed.") + obj.payment_page_url.is_a?(String) != false || raise("Passed value for field obj.payment_page_url is not the expected type, validation failed.") + obj.payment_reference&.is_a?(String) != false || raise("Passed value for field obj.payment_reference is not the expected type, validation failed.") + Monite::RecipientAccountResponse.validate_raw(obj: obj.recipient) + obj.return_url&.is_a?(String) != false || raise("Passed value for field obj.return_url is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_counterpart_address_schema.rb b/lib/monite/types/purchase_order_counterpart_address_schema.rb new file mode 100644 index 0000000..fc5156a --- /dev/null +++ b/lib/monite/types/purchase_order_counterpart_address_schema.rb @@ -0,0 +1,96 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# Address information. + class PurchaseOrderCounterpartAddressSchema + # @return [String] City name. + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderCounterpartAddressSchema] + def initialize(city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# PurchaseOrderCounterpartAddressSchema + # + # @param json_object [String] + # @return [Monite::PurchaseOrderCounterpartAddressSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderCounterpartAddressSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_counterpart_individual_response.rb b/lib/monite/types/purchase_order_counterpart_individual_response.rb new file mode 100644 index 0000000..80670e8 --- /dev/null +++ b/lib/monite/types/purchase_order_counterpart_individual_response.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class PurchaseOrderCounterpartIndividualResponse + # @return [String] The person's email address. + attr_reader :email + # @return [String] The person's first name. + attr_reader :first_name + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The person's last name. + attr_reader :last_name + # @return [String] The person's phone number. + attr_reader :phone + # @return [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The person's email address. + # @param first_name [String] The person's first name. + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param last_name [String] The person's last name. + # @param phone [String] The person's phone number. + # @param title [String] The person's title or honorific. Examples: Mr., Ms., Dr., Prof. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderCounterpartIndividualResponse] + def initialize(email: OMIT, first_name:, is_customer:, is_vendor:, last_name:, phone: OMIT, title: OMIT, additional_properties: nil) + @email = email if email != OMIT + @first_name = first_name + @is_customer = is_customer + @is_vendor = is_vendor + @last_name = last_name + @phone = phone if phone != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "first_name": first_name, "is_customer": is_customer, "is_vendor": is_vendor, "last_name": last_name, "phone": phone, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# PurchaseOrderCounterpartIndividualResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderCounterpartIndividualResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + first_name = parsed_json["first_name"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + title = parsed_json["title"] + new( + email: email, + first_name: first_name, + is_customer: is_customer, + is_vendor: is_vendor, + last_name: last_name, + phone: phone, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderCounterpartIndividualResponse to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.is_customer.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_counterpart_individual_root_response.rb b/lib/monite/types/purchase_order_counterpart_individual_root_response.rb new file mode 100644 index 0000000..226317e --- /dev/null +++ b/lib/monite/types/purchase_order_counterpart_individual_root_response.rb @@ -0,0 +1,172 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "purchase_order_counterpart_individual_response" +require_relative "language_code_enum" +require_relative "counterpart_type" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are individuals (natural persons). + class PurchaseOrderCounterpartIndividualRootResponse + # @return [String] Unique ID of the counterpart. + attr_reader :id + # @return [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :created_at + # @return [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :updated_at + # @return [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + attr_reader :created_automatically + # @return [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + attr_reader :default_billing_address_id + # @return [String] ID of the shipping address. + attr_reader :default_shipping_address_id + # @return [String] Entity user ID of counterpart creator. + attr_reader :created_by_entity_user_id + # @return [Monite::PurchaseOrderCounterpartIndividualResponse] + attr_reader :individual + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. This field is +# required for counterparts that are non-VAT registered. + attr_reader :tax_id + # @return [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the counterpart. + # @param created_at [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param updated_at [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param created_automatically [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + # @param default_billing_address_id [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + # @param default_shipping_address_id [String] ID of the shipping address. + # @param created_by_entity_user_id [String] Entity user ID of counterpart creator. + # @param individual [Monite::PurchaseOrderCounterpartIndividualResponse] + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. This field is +# required for counterparts that are non-VAT registered. + # @param type [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderCounterpartIndividualRootResponse] + def initialize(id:, created_at:, updated_at:, created_automatically: OMIT, default_billing_address_id: OMIT, default_shipping_address_id: OMIT, created_by_entity_user_id: OMIT, individual:, language: OMIT, reminders_enabled: OMIT, tax_id: OMIT, type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @created_automatically = created_automatically if created_automatically != OMIT + @default_billing_address_id = default_billing_address_id if default_billing_address_id != OMIT + @default_shipping_address_id = default_shipping_address_id if default_shipping_address_id != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @individual = individual + @language = language if language != OMIT + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_automatically": created_automatically, "default_billing_address_id": default_billing_address_id, "default_shipping_address_id": default_shipping_address_id, "created_by_entity_user_id": created_by_entity_user_id, "individual": individual, "language": language, "reminders_enabled": reminders_enabled, "tax_id": tax_id, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# PurchaseOrderCounterpartIndividualRootResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderCounterpartIndividualRootResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_automatically = parsed_json["created_automatically"] + default_billing_address_id = parsed_json["default_billing_address_id"] + default_shipping_address_id = parsed_json["default_shipping_address_id"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::PurchaseOrderCounterpartIndividualResponse.from_json(json_object: individual) + else + individual = nil + end + language = parsed_json["language"] + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_automatically: created_automatically, + default_billing_address_id: default_billing_address_id, + default_shipping_address_id: default_shipping_address_id, + created_by_entity_user_id: created_by_entity_user_id, + individual: individual, + language: language, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderCounterpartIndividualRootResponse to a +# JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_automatically&.is_a?(Boolean) != false || raise("Passed value for field obj.created_automatically is not the expected type, validation failed.") + obj.default_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_billing_address_id is not the expected type, validation failed.") + obj.default_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_shipping_address_id is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + Monite::PurchaseOrderCounterpartIndividualResponse.validate_raw(obj: obj.individual) + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.type.is_a?(Monite::CounterpartType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_counterpart_organization_response.rb b/lib/monite/types/purchase_order_counterpart_organization_response.rb new file mode 100644 index 0000000..23c8af3 --- /dev/null +++ b/lib/monite/types/purchase_order_counterpart_organization_response.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class PurchaseOrderCounterpartOrganizationResponse + # @return [String] The email address of the organization + attr_reader :email + # @return [Boolean] Indicates if the counterpart is a customer. + attr_reader :is_customer + # @return [Boolean] Indicates if the counterpart is a vendor. + attr_reader :is_vendor + # @return [String] The legal name of the organization. + attr_reader :legal_name + # @return [String] The phone number of the organization + attr_reader :phone + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The email address of the organization + # @param is_customer [Boolean] Indicates if the counterpart is a customer. + # @param is_vendor [Boolean] Indicates if the counterpart is a vendor. + # @param legal_name [String] The legal name of the organization. + # @param phone [String] The phone number of the organization + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderCounterpartOrganizationResponse] + def initialize(email: OMIT, is_customer:, is_vendor:, legal_name:, phone: OMIT, additional_properties: nil) + @email = email if email != OMIT + @is_customer = is_customer + @is_vendor = is_vendor + @legal_name = legal_name + @phone = phone if phone != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "is_customer": is_customer, "is_vendor": is_vendor, "legal_name": legal_name, "phone": phone }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# PurchaseOrderCounterpartOrganizationResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderCounterpartOrganizationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + is_customer = parsed_json["is_customer"] + is_vendor = parsed_json["is_vendor"] + legal_name = parsed_json["legal_name"] + phone = parsed_json["phone"] + new( + email: email, + is_customer: is_customer, + is_vendor: is_vendor, + legal_name: legal_name, + phone: phone, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderCounterpartOrganizationResponse to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.is_customer.is_a?(Boolean) != false || raise("Passed value for field obj.is_customer is not the expected type, validation failed.") + obj.is_vendor.is_a?(Boolean) != false || raise("Passed value for field obj.is_vendor is not the expected type, validation failed.") + obj.legal_name.is_a?(String) != false || raise("Passed value for field obj.legal_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_counterpart_organization_root_response.rb b/lib/monite/types/purchase_order_counterpart_organization_root_response.rb new file mode 100644 index 0000000..3b0bae9 --- /dev/null +++ b/lib/monite/types/purchase_order_counterpart_organization_root_response.rb @@ -0,0 +1,172 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "language_code_enum" +require_relative "purchase_order_counterpart_organization_response" +require_relative "counterpart_type" +require "ostruct" +require "json" + +module Monite +# Represents counterparts that are organizations (juridical persons). + class PurchaseOrderCounterpartOrganizationRootResponse + # @return [String] Unique ID of the counterpart. + attr_reader :id + # @return [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :created_at + # @return [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :updated_at + # @return [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + attr_reader :created_automatically + # @return [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + attr_reader :default_billing_address_id + # @return [String] ID of the shipping address. + attr_reader :default_shipping_address_id + # @return [String] Entity user ID of counterpart creator. + attr_reader :created_by_entity_user_id + # @return [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + attr_reader :language + # @return [Monite::PurchaseOrderCounterpartOrganizationResponse] + attr_reader :organization + # @return [Boolean] + attr_reader :reminders_enabled + # @return [String] The counterpart's taxpayer identification number or tax ID. This field is +# required for counterparts that are non-VAT registered. + attr_reader :tax_id + # @return [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the counterpart. + # @param created_at [DateTime] Date and time when the counterpart was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param updated_at [DateTime] Date and time when the counterpart was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param created_automatically [Boolean] `true` if the counterpart was created automatically by Monite when processing +# incoming invoices with OCR. `false` if the counterpart was created by the API +# client. + # @param default_billing_address_id [String] ID of the counterpart's billing address. If the counterpart is US-based and +# needs to accept ACH payments, this address must have all fields filled in. If +# `default_billing_address_id` is not defined, the default address is instead used +# as the billing address for ACH payments. + # @param default_shipping_address_id [String] ID of the shipping address. + # @param created_by_entity_user_id [String] Entity user ID of counterpart creator. + # @param language [Monite::LanguageCodeEnum] The language used to generate PDF documents for this counterpart. + # @param organization [Monite::PurchaseOrderCounterpartOrganizationResponse] + # @param reminders_enabled [Boolean] + # @param tax_id [String] The counterpart's taxpayer identification number or tax ID. This field is +# required for counterparts that are non-VAT registered. + # @param type [Monite::CounterpartType] The counterpart type: `organization` (juridical person) or `individual` (natural +# person). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderCounterpartOrganizationRootResponse] + def initialize(id:, created_at:, updated_at:, created_automatically: OMIT, default_billing_address_id: OMIT, default_shipping_address_id: OMIT, created_by_entity_user_id: OMIT, language: OMIT, organization:, reminders_enabled: OMIT, tax_id: OMIT, type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @created_automatically = created_automatically if created_automatically != OMIT + @default_billing_address_id = default_billing_address_id if default_billing_address_id != OMIT + @default_shipping_address_id = default_shipping_address_id if default_shipping_address_id != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @language = language if language != OMIT + @organization = organization + @reminders_enabled = reminders_enabled if reminders_enabled != OMIT + @tax_id = tax_id if tax_id != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "created_automatically": created_automatically, "default_billing_address_id": default_billing_address_id, "default_shipping_address_id": default_shipping_address_id, "created_by_entity_user_id": created_by_entity_user_id, "language": language, "organization": organization, "reminders_enabled": reminders_enabled, "tax_id": tax_id, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# PurchaseOrderCounterpartOrganizationRootResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderCounterpartOrganizationRootResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + created_automatically = parsed_json["created_automatically"] + default_billing_address_id = parsed_json["default_billing_address_id"] + default_shipping_address_id = parsed_json["default_shipping_address_id"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + language = parsed_json["language"] + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::PurchaseOrderCounterpartOrganizationResponse.from_json(json_object: organization) + else + organization = nil + end + reminders_enabled = parsed_json["reminders_enabled"] + tax_id = parsed_json["tax_id"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + created_automatically: created_automatically, + default_billing_address_id: default_billing_address_id, + default_shipping_address_id: default_shipping_address_id, + created_by_entity_user_id: created_by_entity_user_id, + language: language, + organization: organization, + reminders_enabled: reminders_enabled, + tax_id: tax_id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderCounterpartOrganizationRootResponse to a +# JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.created_automatically&.is_a?(Boolean) != false || raise("Passed value for field obj.created_automatically is not the expected type, validation failed.") + obj.default_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_billing_address_id is not the expected type, validation failed.") + obj.default_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.default_shipping_address_id is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + Monite::PurchaseOrderCounterpartOrganizationResponse.validate_raw(obj: obj.organization) + obj.reminders_enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.reminders_enabled is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.type.is_a?(Monite::CounterpartType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_counterpart_schema.rb b/lib/monite/types/purchase_order_counterpart_schema.rb new file mode 100644 index 0000000..673fa88 --- /dev/null +++ b/lib/monite/types/purchase_order_counterpart_schema.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "json" +require_relative "purchase_order_counterpart_individual_root_response" +require_relative "purchase_order_counterpart_organization_root_response" + +module Monite +# A Counterpart object contains information about an organization (juridical +# person) or +# individual (natural person) that provides goods and services to or buys them +# from an +# [SME](https://docs.monite.com/docs/glossary#sme). + class PurchaseOrderCounterpartSchema + + +# Deserialize a JSON object to an instance of PurchaseOrderCounterpartSchema + # + # @param json_object [String] + # @return [Monite::PurchaseOrderCounterpartSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::PurchaseOrderCounterpartIndividualRootResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::PurchaseOrderCounterpartIndividualRootResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::PurchaseOrderCounterpartOrganizationRootResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::PurchaseOrderCounterpartOrganizationRootResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::PurchaseOrderCounterpartIndividualRootResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::PurchaseOrderCounterpartOrganizationRootResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_cursor_fields.rb b/lib/monite/types/purchase_order_cursor_fields.rb new file mode 100644 index 0000000..fb25d42 --- /dev/null +++ b/lib/monite/types/purchase_order_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PurchaseOrderCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_email_preview_response.rb b/lib/monite/types/purchase_order_email_preview_response.rb new file mode 100644 index 0000000..20383e9 --- /dev/null +++ b/lib/monite/types/purchase_order_email_preview_response.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema for returning a response for email preview + class PurchaseOrderEmailPreviewResponse + # @return [String] + attr_reader :body_preview + # @return [String] + attr_reader :subject_preview + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param body_preview [String] + # @param subject_preview [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderEmailPreviewResponse] + def initialize(body_preview:, subject_preview:, additional_properties: nil) + @body_preview = body_preview + @subject_preview = subject_preview + @additional_properties = additional_properties + @_field_set = { "body_preview": body_preview, "subject_preview": subject_preview } + end +# Deserialize a JSON object to an instance of PurchaseOrderEmailPreviewResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderEmailPreviewResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + body_preview = parsed_json["body_preview"] + subject_preview = parsed_json["subject_preview"] + new( + body_preview: body_preview, + subject_preview: subject_preview, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderEmailPreviewResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body_preview.is_a?(String) != false || raise("Passed value for field obj.body_preview is not the expected type, validation failed.") + obj.subject_preview.is_a?(String) != false || raise("Passed value for field obj.subject_preview is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_email_sent_response.rb b/lib/monite/types/purchase_order_email_sent_response.rb new file mode 100644 index 0000000..cda29d5 --- /dev/null +++ b/lib/monite/types/purchase_order_email_sent_response.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema for returning a response an email with a link to purchase order +# document has been sent + class PurchaseOrderEmailSentResponse + # @return [String] + attr_reader :mail_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param mail_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderEmailSentResponse] + def initialize(mail_id:, additional_properties: nil) + @mail_id = mail_id + @additional_properties = additional_properties + @_field_set = { "mail_id": mail_id } + end +# Deserialize a JSON object to an instance of PurchaseOrderEmailSentResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderEmailSentResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + mail_id = parsed_json["mail_id"] + new(mail_id: mail_id, additional_properties: struct) + end +# Serialize an instance of PurchaseOrderEmailSentResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mail_id.is_a?(String) != false || raise("Passed value for field obj.mail_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_item.rb b/lib/monite/types/purchase_order_item.rb new file mode 100644 index 0000000..40020b8 --- /dev/null +++ b/lib/monite/types/purchase_order_item.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require "ostruct" +require "json" + +module Monite + class PurchaseOrderItem + # @return [Monite::CurrencyEnum] The currency in which the price of the product is set. + attr_reader :currency + # @return [String] The name of the product to purchase + attr_reader :name + # @return [Integer] The subtotal cost (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :price + # @return [Integer] Number (quantity) of products + attr_reader :quantity + # @return [String] Units (hours, meters, unit) + attr_reader :unit + # @return [Integer] Percent minor units. Example: 12.5% is 1250 + attr_reader :vat_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param currency [Monite::CurrencyEnum] The currency in which the price of the product is set. + # @param name [String] The name of the product to purchase + # @param price [Integer] The subtotal cost (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param quantity [Integer] Number (quantity) of products + # @param unit [String] Units (hours, meters, unit) + # @param vat_rate [Integer] Percent minor units. Example: 12.5% is 1250 + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderItem] + def initialize(currency:, name:, price:, quantity:, unit:, vat_rate:, additional_properties: nil) + @currency = currency + @name = name + @price = price + @quantity = quantity + @unit = unit + @vat_rate = vat_rate + @additional_properties = additional_properties + @_field_set = { "currency": currency, "name": name, "price": price, "quantity": quantity, "unit": unit, "vat_rate": vat_rate } + end +# Deserialize a JSON object to an instance of PurchaseOrderItem + # + # @param json_object [String] + # @return [Monite::PurchaseOrderItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + currency = parsed_json["currency"] + name = parsed_json["name"] + price = parsed_json["price"] + quantity = parsed_json["quantity"] + unit = parsed_json["unit"] + vat_rate = parsed_json["vat_rate"] + new( + currency: currency, + name: name, + price: price, + quantity: quantity, + unit: unit, + vat_rate: vat_rate, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.price.is_a?(Integer) != false || raise("Passed value for field obj.price is not the expected type, validation failed.") + obj.quantity.is_a?(Integer) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.unit.is_a?(String) != false || raise("Passed value for field obj.unit is not the expected type, validation failed.") + obj.vat_rate.is_a?(Integer) != false || raise("Passed value for field obj.vat_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_pagination_response.rb b/lib/monite/types/purchase_order_pagination_response.rb new file mode 100644 index 0000000..00a5830 --- /dev/null +++ b/lib/monite/types/purchase_order_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "purchase_order_response_schema" +require "ostruct" +require "json" + +module Monite +# A paginated list of purchase orders. + class PurchaseOrderPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PurchaseOrderPaginationResponse + # + # @param json_object [String] + # @return [Monite::PurchaseOrderPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::PurchaseOrderResponseSchema.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_response_schema.rb b/lib/monite/types/purchase_order_response_schema.rb new file mode 100644 index 0000000..ed40a69 --- /dev/null +++ b/lib/monite/types/purchase_order_response_schema.rb @@ -0,0 +1,241 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "purchase_order_counterpart_schema" +require_relative "purchase_order_counterpart_address_schema" +require_relative "currency_enum" +require_relative "purchase_order_response_schema_entity" +require_relative "purchase_order_vat_id" +require_relative "purchase_order_item" +require "ostruct" +require "json" + +module Monite +# Represents response for an Accounts Purchase Order document created by entity. + class PurchaseOrderResponseSchema + # @return [String] A unique ID assigned to this purchase order. + attr_reader :id + # @return [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + attr_reader :updated_at + # @return [Monite::PurchaseOrderCounterpartSchema] Counterpart information about an organization (juridical person) or individual +# (natural person) that provides goods and services to or buys them from an + attr_reader :counterpart + # @return [Monite::PurchaseOrderCounterpartAddressSchema] Counterpart address data saved on creation or update of the purchase order. + attr_reader :counterpart_address + # @return [String] The ID of counterpart address object stored in counterparts service. If not +# provided, counterpart's default address is used. + attr_reader :counterpart_address_id + # @return [String] Counterpart unique ID. + attr_reader :counterpart_id + # @return [String] ID of the creator of the purchase order + attr_reader :created_by_user_id + # @return [Monite::CurrencyEnum] The currency in which the price of the product is set. (all items need to have +# the same currency) + attr_reader :currency + # @return [String] + attr_reader :document_id + # @return [Monite::PurchaseOrderResponseSchemaEntity] Data of the entity (address, name, contact) + attr_reader :entity + # @return [String] The ID of the entity which issued the purchase order. + attr_reader :entity_id + # @return [Monite::PurchaseOrderVatId] + attr_reader :entity_vat_id + # @return [String] + attr_reader :file_id + # @return [String] + attr_reader :file_url + # @return [String] When status changed from 'draft' to 'send', so after sending purchase order + attr_reader :issued_at + # @return [Array] List of item to purchase + attr_reader :items + # @return [String] Msg which will be send to counterpart for who the purchase order is issued. + attr_reader :message + # @return [String] Purchase order can be in 'draft' state before sending it to counterpart. After +# that state is 'issued' + attr_reader :status + # @return [Integer] Number of days for which purchase order is valid + attr_reader :valid_for_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID assigned to this purchase order. + # @param created_at [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + # @param counterpart [Monite::PurchaseOrderCounterpartSchema] Counterpart information about an organization (juridical person) or individual +# (natural person) that provides goods and services to or buys them from an + # @param counterpart_address [Monite::PurchaseOrderCounterpartAddressSchema] Counterpart address data saved on creation or update of the purchase order. + # @param counterpart_address_id [String] The ID of counterpart address object stored in counterparts service. If not +# provided, counterpart's default address is used. + # @param counterpart_id [String] Counterpart unique ID. + # @param created_by_user_id [String] ID of the creator of the purchase order + # @param currency [Monite::CurrencyEnum] The currency in which the price of the product is set. (all items need to have +# the same currency) + # @param document_id [String] + # @param entity [Monite::PurchaseOrderResponseSchemaEntity] Data of the entity (address, name, contact) + # @param entity_id [String] The ID of the entity which issued the purchase order. + # @param entity_vat_id [Monite::PurchaseOrderVatId] + # @param file_id [String] + # @param file_url [String] + # @param issued_at [String] When status changed from 'draft' to 'send', so after sending purchase order + # @param items [Array] List of item to purchase + # @param message [String] Msg which will be send to counterpart for who the purchase order is issued. + # @param status [String] Purchase order can be in 'draft' state before sending it to counterpart. After +# that state is 'issued' + # @param valid_for_days [Integer] Number of days for which purchase order is valid + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderResponseSchema] + def initialize(id:, created_at:, updated_at:, counterpart:, counterpart_address: OMIT, counterpart_address_id: OMIT, counterpart_id:, created_by_user_id: OMIT, currency:, document_id:, entity:, entity_id:, entity_vat_id: OMIT, file_id: OMIT, file_url: OMIT, issued_at: OMIT, items:, message:, status:, valid_for_days:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @counterpart = counterpart + @counterpart_address = counterpart_address if counterpart_address != OMIT + @counterpart_address_id = counterpart_address_id if counterpart_address_id != OMIT + @counterpart_id = counterpart_id + @created_by_user_id = created_by_user_id if created_by_user_id != OMIT + @currency = currency + @document_id = document_id + @entity = entity + @entity_id = entity_id + @entity_vat_id = entity_vat_id if entity_vat_id != OMIT + @file_id = file_id if file_id != OMIT + @file_url = file_url if file_url != OMIT + @issued_at = issued_at if issued_at != OMIT + @items = items + @message = message + @status = status + @valid_for_days = valid_for_days + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "counterpart": counterpart, "counterpart_address": counterpart_address, "counterpart_address_id": counterpart_address_id, "counterpart_id": counterpart_id, "created_by_user_id": created_by_user_id, "currency": currency, "document_id": document_id, "entity": entity, "entity_id": entity_id, "entity_vat_id": entity_vat_id, "file_id": file_id, "file_url": file_url, "issued_at": issued_at, "items": items, "message": message, "status": status, "valid_for_days": valid_for_days }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of PurchaseOrderResponseSchema + # + # @param json_object [String] + # @return [Monite::PurchaseOrderResponseSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["counterpart"].nil? + counterpart = parsed_json["counterpart"].to_json + counterpart = Monite::PurchaseOrderCounterpartSchema.from_json(json_object: counterpart) + else + counterpart = nil + end + unless parsed_json["counterpart_address"].nil? + counterpart_address = parsed_json["counterpart_address"].to_json + counterpart_address = Monite::PurchaseOrderCounterpartAddressSchema.from_json(json_object: counterpart_address) + else + counterpart_address = nil + end + counterpart_address_id = parsed_json["counterpart_address_id"] + counterpart_id = parsed_json["counterpart_id"] + created_by_user_id = parsed_json["created_by_user_id"] + currency = parsed_json["currency"] + document_id = parsed_json["document_id"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::PurchaseOrderResponseSchemaEntity.from_json(json_object: entity) + else + entity = nil + end + entity_id = parsed_json["entity_id"] + unless parsed_json["entity_vat_id"].nil? + entity_vat_id = parsed_json["entity_vat_id"].to_json + entity_vat_id = Monite::PurchaseOrderVatId.from_json(json_object: entity_vat_id) + else + entity_vat_id = nil + end + file_id = parsed_json["file_id"] + file_url = parsed_json["file_url"] + issued_at = parsed_json["issued_at"] + items = parsed_json["items"]&.map do | item | + item = item.to_json + Monite::PurchaseOrderItem.from_json(json_object: item) +end + message = parsed_json["message"] + status = parsed_json["status"] + valid_for_days = parsed_json["valid_for_days"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + counterpart: counterpart, + counterpart_address: counterpart_address, + counterpart_address_id: counterpart_address_id, + counterpart_id: counterpart_id, + created_by_user_id: created_by_user_id, + currency: currency, + document_id: document_id, + entity: entity, + entity_id: entity_id, + entity_vat_id: entity_vat_id, + file_id: file_id, + file_url: file_url, + issued_at: issued_at, + items: items, + message: message, + status: status, + valid_for_days: valid_for_days, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderResponseSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + Monite::PurchaseOrderCounterpartSchema.validate_raw(obj: obj.counterpart) + obj.counterpart_address.nil? || Monite::PurchaseOrderCounterpartAddressSchema.validate_raw(obj: obj.counterpart_address) + obj.counterpart_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_address_id is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.created_by_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_user_id is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.document_id.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + Monite::PurchaseOrderResponseSchemaEntity.validate_raw(obj: obj.entity) + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.entity_vat_id.nil? || Monite::PurchaseOrderVatId.validate_raw(obj: obj.entity_vat_id) + obj.file_id&.is_a?(String) != false || raise("Passed value for field obj.file_id is not the expected type, validation failed.") + obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") + obj.issued_at&.is_a?(String) != false || raise("Passed value for field obj.issued_at is not the expected type, validation failed.") + obj.items.is_a?(Array) != false || raise("Passed value for field obj.items is not the expected type, validation failed.") + obj.message.is_a?(String) != false || raise("Passed value for field obj.message is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.valid_for_days.is_a?(Integer) != false || raise("Passed value for field obj.valid_for_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_response_schema_entity.rb b/lib/monite/types/purchase_order_response_schema_entity.rb new file mode 100644 index 0000000..48b39e4 --- /dev/null +++ b/lib/monite/types/purchase_order_response_schema_entity.rb @@ -0,0 +1,59 @@ +# frozen_string_literal: true +require "json" +require_relative "payable_entity_individual_response" +require_relative "payable_entity_organization_response" + +module Monite +# Data of the entity (address, name, contact) + class PurchaseOrderResponseSchemaEntity + + +# Deserialize a JSON object to an instance of PurchaseOrderResponseSchemaEntity + # + # @param json_object [String] + # @return [Monite::PurchaseOrderResponseSchemaEntity] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::PayableEntityIndividualResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::PayableEntityIndividualResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::PayableEntityOrganizationResponse.validate_raw(obj: struct) + unless struct.nil? + return Monite::PayableEntityOrganizationResponse.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::PayableEntityIndividualResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::PayableEntityOrganizationResponse.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_status_enum.rb b/lib/monite/types/purchase_order_status_enum.rb new file mode 100644 index 0000000..8cdd05f --- /dev/null +++ b/lib/monite/types/purchase_order_status_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class PurchaseOrderStatusEnum + + DRAFT = "draft" + ISSUED = "issued" + + end +end \ No newline at end of file diff --git a/lib/monite/types/purchase_order_vat_id.rb b/lib/monite/types/purchase_order_vat_id.rb new file mode 100644 index 0000000..692151f --- /dev/null +++ b/lib/monite/types/purchase_order_vat_id.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class PurchaseOrderVatId + # @return [String] + attr_reader :id + # @return [String] + attr_reader :country + # @return [String] + attr_reader :entity_id + # @return [String] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param country [String] + # @param entity_id [String] + # @param type [String] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::PurchaseOrderVatId] + def initialize(id:, country:, entity_id:, type:, value:, additional_properties: nil) + @id = id + @country = country + @entity_id = entity_id + @type = type + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "country": country, "entity_id": entity_id, "type": type, "value": value } + end +# Deserialize a JSON object to an instance of PurchaseOrderVatId + # + # @param json_object [String] + # @return [Monite::PurchaseOrderVatId] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + country = parsed_json["country"] + entity_id = parsed_json["entity_id"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + id: id, + country: country, + entity_id: entity_id, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of PurchaseOrderVatId to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.country.is_a?(String) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/quote_response_payload.rb b/lib/monite/types/quote_response_payload.rb new file mode 100644 index 0000000..47e739e --- /dev/null +++ b/lib/monite/types/quote_response_payload.rb @@ -0,0 +1,530 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "receivables_representation_of_counterpart_address" +require_relative "receivable_counterpart_contact" +require_relative "receivable_counterpart_type" +require_relative "receivable_counterpart_vat_id_response" +require_relative "currency_enum" +require_relative "discount" +require_relative "quote_response_payload_entity" +require_relative "receivable_entity_address_schema" +require_relative "receivables_representation_of_entity_bank_account" +require_relative "receivable_entity_vat_id_response" +require_relative "language_code_enum" +require "date" +require_relative "response_item" +require_relative "quote_state_enum" +require_relative "tag_read_schema" +require_relative "total_vat_amount_item" +require_relative "vat_mode_enum" +require "ostruct" +require "json" + +module Monite + class QuoteResponsePayload + # @return [String] + attr_reader :id + # @return [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + attr_reader :updated_at + # @return [String] The unique ID of a previous document related to the receivable if applicable. + attr_reader :based_on + # @return [String] The unique document ID of a previous document related to the receivable if +# applicable. + attr_reader :based_on_document_id + # @return [String] Field with a comment on why the client declined this Quote + attr_reader :comment + # @return [String] The commercial terms of the receivable (e.g. The products must be delivered in X +# days). + attr_reader :commercial_condition_description + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address + # @return [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + attr_reader :counterpart_business_type + # @return [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + attr_reader :counterpart_contact + # @return [String] Unique ID of the counterpart. + attr_reader :counterpart_id + # @return [String] A legal name of a counterpart it is an organization or first and last name if it +# is an individual + attr_reader :counterpart_name + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address + # @return [String] The VAT/TAX ID of the counterpart. + attr_reader :counterpart_tax_id + # @return [Monite::ReceivableCounterpartType] The type of the counterpart. + attr_reader :counterpart_type + # @return [Monite::ReceivableCounterpartVatIdResponse] + attr_reader :counterpart_vat_id + # @return [Monite::CurrencyEnum] The currency used in the receivable. + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [Integer] Total price of the receivable with discounts before taxes [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :discounted_subtotal + # @return [String] The sequential code systematically assigned to invoices. + attr_reader :document_id + # @return [String] Optional field representing date until which invoice should be paid + attr_reader :due_date + # @return [Monite::QuoteResponsePayloadEntity] + attr_reader :entity + # @return [Monite::ReceivableEntityAddressSchema] + attr_reader :entity_address + # @return [Monite::ReceivablesRepresentationOfEntityBankAccount] + attr_reader :entity_bank_account + # @return [String] The entity user who created this document. + attr_reader :entity_user_id + # @return [Monite::ReceivableEntityVatIdResponse] + attr_reader :entity_vat_id + # @return [String] The date (in ISO 8601 format) until which the quote is valid. + attr_reader :expiry_date + # @return [Monite::LanguageCodeEnum] The language of the customer-facing PDF file (`file_url`). The value matches the +# counterpart's `language` at the time when this PDF file was generated. + attr_reader :file_language + # @return [String] The receivable's PDF URL in the counterpart's default language. + attr_reader :file_url + # @return [DateTime] Optional field for the issue of the entry. + attr_reader :issue_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable. + attr_reader :memo + # @return [Monite::LanguageCodeEnum] The language of the entity's copy of the PDF file (`original_file_url`). The +# value matches the entity's `language` at the time when this PDF file was +# generated. + attr_reader :original_file_language + # @return [String] The receivable's PDF URL in the entity's default language. + attr_reader :original_file_url + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [String] Link for custom quote accept page + attr_reader :quote_accept_page_url + # @return [Boolean] Whether acceptance a quote requires a signature. + attr_reader :signature_required + # @return [Monite::QuoteStateEnum] The status of the Quote inside the receivable workflow. + attr_reader :status + # @return [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :subtotal + # @return [Array] The list of tags for this receivable. + attr_reader :tags + # @return [Integer] Total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Calculated as +# a subtotal + total_vat_amount. + attr_reader :total_amount + # @return [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :total_vat_amount + # @return [Array] List of total vat amount for each VAT, presented in receivable + attr_reader :total_vat_amounts + # @return [Integer] Total price of the receivable with tax withheld in minor units + attr_reader :total_withholding_tax + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + attr_reader :vat_mode + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + # @param based_on [String] The unique ID of a previous document related to the receivable if applicable. + # @param based_on_document_id [String] The unique document ID of a previous document related to the receivable if +# applicable. + # @param comment [String] Field with a comment on why the client declined this Quote + # @param commercial_condition_description [String] The commercial terms of the receivable (e.g. The products must be delivered in X +# days). + # @param counterpart_billing_address [Monite::ReceivablesRepresentationOfCounterpartAddress] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_business_type [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + # @param counterpart_contact [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + # @param counterpart_id [String] Unique ID of the counterpart. + # @param counterpart_name [String] A legal name of a counterpart it is an organization or first and last name if it +# is an individual + # @param counterpart_shipping_address [Monite::ReceivablesRepresentationOfCounterpartAddress] Address where goods were shipped / where services were provided. + # @param counterpart_tax_id [String] The VAT/TAX ID of the counterpart. + # @param counterpart_type [Monite::ReceivableCounterpartType] The type of the counterpart. + # @param counterpart_vat_id [Monite::ReceivableCounterpartVatIdResponse] + # @param currency [Monite::CurrencyEnum] The currency used in the receivable. + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param discounted_subtotal [Integer] Total price of the receivable with discounts before taxes [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param document_id [String] The sequential code systematically assigned to invoices. + # @param due_date [String] Optional field representing date until which invoice should be paid + # @param entity [Monite::QuoteResponsePayloadEntity] + # @param entity_address [Monite::ReceivableEntityAddressSchema] + # @param entity_bank_account [Monite::ReceivablesRepresentationOfEntityBankAccount] + # @param entity_user_id [String] The entity user who created this document. + # @param entity_vat_id [Monite::ReceivableEntityVatIdResponse] + # @param expiry_date [String] The date (in ISO 8601 format) until which the quote is valid. + # @param file_language [Monite::LanguageCodeEnum] The language of the customer-facing PDF file (`file_url`). The value matches the +# counterpart's `language` at the time when this PDF file was generated. + # @param file_url [String] The receivable's PDF URL in the counterpart's default language. + # @param issue_date [DateTime] Optional field for the issue of the entry. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable. + # @param original_file_language [Monite::LanguageCodeEnum] The language of the entity's copy of the PDF file (`original_file_url`). The +# value matches the entity's `language` at the time when this PDF file was +# generated. + # @param original_file_url [String] The receivable's PDF URL in the entity's default language. + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param project_id [String] A project related to current receivable + # @param quote_accept_page_url [String] Link for custom quote accept page + # @param signature_required [Boolean] Whether acceptance a quote requires a signature. + # @param status [Monite::QuoteStateEnum] The status of the Quote inside the receivable workflow. + # @param subtotal [Integer] The subtotal (excluding VAT), in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param tags [Array] The list of tags for this receivable. + # @param total_amount [Integer] Total price of the receivable in [minor +# units](https://docs.monite.com/references/currencies#minor-units). Calculated as +# a subtotal + total_vat_amount. + # @param total_vat_amount [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param total_vat_amounts [Array] List of total vat amount for each VAT, presented in receivable + # @param total_withholding_tax [Integer] Total price of the receivable with tax withheld in minor units + # @param trade_name [String] Trade name of the entity + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::QuoteResponsePayload] + def initialize(id:, created_at:, updated_at:, based_on: OMIT, based_on_document_id: OMIT, comment: OMIT, commercial_condition_description: OMIT, counterpart_billing_address: OMIT, counterpart_business_type: OMIT, counterpart_contact: OMIT, counterpart_id:, counterpart_name: OMIT, counterpart_shipping_address: OMIT, counterpart_tax_id: OMIT, counterpart_type:, counterpart_vat_id: OMIT, currency:, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, discounted_subtotal: OMIT, document_id: OMIT, due_date: OMIT, entity:, entity_address:, entity_bank_account: OMIT, entity_user_id: OMIT, entity_vat_id: OMIT, expiry_date: OMIT, file_language:, file_url: OMIT, issue_date: OMIT, line_items:, memo: OMIT, original_file_language:, original_file_url: OMIT, partner_metadata: OMIT, project_id: OMIT, quote_accept_page_url: OMIT, signature_required: OMIT, status:, subtotal: OMIT, tags: OMIT, total_amount: OMIT, total_vat_amount:, total_vat_amounts: OMIT, total_withholding_tax: OMIT, trade_name: OMIT, vat_exempt: OMIT, vat_exemption_rationale: OMIT, vat_mode: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @based_on = based_on if based_on != OMIT + @based_on_document_id = based_on_document_id if based_on_document_id != OMIT + @comment = comment if comment != OMIT + @commercial_condition_description = commercial_condition_description if commercial_condition_description != OMIT + @counterpart_billing_address = counterpart_billing_address if counterpart_billing_address != OMIT + @counterpart_business_type = counterpart_business_type if counterpart_business_type != OMIT + @counterpart_contact = counterpart_contact if counterpart_contact != OMIT + @counterpart_id = counterpart_id + @counterpart_name = counterpart_name if counterpart_name != OMIT + @counterpart_shipping_address = counterpart_shipping_address if counterpart_shipping_address != OMIT + @counterpart_tax_id = counterpart_tax_id if counterpart_tax_id != OMIT + @counterpart_type = counterpart_type + @counterpart_vat_id = counterpart_vat_id if counterpart_vat_id != OMIT + @currency = currency + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @discounted_subtotal = discounted_subtotal if discounted_subtotal != OMIT + @document_id = document_id if document_id != OMIT + @due_date = due_date if due_date != OMIT + @entity = entity + @entity_address = entity_address + @entity_bank_account = entity_bank_account if entity_bank_account != OMIT + @entity_user_id = entity_user_id if entity_user_id != OMIT + @entity_vat_id = entity_vat_id if entity_vat_id != OMIT + @expiry_date = expiry_date if expiry_date != OMIT + @file_language = file_language + @file_url = file_url if file_url != OMIT + @issue_date = issue_date if issue_date != OMIT + @line_items = line_items + @memo = memo if memo != OMIT + @original_file_language = original_file_language + @original_file_url = original_file_url if original_file_url != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @project_id = project_id if project_id != OMIT + @quote_accept_page_url = quote_accept_page_url if quote_accept_page_url != OMIT + @signature_required = signature_required if signature_required != OMIT + @status = status + @subtotal = subtotal if subtotal != OMIT + @tags = tags if tags != OMIT + @total_amount = total_amount if total_amount != OMIT + @total_vat_amount = total_vat_amount + @total_vat_amounts = total_vat_amounts if total_vat_amounts != OMIT + @total_withholding_tax = total_withholding_tax if total_withholding_tax != OMIT + @trade_name = trade_name if trade_name != OMIT + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @vat_mode = vat_mode if vat_mode != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "based_on": based_on, "based_on_document_id": based_on_document_id, "comment": comment, "commercial_condition_description": commercial_condition_description, "counterpart_billing_address": counterpart_billing_address, "counterpart_business_type": counterpart_business_type, "counterpart_contact": counterpart_contact, "counterpart_id": counterpart_id, "counterpart_name": counterpart_name, "counterpart_shipping_address": counterpart_shipping_address, "counterpart_tax_id": counterpart_tax_id, "counterpart_type": counterpart_type, "counterpart_vat_id": counterpart_vat_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "discounted_subtotal": discounted_subtotal, "document_id": document_id, "due_date": due_date, "entity": entity, "entity_address": entity_address, "entity_bank_account": entity_bank_account, "entity_user_id": entity_user_id, "entity_vat_id": entity_vat_id, "expiry_date": expiry_date, "file_language": file_language, "file_url": file_url, "issue_date": issue_date, "line_items": line_items, "memo": memo, "original_file_language": original_file_language, "original_file_url": original_file_url, "partner_metadata": partner_metadata, "project_id": project_id, "quote_accept_page_url": quote_accept_page_url, "signature_required": signature_required, "status": status, "subtotal": subtotal, "tags": tags, "total_amount": total_amount, "total_vat_amount": total_vat_amount, "total_vat_amounts": total_vat_amounts, "total_withholding_tax": total_withholding_tax, "trade_name": trade_name, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "vat_mode": vat_mode, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of QuoteResponsePayload + # + # @param json_object [String] + # @return [Monite::QuoteResponsePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + based_on = parsed_json["based_on"] + based_on_document_id = parsed_json["based_on_document_id"] + comment = parsed_json["comment"] + commercial_condition_description = parsed_json["commercial_condition_description"] + unless parsed_json["counterpart_billing_address"].nil? + counterpart_billing_address = parsed_json["counterpart_billing_address"].to_json + counterpart_billing_address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: counterpart_billing_address) + else + counterpart_billing_address = nil + end + counterpart_business_type = parsed_json["counterpart_business_type"] + unless parsed_json["counterpart_contact"].nil? + counterpart_contact = parsed_json["counterpart_contact"].to_json + counterpart_contact = Monite::ReceivableCounterpartContact.from_json(json_object: counterpart_contact) + else + counterpart_contact = nil + end + counterpart_id = parsed_json["counterpart_id"] + counterpart_name = parsed_json["counterpart_name"] + unless parsed_json["counterpart_shipping_address"].nil? + counterpart_shipping_address = parsed_json["counterpart_shipping_address"].to_json + counterpart_shipping_address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: counterpart_shipping_address) + else + counterpart_shipping_address = nil + end + counterpart_tax_id = parsed_json["counterpart_tax_id"] + counterpart_type = parsed_json["counterpart_type"] + unless parsed_json["counterpart_vat_id"].nil? + counterpart_vat_id = parsed_json["counterpart_vat_id"].to_json + counterpart_vat_id = Monite::ReceivableCounterpartVatIdResponse.from_json(json_object: counterpart_vat_id) + else + counterpart_vat_id = nil + end + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + discounted_subtotal = parsed_json["discounted_subtotal"] + document_id = parsed_json["document_id"] + due_date = parsed_json["due_date"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::QuoteResponsePayloadEntity.from_json(json_object: entity) + else + entity = nil + end + unless parsed_json["entity_address"].nil? + entity_address = parsed_json["entity_address"].to_json + entity_address = Monite::ReceivableEntityAddressSchema.from_json(json_object: entity_address) + else + entity_address = nil + end + unless parsed_json["entity_bank_account"].nil? + entity_bank_account = parsed_json["entity_bank_account"].to_json + entity_bank_account = Monite::ReceivablesRepresentationOfEntityBankAccount.from_json(json_object: entity_bank_account) + else + entity_bank_account = nil + end + entity_user_id = parsed_json["entity_user_id"] + unless parsed_json["entity_vat_id"].nil? + entity_vat_id = parsed_json["entity_vat_id"].to_json + entity_vat_id = Monite::ReceivableEntityVatIdResponse.from_json(json_object: entity_vat_id) + else + entity_vat_id = nil + end + expiry_date = parsed_json["expiry_date"] + file_language = parsed_json["file_language"] + file_url = parsed_json["file_url"] + issue_date = unless parsed_json["issue_date"].nil? + DateTime.parse(parsed_json["issue_date"]) +else + nil +end + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::ResponseItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + original_file_language = parsed_json["original_file_language"] + original_file_url = parsed_json["original_file_url"] + partner_metadata = parsed_json["partner_metadata"] + project_id = parsed_json["project_id"] + quote_accept_page_url = parsed_json["quote_accept_page_url"] + signature_required = parsed_json["signature_required"] + status = parsed_json["status"] + subtotal = parsed_json["subtotal"] + tags = parsed_json["tags"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + total_amount = parsed_json["total_amount"] + total_vat_amount = parsed_json["total_vat_amount"] + total_vat_amounts = parsed_json["total_vat_amounts"]&.map do | item | + item = item.to_json + Monite::TotalVatAmountItem.from_json(json_object: item) +end + total_withholding_tax = parsed_json["total_withholding_tax"] + trade_name = parsed_json["trade_name"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + vat_mode = parsed_json["vat_mode"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + based_on: based_on, + based_on_document_id: based_on_document_id, + comment: comment, + commercial_condition_description: commercial_condition_description, + counterpart_billing_address: counterpart_billing_address, + counterpart_business_type: counterpart_business_type, + counterpart_contact: counterpart_contact, + counterpart_id: counterpart_id, + counterpart_name: counterpart_name, + counterpart_shipping_address: counterpart_shipping_address, + counterpart_tax_id: counterpart_tax_id, + counterpart_type: counterpart_type, + counterpart_vat_id: counterpart_vat_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + discounted_subtotal: discounted_subtotal, + document_id: document_id, + due_date: due_date, + entity: entity, + entity_address: entity_address, + entity_bank_account: entity_bank_account, + entity_user_id: entity_user_id, + entity_vat_id: entity_vat_id, + expiry_date: expiry_date, + file_language: file_language, + file_url: file_url, + issue_date: issue_date, + line_items: line_items, + memo: memo, + original_file_language: original_file_language, + original_file_url: original_file_url, + partner_metadata: partner_metadata, + project_id: project_id, + quote_accept_page_url: quote_accept_page_url, + signature_required: signature_required, + status: status, + subtotal: subtotal, + tags: tags, + total_amount: total_amount, + total_vat_amount: total_vat_amount, + total_vat_amounts: total_vat_amounts, + total_withholding_tax: total_withholding_tax, + trade_name: trade_name, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + vat_mode: vat_mode, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of QuoteResponsePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.based_on&.is_a?(String) != false || raise("Passed value for field obj.based_on is not the expected type, validation failed.") + obj.based_on_document_id&.is_a?(String) != false || raise("Passed value for field obj.based_on_document_id is not the expected type, validation failed.") + obj.comment&.is_a?(String) != false || raise("Passed value for field obj.comment is not the expected type, validation failed.") + obj.commercial_condition_description&.is_a?(String) != false || raise("Passed value for field obj.commercial_condition_description is not the expected type, validation failed.") + obj.counterpart_billing_address.nil? || Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.counterpart_billing_address) + obj.counterpart_business_type&.is_a?(String) != false || raise("Passed value for field obj.counterpart_business_type is not the expected type, validation failed.") + obj.counterpart_contact.nil? || Monite::ReceivableCounterpartContact.validate_raw(obj: obj.counterpart_contact) + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_name&.is_a?(String) != false || raise("Passed value for field obj.counterpart_name is not the expected type, validation failed.") + obj.counterpart_shipping_address.nil? || Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.counterpart_shipping_address) + obj.counterpart_tax_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_tax_id is not the expected type, validation failed.") + obj.counterpart_type.is_a?(Monite::ReceivableCounterpartType) != false || raise("Passed value for field obj.counterpart_type is not the expected type, validation failed.") + obj.counterpart_vat_id.nil? || Monite::ReceivableCounterpartVatIdResponse.validate_raw(obj: obj.counterpart_vat_id) + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.discounted_subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.discounted_subtotal is not the expected type, validation failed.") + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.due_date&.is_a?(String) != false || raise("Passed value for field obj.due_date is not the expected type, validation failed.") + Monite::QuoteResponsePayloadEntity.validate_raw(obj: obj.entity) + Monite::ReceivableEntityAddressSchema.validate_raw(obj: obj.entity_address) + obj.entity_bank_account.nil? || Monite::ReceivablesRepresentationOfEntityBankAccount.validate_raw(obj: obj.entity_bank_account) + obj.entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.entity_user_id is not the expected type, validation failed.") + obj.entity_vat_id.nil? || Monite::ReceivableEntityVatIdResponse.validate_raw(obj: obj.entity_vat_id) + obj.expiry_date&.is_a?(String) != false || raise("Passed value for field obj.expiry_date is not the expected type, validation failed.") + obj.file_language.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.file_language is not the expected type, validation failed.") + obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") + obj.issue_date&.is_a?(DateTime) != false || raise("Passed value for field obj.issue_date is not the expected type, validation failed.") + obj.line_items.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.original_file_language.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.original_file_language is not the expected type, validation failed.") + obj.original_file_url&.is_a?(String) != false || raise("Passed value for field obj.original_file_url is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.quote_accept_page_url&.is_a?(String) != false || raise("Passed value for field obj.quote_accept_page_url is not the expected type, validation failed.") + obj.signature_required&.is_a?(Boolean) != false || raise("Passed value for field obj.signature_required is not the expected type, validation failed.") + obj.status.is_a?(Monite::QuoteStateEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subtotal&.is_a?(Integer) != false || raise("Passed value for field obj.subtotal is not the expected type, validation failed.") + obj.tags&.is_a?(Array) != false || raise("Passed value for field obj.tags is not the expected type, validation failed.") + obj.total_amount&.is_a?(Integer) != false || raise("Passed value for field obj.total_amount is not the expected type, validation failed.") + obj.total_vat_amount.is_a?(Integer) != false || raise("Passed value for field obj.total_vat_amount is not the expected type, validation failed.") + obj.total_vat_amounts&.is_a?(Array) != false || raise("Passed value for field obj.total_vat_amounts is not the expected type, validation failed.") + obj.total_withholding_tax&.is_a?(Integer) != false || raise("Passed value for field obj.total_withholding_tax is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.vat_mode&.is_a?(Monite::VatModeEnum) != false || raise("Passed value for field obj.vat_mode is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/quote_response_payload_entity.rb b/lib/monite/types/quote_response_payload_entity.rb new file mode 100644 index 0000000..6985bd4 --- /dev/null +++ b/lib/monite/types/quote_response_payload_entity.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "json" +require_relative "receivable_entity_organization" +require_relative "receivable_entity_individual" + +module Monite + class QuoteResponsePayloadEntity + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::QuoteResponsePayloadEntity] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of QuoteResponsePayloadEntity + # + # @param json_object [String] + # @return [Monite::QuoteResponsePayloadEntity] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "organization" + member = Monite::ReceivableEntityOrganization.from_json(json_object: json_object) + when "individual" + member = Monite::ReceivableEntityIndividual.from_json(json_object: json_object) + else + member = Monite::ReceivableEntityOrganization.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "organization" + { **@member.to_json, type: @discriminant }.to_json + when "individual" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "organization" + Monite::ReceivableEntityOrganization.validate_raw(obj: obj) + when "individual" + Monite::ReceivableEntityIndividual.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::ReceivableEntityOrganization] + # @return [Monite::QuoteResponsePayloadEntity] + def self.organization(member:) + new(member: member, discriminant: "organization") + end + # @param member [Monite::ReceivableEntityIndividual] + # @return [Monite::QuoteResponsePayloadEntity] + def self.individual(member:) + new(member: member, discriminant: "individual") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/quote_state_enum.rb b/lib/monite/types/quote_state_enum.rb new file mode 100644 index 0000000..76e587f --- /dev/null +++ b/lib/monite/types/quote_state_enum.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite + class QuoteStateEnum + + DRAFT = "draft" + ISSUED = "issued" + ACCEPTED = "accepted" + EXPIRED = "expired" + DECLINED = "declined" + DELETED = "deleted" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_counterpart_contact.rb b/lib/monite/types/receivable_counterpart_contact.rb new file mode 100644 index 0000000..ada47da --- /dev/null +++ b/lib/monite/types/receivable_counterpart_contact.rb @@ -0,0 +1,97 @@ +# frozen_string_literal: true +require_relative "receivables_representation_of_counterpart_address" +require "ostruct" +require "json" + +module Monite + class ReceivableCounterpartContact + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] The contact address of the counterpart + attr_reader :address + # @return [String] The contact email of the counterpart. + attr_reader :email + # @return [String] The first name of the counterpart contact. + attr_reader :first_name + # @return [String] The last name of the counterpart contact. + attr_reader :last_name + # @return [String] The contact phone number of the counterpart. + attr_reader :phone + # @return [String] The counterpart contact title (e.g. Dr., Mr., Mrs., Ms., etc). + attr_reader :title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address [Monite::ReceivablesRepresentationOfCounterpartAddress] The contact address of the counterpart + # @param email [String] The contact email of the counterpart. + # @param first_name [String] The first name of the counterpart contact. + # @param last_name [String] The last name of the counterpart contact. + # @param phone [String] The contact phone number of the counterpart. + # @param title [String] The counterpart contact title (e.g. Dr., Mr., Mrs., Ms., etc). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableCounterpartContact] + def initialize(address:, email: OMIT, first_name:, last_name:, phone: OMIT, title: OMIT, additional_properties: nil) + @address = address + @email = email if email != OMIT + @first_name = first_name + @last_name = last_name + @phone = phone if phone != OMIT + @title = title if title != OMIT + @additional_properties = additional_properties + @_field_set = { "address": address, "email": email, "first_name": first_name, "last_name": last_name, "phone": phone, "title": title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableCounterpartContact + # + # @param json_object [String] + # @return [Monite::ReceivableCounterpartContact] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::ReceivablesRepresentationOfCounterpartAddress.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + first_name = parsed_json["first_name"] + last_name = parsed_json["last_name"] + phone = parsed_json["phone"] + title = parsed_json["title"] + new( + address: address, + email: email, + first_name: first_name, + last_name: last_name, + phone: phone, + title: title, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableCounterpartContact to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::ReceivablesRepresentationOfCounterpartAddress.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.title&.is_a?(String) != false || raise("Passed value for field obj.title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_counterpart_type.rb b/lib/monite/types/receivable_counterpart_type.rb new file mode 100644 index 0000000..c0ff2a3 --- /dev/null +++ b/lib/monite/types/receivable_counterpart_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ReceivableCounterpartType + + INDIVIDUAL = "individual" + ORGANIZATION = "organization" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_counterpart_vat_id_response.rb b/lib/monite/types/receivable_counterpart_vat_id_response.rb new file mode 100644 index 0000000..8b0640f --- /dev/null +++ b/lib/monite/types/receivable_counterpart_vat_id_response.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "vat_id_type_enum" +require "ostruct" +require "json" + +module Monite + class ReceivableCounterpartVatIdResponse + # @return [String] + attr_reader :id + # @return [String] + attr_reader :counterpart_id + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [Monite::VatIdTypeEnum] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param counterpart_id [String] + # @param country [Monite::AllowedCountries] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableCounterpartVatIdResponse] + def initialize(id:, counterpart_id:, country: OMIT, type: OMIT, value:, additional_properties: nil) + @id = id + @counterpart_id = counterpart_id + @country = country if country != OMIT + @type = type if type != OMIT + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "counterpart_id": counterpart_id, "country": country, "type": type, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableCounterpartVatIdResponse + # + # @param json_object [String] + # @return [Monite::ReceivableCounterpartVatIdResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + counterpart_id = parsed_json["counterpart_id"] + country = parsed_json["country"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + id: id, + counterpart_id: counterpart_id, + country: country, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableCounterpartVatIdResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.type&.is_a?(Monite::VatIdTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_create_based_on_payload.rb b/lib/monite/types/receivable_create_based_on_payload.rb new file mode 100644 index 0000000..ac82780 --- /dev/null +++ b/lib/monite/types/receivable_create_based_on_payload.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true +require_relative "based_on_transition_type" +require "ostruct" +require "json" + +module Monite + class ReceivableCreateBasedOnPayload + # @return [String] The unique ID of a previous document related to the receivable if applicable. + attr_reader :based_on + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [Monite::BasedOnTransitionType] The type of a created receivable. Currently supported transitions:quote -> +# invoice; invoice -> credit_note + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param based_on [String] The unique ID of a previous document related to the receivable if applicable. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param type [Monite::BasedOnTransitionType] The type of a created receivable. Currently supported transitions:quote -> +# invoice; invoice -> credit_note + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableCreateBasedOnPayload] + def initialize(based_on:, tag_ids: OMIT, type:, additional_properties: nil) + @based_on = based_on + @tag_ids = tag_ids if tag_ids != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "based_on": based_on, "tag_ids": tag_ids, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableCreateBasedOnPayload + # + # @param json_object [String] + # @return [Monite::ReceivableCreateBasedOnPayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + based_on = parsed_json["based_on"] + tag_ids = parsed_json["tag_ids"] + type = parsed_json["type"] + new( + based_on: based_on, + tag_ids: tag_ids, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableCreateBasedOnPayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.based_on.is_a?(String) != false || raise("Passed value for field obj.based_on is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.type.is_a?(Monite::BasedOnTransitionType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_created_event_data.rb b/lib/monite/types/receivable_created_event_data.rb new file mode 100644 index 0000000..b929441 --- /dev/null +++ b/lib/monite/types/receivable_created_event_data.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivableCreatedEventData + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableCreatedEventData] + def initialize(additional_properties: nil) + @additional_properties = additional_properties + @_field_set = { } + end +# Deserialize a JSON object to an instance of ReceivableCreatedEventData + # + # @param json_object [String] + # @return [Monite::ReceivableCreatedEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + new(additional_properties: struct) + end +# Serialize an instance of ReceivableCreatedEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_cursor_fields.rb b/lib/monite/types/receivable_cursor_fields.rb new file mode 100644 index 0000000..1196381 --- /dev/null +++ b/lib/monite/types/receivable_cursor_fields.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module Monite + class ReceivableCursorFields + + COUNTERPART_NAME = "counterpart_name" + COUNTERPART_ID = "counterpart_id" + AMOUNT = "amount" + STATUS = "status" + DUE_DATE = "due_date" + ISSUE_DATE = "issue_date" + DOCUMENT_ID = "document_id" + CREATED_AT = "created_at" + PROJECT_ID = "project_id" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_edit_flow.rb b/lib/monite/types/receivable_edit_flow.rb new file mode 100644 index 0000000..78b6ef1 --- /dev/null +++ b/lib/monite/types/receivable_edit_flow.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class ReceivableEditFlow + + COMPLIANT = "compliant" + PARTIALLY_COMPLIANT = "partially_compliant" + NON_COMPLIANT = "non_compliant" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_address_schema.rb b/lib/monite/types/receivable_entity_address_schema.rb new file mode 100644 index 0000000..85d09cc --- /dev/null +++ b/lib/monite/types/receivable_entity_address_schema.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite +# A schema represents address info of the entity + class ReceivableEntityAddressSchema + # @return [String] A city (a full name) where the entity is registered + attr_reader :city + # @return [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + attr_reader :country + # @return [String] A street where the entity is registered + attr_reader :line_1 + # @return [String] An alternative street used by the entity + attr_reader :line_2 + # @return [String] A postal code of the address where the entity is registered + attr_reader :postal_code + # @return [String] A state in a country where the entity is registered + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] A city (a full name) where the entity is registered + # @param country [Monite::AllowedCountries] A country name (as ISO code) where the entity is registered + # @param line_1 [String] A street where the entity is registered + # @param line_2 [String] An alternative street used by the entity + # @param postal_code [String] A postal code of the address where the entity is registered + # @param state [String] A state in a country where the entity is registered + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityAddressSchema] + def initialize(city:, country: OMIT, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @city = city + @country = country if country != OMIT + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityAddressSchema + # + # @param json_object [String] + # @return [Monite::ReceivableEntityAddressSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityAddressSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country&.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_base.rb b/lib/monite/types/receivable_entity_base.rb new file mode 100644 index 0000000..6c16e2a --- /dev/null +++ b/lib/monite/types/receivable_entity_base.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A base schemas for an entity + class ReceivableEntityBase + # @return [String] An email of the entity + attr_reader :email + # @return [String] A link to the entity logo + attr_reader :logo + # @return [String] A phone number of the entity + attr_reader :phone + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] An email of the entity + # @param logo [String] A link to the entity logo + # @param phone [String] A phone number of the entity + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityBase] + def initialize(email: OMIT, logo: OMIT, phone: OMIT, website: OMIT, additional_properties: nil) + @email = email if email != OMIT + @logo = logo if logo != OMIT + @phone = phone if phone != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "logo": logo, "phone": phone, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityBase + # + # @param json_object [String] + # @return [Monite::ReceivableEntityBase] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + logo = parsed_json["logo"] + phone = parsed_json["phone"] + website = parsed_json["website"] + new( + email: email, + logo: logo, + phone: phone, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityBase to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.logo&.is_a?(String) != false || raise("Passed value for field obj.logo is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_individual.rb b/lib/monite/types/receivable_entity_individual.rb new file mode 100644 index 0000000..b8b1d8d --- /dev/null +++ b/lib/monite/types/receivable_entity_individual.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A Response schema for an entity of individual type + class ReceivableEntityIndividual + # @return [String] An email of the entity + attr_reader :email + # @return [String] The first name of the entity issuing the receivable + attr_reader :first_name + # @return [String] The last name of the entity issuing the receivable + attr_reader :last_name + # @return [String] A link to the entity logo + attr_reader :logo + # @return [String] A phone number of the entity + attr_reader :phone + # @return [String] The Tax ID of the entity issuing the receivable + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] An email of the entity + # @param first_name [String] The first name of the entity issuing the receivable + # @param last_name [String] The last name of the entity issuing the receivable + # @param logo [String] A link to the entity logo + # @param phone [String] A phone number of the entity + # @param tax_id [String] The Tax ID of the entity issuing the receivable + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityIndividual] + def initialize(email: OMIT, first_name:, last_name:, logo: OMIT, phone: OMIT, tax_id: OMIT, website: OMIT, additional_properties: nil) + @email = email if email != OMIT + @first_name = first_name + @last_name = last_name + @logo = logo if logo != OMIT + @phone = phone if phone != OMIT + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "first_name": first_name, "last_name": last_name, "logo": logo, "phone": phone, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityIndividual + # + # @param json_object [String] + # @return [Monite::ReceivableEntityIndividual] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + first_name = parsed_json["first_name"] + last_name = parsed_json["last_name"] + logo = parsed_json["logo"] + phone = parsed_json["phone"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + email: email, + first_name: first_name, + last_name: last_name, + logo: logo, + phone: phone, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityIndividual to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.logo&.is_a?(String) != false || raise("Passed value for field obj.logo is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_individual_request.rb b/lib/monite/types/receivable_entity_individual_request.rb new file mode 100644 index 0000000..bdefbe5 --- /dev/null +++ b/lib/monite/types/receivable_entity_individual_request.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A Request schema for an entity of individual type + class ReceivableEntityIndividualRequest + # @return [String] An email of the entity + attr_reader :email + # @return [String] The first name of the entity issuing the receivable + attr_reader :first_name + # @return [String] The last name of the entity issuing the receivable + attr_reader :last_name + # @return [String] A link to the entity logo + attr_reader :logo + # @return [String] A phone number of the entity + attr_reader :phone + # @return [String] The Tax ID of the entity issuing the receivable + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] An email of the entity + # @param first_name [String] The first name of the entity issuing the receivable + # @param last_name [String] The last name of the entity issuing the receivable + # @param logo [String] A link to the entity logo + # @param phone [String] A phone number of the entity + # @param tax_id [String] The Tax ID of the entity issuing the receivable + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityIndividualRequest] + def initialize(email: OMIT, first_name:, last_name:, logo: OMIT, phone: OMIT, tax_id: OMIT, website: OMIT, additional_properties: nil) + @email = email if email != OMIT + @first_name = first_name + @last_name = last_name + @logo = logo if logo != OMIT + @phone = phone if phone != OMIT + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "first_name": first_name, "last_name": last_name, "logo": logo, "phone": phone, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityIndividualRequest + # + # @param json_object [String] + # @return [Monite::ReceivableEntityIndividualRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + first_name = parsed_json["first_name"] + last_name = parsed_json["last_name"] + logo = parsed_json["logo"] + phone = parsed_json["phone"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + email: email, + first_name: first_name, + last_name: last_name, + logo: logo, + phone: phone, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityIndividualRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.first_name.is_a?(String) != false || raise("Passed value for field obj.first_name is not the expected type, validation failed.") + obj.last_name.is_a?(String) != false || raise("Passed value for field obj.last_name is not the expected type, validation failed.") + obj.logo&.is_a?(String) != false || raise("Passed value for field obj.logo is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_organization.rb b/lib/monite/types/receivable_entity_organization.rb new file mode 100644 index 0000000..12b6a5a --- /dev/null +++ b/lib/monite/types/receivable_entity_organization.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A Response schema for an entity of organization type + class ReceivableEntityOrganization + # @return [String] An email of the entity + attr_reader :email + # @return [String] A link to the entity logo + attr_reader :logo + # @return [String] The name of the entity issuing the receivable, when it is an organization. + attr_reader :name + # @return [String] A phone number of the entity + attr_reader :phone + # @return [String] The Tax ID of the entity issuing the receivable + attr_reader :tax_id + # @return [String] The VAT ID of the entity issuing the receivable, when it is an organization. + attr_reader :vat_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] An email of the entity + # @param logo [String] A link to the entity logo + # @param name [String] The name of the entity issuing the receivable, when it is an organization. + # @param phone [String] A phone number of the entity + # @param tax_id [String] The Tax ID of the entity issuing the receivable + # @param vat_id [String] The VAT ID of the entity issuing the receivable, when it is an organization. + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityOrganization] + def initialize(email: OMIT, logo: OMIT, name:, phone: OMIT, tax_id: OMIT, vat_id: OMIT, website: OMIT, additional_properties: nil) + @email = email if email != OMIT + @logo = logo if logo != OMIT + @name = name + @phone = phone if phone != OMIT + @tax_id = tax_id if tax_id != OMIT + @vat_id = vat_id if vat_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "logo": logo, "name": name, "phone": phone, "tax_id": tax_id, "vat_id": vat_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityOrganization + # + # @param json_object [String] + # @return [Monite::ReceivableEntityOrganization] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + logo = parsed_json["logo"] + name = parsed_json["name"] + phone = parsed_json["phone"] + tax_id = parsed_json["tax_id"] + vat_id = parsed_json["vat_id"] + website = parsed_json["website"] + new( + email: email, + logo: logo, + name: name, + phone: phone, + tax_id: tax_id, + vat_id: vat_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityOrganization to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.logo&.is_a?(String) != false || raise("Passed value for field obj.logo is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.vat_id&.is_a?(String) != false || raise("Passed value for field obj.vat_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_organization_request.rb b/lib/monite/types/receivable_entity_organization_request.rb new file mode 100644 index 0000000..8d18bb7 --- /dev/null +++ b/lib/monite/types/receivable_entity_organization_request.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A Request schema for an entity of organization type + class ReceivableEntityOrganizationRequest + # @return [String] An email of the entity + attr_reader :email + # @return [String] A link to the entity logo + attr_reader :logo + # @return [String] The name of the entity issuing the receivable, when it is an organization. + attr_reader :name + # @return [String] A phone number of the entity + attr_reader :phone + # @return [String] The Tax ID of the entity issuing the receivable + attr_reader :tax_id + # @return [String] A website of the entity + attr_reader :website + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] An email of the entity + # @param logo [String] A link to the entity logo + # @param name [String] The name of the entity issuing the receivable, when it is an organization. + # @param phone [String] A phone number of the entity + # @param tax_id [String] The Tax ID of the entity issuing the receivable + # @param website [String] A website of the entity + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityOrganizationRequest] + def initialize(email: OMIT, logo: OMIT, name:, phone: OMIT, tax_id: OMIT, website: OMIT, additional_properties: nil) + @email = email if email != OMIT + @logo = logo if logo != OMIT + @name = name + @phone = phone if phone != OMIT + @tax_id = tax_id if tax_id != OMIT + @website = website if website != OMIT + @additional_properties = additional_properties + @_field_set = { "email": email, "logo": logo, "name": name, "phone": phone, "tax_id": tax_id, "website": website }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityOrganizationRequest + # + # @param json_object [String] + # @return [Monite::ReceivableEntityOrganizationRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + logo = parsed_json["logo"] + name = parsed_json["name"] + phone = parsed_json["phone"] + tax_id = parsed_json["tax_id"] + website = parsed_json["website"] + new( + email: email, + logo: logo, + name: name, + phone: phone, + tax_id: tax_id, + website: website, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityOrganizationRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.logo&.is_a?(String) != false || raise("Passed value for field obj.logo is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_entity_vat_id_response.rb b/lib/monite/types/receivable_entity_vat_id_response.rb new file mode 100644 index 0000000..11dd793 --- /dev/null +++ b/lib/monite/types/receivable_entity_vat_id_response.rb @@ -0,0 +1,86 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require_relative "vat_id_type_enum" +require "ostruct" +require "json" + +module Monite + class ReceivableEntityVatIdResponse + # @return [String] + attr_reader :id + # @return [Monite::AllowedCountries] + attr_reader :country + # @return [String] + attr_reader :entity_id + # @return [Monite::VatIdTypeEnum] + attr_reader :type + # @return [String] + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param country [Monite::AllowedCountries] + # @param entity_id [String] + # @param type [Monite::VatIdTypeEnum] + # @param value [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableEntityVatIdResponse] + def initialize(id:, country:, entity_id:, type: OMIT, value:, additional_properties: nil) + @id = id + @country = country + @entity_id = entity_id + @type = type if type != OMIT + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "country": country, "entity_id": entity_id, "type": type, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableEntityVatIdResponse + # + # @param json_object [String] + # @return [Monite::ReceivableEntityVatIdResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + country = parsed_json["country"] + entity_id = parsed_json["entity_id"] + type = parsed_json["type"] + value = parsed_json["value"] + new( + id: id, + country: country, + entity_id: entity_id, + type: type, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableEntityVatIdResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.entity_id.is_a?(String) != false || raise("Passed value for field obj.entity_id is not the expected type, validation failed.") + obj.type&.is_a?(Monite::VatIdTypeEnum) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.value.is_a?(String) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_facade_create_invoice_payload.rb b/lib/monite/types/receivable_facade_create_invoice_payload.rb new file mode 100644 index 0000000..c8ac5d6 --- /dev/null +++ b/lib/monite/types/receivable_facade_create_invoice_payload.rb @@ -0,0 +1,310 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "discount" +require_relative "receivable_entity_base" +require_relative "line_item" +require_relative "vat_mode_enum" +require "ostruct" +require "json" + +module Monite + class ReceivableFacadeCreateInvoicePayload + # @return [String] + attr_reader :commercial_condition_description + # @return [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address_id + # @return [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + attr_reader :counterpart_business_type + # @return [String] + attr_reader :counterpart_id + # @return [String] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address_id + # @return [String] Counterpart VAT ID id + attr_reader :counterpart_vat_id_id + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [String] The document number of the receivable, which will appear in the PDF document. +# Can be set manually only in the [non-compliant +# //docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance). +# Otherwise (or if omitted), it will be generated automatically based on the +# entity's [document number +# customization](https://docs.monite.com/advanced/document-number-customization) +# settings when the document is issued. + attr_reader :document_id + # @return [Monite::ReceivableEntityBase] + attr_reader :entity + # @return [String] Entity bank account ID + attr_reader :entity_bank_account_id + # @return [String] Entity VAT ID id + attr_reader :entity_vat_id_id + # @return [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. +# If omitted or `null`, defaults to the invoice issue date and the value is +# automatically set when the invoice is moved to the `issued` status. + attr_reader :fulfillment_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable + attr_reader :memo + # @return [String] + attr_reader :overdue_reminder_id + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] Link to the invoice's payment page. Either Monite's payment links or your custom +# payment links. + attr_reader :payment_page_url + # @return [String] + attr_reader :payment_reminder_id + # @return [String] + attr_reader :payment_terms_id + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [String] Contain purchase order number. + attr_reader :purchase_order + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [String] The type of the document uploaded. + attr_reader :type + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + attr_reader :vat_mode + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param commercial_condition_description [String] + # @param counterpart_billing_address_id [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_business_type [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + # @param counterpart_id [String] + # @param counterpart_shipping_address_id [String] Address where goods were shipped / where services were provided. + # @param counterpart_vat_id_id [String] Counterpart VAT ID id + # @param currency [Monite::CurrencyEnum] + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param document_id [String] The document number of the receivable, which will appear in the PDF document. +# Can be set manually only in the [non-compliant +# //docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance). +# Otherwise (or if omitted), it will be generated automatically based on the +# entity's [document number +# customization](https://docs.monite.com/advanced/document-number-customization) +# settings when the document is issued. + # @param entity [Monite::ReceivableEntityBase] + # @param entity_bank_account_id [String] Entity bank account ID + # @param entity_vat_id_id [String] Entity VAT ID id + # @param fulfillment_date [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. +# If omitted or `null`, defaults to the invoice issue date and the value is +# automatically set when the invoice is moved to the `issued` status. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable + # @param overdue_reminder_id [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_page_url [String] Link to the invoice's payment page. Either Monite's payment links or your custom +# payment links. + # @param payment_reminder_id [String] + # @param payment_terms_id [String] + # @param project_id [String] A project related to current receivable + # @param purchase_order [String] Contain purchase order number. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param trade_name [String] Trade name of the entity + # @param type [String] The type of the document uploaded. + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableFacadeCreateInvoicePayload] + def initialize(commercial_condition_description: OMIT, counterpart_billing_address_id:, counterpart_business_type: OMIT, counterpart_id:, counterpart_shipping_address_id: OMIT, counterpart_vat_id_id: OMIT, currency:, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, document_id: OMIT, entity: OMIT, entity_bank_account_id: OMIT, entity_vat_id_id: OMIT, fulfillment_date: OMIT, line_items:, memo: OMIT, overdue_reminder_id: OMIT, partner_metadata: OMIT, payment_page_url: OMIT, payment_reminder_id: OMIT, payment_terms_id: OMIT, project_id: OMIT, purchase_order: OMIT, tag_ids: OMIT, trade_name: OMIT, type:, vat_exempt: OMIT, vat_exemption_rationale: OMIT, vat_mode: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @commercial_condition_description = commercial_condition_description if commercial_condition_description != OMIT + @counterpart_billing_address_id = counterpart_billing_address_id + @counterpart_business_type = counterpart_business_type if counterpart_business_type != OMIT + @counterpart_id = counterpart_id + @counterpart_shipping_address_id = counterpart_shipping_address_id if counterpart_shipping_address_id != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @currency = currency + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @document_id = document_id if document_id != OMIT + @entity = entity if entity != OMIT + @entity_bank_account_id = entity_bank_account_id if entity_bank_account_id != OMIT + @entity_vat_id_id = entity_vat_id_id if entity_vat_id_id != OMIT + @fulfillment_date = fulfillment_date if fulfillment_date != OMIT + @line_items = line_items + @memo = memo if memo != OMIT + @overdue_reminder_id = overdue_reminder_id if overdue_reminder_id != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @payment_page_url = payment_page_url if payment_page_url != OMIT + @payment_reminder_id = payment_reminder_id if payment_reminder_id != OMIT + @payment_terms_id = payment_terms_id if payment_terms_id != OMIT + @project_id = project_id if project_id != OMIT + @purchase_order = purchase_order if purchase_order != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @trade_name = trade_name if trade_name != OMIT + @type = type + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @vat_mode = vat_mode if vat_mode != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "commercial_condition_description": commercial_condition_description, "counterpart_billing_address_id": counterpart_billing_address_id, "counterpart_business_type": counterpart_business_type, "counterpart_id": counterpart_id, "counterpart_shipping_address_id": counterpart_shipping_address_id, "counterpart_vat_id_id": counterpart_vat_id_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "document_id": document_id, "entity": entity, "entity_bank_account_id": entity_bank_account_id, "entity_vat_id_id": entity_vat_id_id, "fulfillment_date": fulfillment_date, "line_items": line_items, "memo": memo, "overdue_reminder_id": overdue_reminder_id, "partner_metadata": partner_metadata, "payment_page_url": payment_page_url, "payment_reminder_id": payment_reminder_id, "payment_terms_id": payment_terms_id, "project_id": project_id, "purchase_order": purchase_order, "tag_ids": tag_ids, "trade_name": trade_name, "type": type, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "vat_mode": vat_mode, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableFacadeCreateInvoicePayload + # + # @param json_object [String] + # @return [Monite::ReceivableFacadeCreateInvoicePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + commercial_condition_description = parsed_json["commercial_condition_description"] + counterpart_billing_address_id = parsed_json["counterpart_billing_address_id"] + counterpart_business_type = parsed_json["counterpart_business_type"] + counterpart_id = parsed_json["counterpart_id"] + counterpart_shipping_address_id = parsed_json["counterpart_shipping_address_id"] + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + document_id = parsed_json["document_id"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::ReceivableEntityBase.from_json(json_object: entity) + else + entity = nil + end + entity_bank_account_id = parsed_json["entity_bank_account_id"] + entity_vat_id_id = parsed_json["entity_vat_id_id"] + fulfillment_date = parsed_json["fulfillment_date"] + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::LineItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + overdue_reminder_id = parsed_json["overdue_reminder_id"] + partner_metadata = parsed_json["partner_metadata"] + payment_page_url = parsed_json["payment_page_url"] + payment_reminder_id = parsed_json["payment_reminder_id"] + payment_terms_id = parsed_json["payment_terms_id"] + project_id = parsed_json["project_id"] + purchase_order = parsed_json["purchase_order"] + tag_ids = parsed_json["tag_ids"] + trade_name = parsed_json["trade_name"] + type = parsed_json["type"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + vat_mode = parsed_json["vat_mode"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + commercial_condition_description: commercial_condition_description, + counterpart_billing_address_id: counterpart_billing_address_id, + counterpart_business_type: counterpart_business_type, + counterpart_id: counterpart_id, + counterpart_shipping_address_id: counterpart_shipping_address_id, + counterpart_vat_id_id: counterpart_vat_id_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + document_id: document_id, + entity: entity, + entity_bank_account_id: entity_bank_account_id, + entity_vat_id_id: entity_vat_id_id, + fulfillment_date: fulfillment_date, + line_items: line_items, + memo: memo, + overdue_reminder_id: overdue_reminder_id, + partner_metadata: partner_metadata, + payment_page_url: payment_page_url, + payment_reminder_id: payment_reminder_id, + payment_terms_id: payment_terms_id, + project_id: project_id, + purchase_order: purchase_order, + tag_ids: tag_ids, + trade_name: trade_name, + type: type, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + vat_mode: vat_mode, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableFacadeCreateInvoicePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.commercial_condition_description&.is_a?(String) != false || raise("Passed value for field obj.commercial_condition_description is not the expected type, validation failed.") + obj.counterpart_billing_address_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_billing_address_id is not the expected type, validation failed.") + obj.counterpart_business_type&.is_a?(String) != false || raise("Passed value for field obj.counterpart_business_type is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_shipping_address_id is not the expected type, validation failed.") + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.entity.nil? || Monite::ReceivableEntityBase.validate_raw(obj: obj.entity) + obj.entity_bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.entity_bank_account_id is not the expected type, validation failed.") + obj.entity_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.entity_vat_id_id is not the expected type, validation failed.") + obj.fulfillment_date&.is_a?(String) != false || raise("Passed value for field obj.fulfillment_date is not the expected type, validation failed.") + obj.line_items.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.overdue_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.overdue_reminder_id is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.payment_page_url&.is_a?(String) != false || raise("Passed value for field obj.payment_page_url is not the expected type, validation failed.") + obj.payment_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.payment_reminder_id is not the expected type, validation failed.") + obj.payment_terms_id&.is_a?(String) != false || raise("Passed value for field obj.payment_terms_id is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.purchase_order&.is_a?(String) != false || raise("Passed value for field obj.purchase_order is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.vat_mode&.is_a?(Monite::VatModeEnum) != false || raise("Passed value for field obj.vat_mode is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_facade_create_payload.rb b/lib/monite/types/receivable_facade_create_payload.rb new file mode 100644 index 0000000..517c543 --- /dev/null +++ b/lib/monite/types/receivable_facade_create_payload.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "json" +require_relative "receivable_facade_create_quote_payload" +require_relative "receivable_facade_create_invoice_payload" +require_relative "receivable_create_based_on_payload" + +module Monite + class ReceivableFacadeCreatePayload + + +# Deserialize a JSON object to an instance of ReceivableFacadeCreatePayload + # + # @param json_object [String] + # @return [Monite::ReceivableFacadeCreatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::ReceivableFacadeCreateQuotePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::ReceivableFacadeCreateQuotePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::ReceivableFacadeCreateInvoicePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::ReceivableFacadeCreateInvoicePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::ReceivableCreateBasedOnPayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::ReceivableCreateBasedOnPayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::ReceivableFacadeCreateQuotePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::ReceivableFacadeCreateInvoicePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::ReceivableCreateBasedOnPayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_facade_create_quote_payload.rb b/lib/monite/types/receivable_facade_create_quote_payload.rb new file mode 100644 index 0000000..9b23167 --- /dev/null +++ b/lib/monite/types/receivable_facade_create_quote_payload.rb @@ -0,0 +1,281 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "discount" +require_relative "receivable_entity_base" +require_relative "line_item" +require_relative "vat_mode_enum" +require "ostruct" +require "json" + +module Monite + class ReceivableFacadeCreateQuotePayload + # @return [String] + attr_reader :commercial_condition_description + # @return [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address_id + # @return [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + attr_reader :counterpart_business_type + # @return [String] + attr_reader :counterpart_id + # @return [String] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address_id + # @return [String] Counterpart VAT ID id + attr_reader :counterpart_vat_id_id + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [String] The document number of the receivable, which will appear in the PDF document. +# Can be set manually only in the [non-compliant +# //docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance). +# Otherwise (or if omitted), it will be generated automatically based on the +# entity's [document number +# customization](https://docs.monite.com/advanced/document-number-customization) +# settings when the document is issued. + attr_reader :document_id + # @return [Monite::ReceivableEntityBase] + attr_reader :entity + # @return [String] Entity bank account ID + attr_reader :entity_bank_account_id + # @return [String] Entity VAT ID id + attr_reader :entity_vat_id_id + # @return [String] The date (in ISO 8601 format) until which the quote is valid. + attr_reader :expiry_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable + attr_reader :memo + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [String] Link for custom quote accept page + attr_reader :quote_accept_page_url + # @return [Boolean] Whether acceptance a quote requires a signature. + attr_reader :signature_required + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [String] The type of the document uploaded. + attr_reader :type + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + attr_reader :vat_mode + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param commercial_condition_description [String] + # @param counterpart_billing_address_id [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_business_type [String] Different types of companies for different countries, ex. GmbH, SAS, SNC, etc. + # @param counterpart_id [String] + # @param counterpart_shipping_address_id [String] Address where goods were shipped / where services were provided. + # @param counterpart_vat_id_id [String] Counterpart VAT ID id + # @param currency [Monite::CurrencyEnum] + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param document_id [String] The document number of the receivable, which will appear in the PDF document. +# Can be set manually only in the [non-compliant +# //docs.monite.com/accounts-receivable/regulatory-compliance/invoice-compliance). +# Otherwise (or if omitted), it will be generated automatically based on the +# entity's [document number +# customization](https://docs.monite.com/advanced/document-number-customization) +# settings when the document is issued. + # @param entity [Monite::ReceivableEntityBase] + # @param entity_bank_account_id [String] Entity bank account ID + # @param entity_vat_id_id [String] Entity VAT ID id + # @param expiry_date [String] The date (in ISO 8601 format) until which the quote is valid. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param project_id [String] A project related to current receivable + # @param quote_accept_page_url [String] Link for custom quote accept page + # @param signature_required [Boolean] Whether acceptance a quote requires a signature. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param trade_name [String] Trade name of the entity + # @param type [String] The type of the document uploaded. + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivable will already include VAT or +# not. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableFacadeCreateQuotePayload] + def initialize(commercial_condition_description: OMIT, counterpart_billing_address_id:, counterpart_business_type: OMIT, counterpart_id:, counterpart_shipping_address_id: OMIT, counterpart_vat_id_id: OMIT, currency:, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, document_id: OMIT, entity: OMIT, entity_bank_account_id: OMIT, entity_vat_id_id: OMIT, expiry_date: OMIT, line_items:, memo: OMIT, partner_metadata: OMIT, project_id: OMIT, quote_accept_page_url: OMIT, signature_required: OMIT, tag_ids: OMIT, trade_name: OMIT, type:, vat_exempt: OMIT, vat_exemption_rationale: OMIT, vat_mode: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @commercial_condition_description = commercial_condition_description if commercial_condition_description != OMIT + @counterpart_billing_address_id = counterpart_billing_address_id + @counterpart_business_type = counterpart_business_type if counterpart_business_type != OMIT + @counterpart_id = counterpart_id + @counterpart_shipping_address_id = counterpart_shipping_address_id if counterpart_shipping_address_id != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @currency = currency + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @document_id = document_id if document_id != OMIT + @entity = entity if entity != OMIT + @entity_bank_account_id = entity_bank_account_id if entity_bank_account_id != OMIT + @entity_vat_id_id = entity_vat_id_id if entity_vat_id_id != OMIT + @expiry_date = expiry_date if expiry_date != OMIT + @line_items = line_items + @memo = memo if memo != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @project_id = project_id if project_id != OMIT + @quote_accept_page_url = quote_accept_page_url if quote_accept_page_url != OMIT + @signature_required = signature_required if signature_required != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @trade_name = trade_name if trade_name != OMIT + @type = type + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @vat_mode = vat_mode if vat_mode != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "commercial_condition_description": commercial_condition_description, "counterpart_billing_address_id": counterpart_billing_address_id, "counterpart_business_type": counterpart_business_type, "counterpart_id": counterpart_id, "counterpart_shipping_address_id": counterpart_shipping_address_id, "counterpart_vat_id_id": counterpart_vat_id_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "document_id": document_id, "entity": entity, "entity_bank_account_id": entity_bank_account_id, "entity_vat_id_id": entity_vat_id_id, "expiry_date": expiry_date, "line_items": line_items, "memo": memo, "partner_metadata": partner_metadata, "project_id": project_id, "quote_accept_page_url": quote_accept_page_url, "signature_required": signature_required, "tag_ids": tag_ids, "trade_name": trade_name, "type": type, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "vat_mode": vat_mode, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableFacadeCreateQuotePayload + # + # @param json_object [String] + # @return [Monite::ReceivableFacadeCreateQuotePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + commercial_condition_description = parsed_json["commercial_condition_description"] + counterpart_billing_address_id = parsed_json["counterpart_billing_address_id"] + counterpart_business_type = parsed_json["counterpart_business_type"] + counterpart_id = parsed_json["counterpart_id"] + counterpart_shipping_address_id = parsed_json["counterpart_shipping_address_id"] + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + document_id = parsed_json["document_id"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::ReceivableEntityBase.from_json(json_object: entity) + else + entity = nil + end + entity_bank_account_id = parsed_json["entity_bank_account_id"] + entity_vat_id_id = parsed_json["entity_vat_id_id"] + expiry_date = parsed_json["expiry_date"] + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::LineItem.from_json(json_object: item) +end + memo = parsed_json["memo"] + partner_metadata = parsed_json["partner_metadata"] + project_id = parsed_json["project_id"] + quote_accept_page_url = parsed_json["quote_accept_page_url"] + signature_required = parsed_json["signature_required"] + tag_ids = parsed_json["tag_ids"] + trade_name = parsed_json["trade_name"] + type = parsed_json["type"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + vat_mode = parsed_json["vat_mode"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + commercial_condition_description: commercial_condition_description, + counterpart_billing_address_id: counterpart_billing_address_id, + counterpart_business_type: counterpart_business_type, + counterpart_id: counterpart_id, + counterpart_shipping_address_id: counterpart_shipping_address_id, + counterpart_vat_id_id: counterpart_vat_id_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + document_id: document_id, + entity: entity, + entity_bank_account_id: entity_bank_account_id, + entity_vat_id_id: entity_vat_id_id, + expiry_date: expiry_date, + line_items: line_items, + memo: memo, + partner_metadata: partner_metadata, + project_id: project_id, + quote_accept_page_url: quote_accept_page_url, + signature_required: signature_required, + tag_ids: tag_ids, + trade_name: trade_name, + type: type, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + vat_mode: vat_mode, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableFacadeCreateQuotePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.commercial_condition_description&.is_a?(String) != false || raise("Passed value for field obj.commercial_condition_description is not the expected type, validation failed.") + obj.counterpart_billing_address_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_billing_address_id is not the expected type, validation failed.") + obj.counterpart_business_type&.is_a?(String) != false || raise("Passed value for field obj.counterpart_business_type is not the expected type, validation failed.") + obj.counterpart_id.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_shipping_address_id is not the expected type, validation failed.") + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.document_id&.is_a?(String) != false || raise("Passed value for field obj.document_id is not the expected type, validation failed.") + obj.entity.nil? || Monite::ReceivableEntityBase.validate_raw(obj: obj.entity) + obj.entity_bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.entity_bank_account_id is not the expected type, validation failed.") + obj.entity_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.entity_vat_id_id is not the expected type, validation failed.") + obj.expiry_date&.is_a?(String) != false || raise("Passed value for field obj.expiry_date is not the expected type, validation failed.") + obj.line_items.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.quote_accept_page_url&.is_a?(String) != false || raise("Passed value for field obj.quote_accept_page_url is not the expected type, validation failed.") + obj.signature_required&.is_a?(Boolean) != false || raise("Passed value for field obj.signature_required is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.vat_mode&.is_a?(Monite::VatModeEnum) != false || raise("Passed value for field obj.vat_mode is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_file_url.rb b/lib/monite/types/receivable_file_url.rb new file mode 100644 index 0000000..25218f9 --- /dev/null +++ b/lib/monite/types/receivable_file_url.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivableFileUrl + # @return [String] The receivable's PDF URL in the counterpart's default language. + attr_reader :file_url + # @return [String] The receivable's PDF URL in the entity's default language. + attr_reader :original_file_url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param file_url [String] The receivable's PDF URL in the counterpart's default language. + # @param original_file_url [String] The receivable's PDF URL in the entity's default language. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableFileUrl] + def initialize(file_url: OMIT, original_file_url: OMIT, additional_properties: nil) + @file_url = file_url if file_url != OMIT + @original_file_url = original_file_url if original_file_url != OMIT + @additional_properties = additional_properties + @_field_set = { "file_url": file_url, "original_file_url": original_file_url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableFileUrl + # + # @param json_object [String] + # @return [Monite::ReceivableFileUrl] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + file_url = parsed_json["file_url"] + original_file_url = parsed_json["original_file_url"] + new( + file_url: file_url, + original_file_url: original_file_url, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableFileUrl to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.file_url&.is_a?(String) != false || raise("Passed value for field obj.file_url is not the expected type, validation failed.") + obj.original_file_url&.is_a?(String) != false || raise("Passed value for field obj.original_file_url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_history_cursor_fields.rb b/lib/monite/types/receivable_history_cursor_fields.rb new file mode 100644 index 0000000..766e770 --- /dev/null +++ b/lib/monite/types/receivable_history_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + RECEIVABLE_HISTORY_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/receivable_history_event_type_enum.rb b/lib/monite/types/receivable_history_event_type_enum.rb new file mode 100644 index 0000000..d448429 --- /dev/null +++ b/lib/monite/types/receivable_history_event_type_enum.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Monite + class ReceivableHistoryEventTypeEnum + + STATUS_CHANGED = "status_changed" + RECEIVABLE_CREATED = "receivable_created" + RECEIVABLE_UPDATED = "receivable_updated" + BASED_ON_RECEIVABLE_CREATED = "based_on_receivable_created" + PAYMENT_RECEIVED = "payment_received" + MAIL_SENT = "mail_sent" + PAYMENT_REMINDER_MAIL_SENT = "payment_reminder_mail_sent" + OVERDUE_REMINDER_MAIL_SENT = "overdue_reminder_mail_sent" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_history_pagination_response.rb b/lib/monite/types/receivable_history_pagination_response.rb new file mode 100644 index 0000000..21ced16 --- /dev/null +++ b/lib/monite/types/receivable_history_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "receivable_history_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of change history records. + class ReceivableHistoryPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableHistoryPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableHistoryPaginationResponse + # + # @param json_object [String] + # @return [Monite::ReceivableHistoryPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ReceivableHistoryResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableHistoryPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_history_response.rb b/lib/monite/types/receivable_history_response.rb new file mode 100644 index 0000000..ecc94c5 --- /dev/null +++ b/lib/monite/types/receivable_history_response.rb @@ -0,0 +1,139 @@ +# frozen_string_literal: true +require_relative "receivable_history_response_event_data" +require_relative "receivable_history_event_type_enum" +require "date" +require "ostruct" +require "json" + +module Monite +# Represents an entry in the change history of an accounts receivable document. + class ReceivableHistoryResponse + # @return [String] A unique ID of the history record. + attr_reader :id + # @return [String] A URL of the PDF file that shows the document state after the change. Available +# only for the following event types: `receivable_created`, `receivable_updated`, +# `status_changed`, and `payment_received`. In other event types the +# `current_pdf_url` value is `null`. +# In `payment_received` events, the `current_pdf_url` value is available only in +# case of full payments and only if the entity setting `generate_paid_invoice_pdf` +# is `true`. +# Note that Monite generates PDFs asynchronously. This means that the initial +# value of `current_pdf_url` for the abovementioned events right after they +# occurred is usually `null` and the value gets populated later after the PDF +# document has been generated. + attr_reader :current_pdf_url + # @return [String] ID of the entity user who made the change or trigger the event, or `null` if it +# was done by using a partner access token. + attr_reader :entity_user_id + # @return [Monite::ReceivableHistoryResponseEventData] An object containing additional information about the event or change. The +# object structure varies based on the `event_type`. In `receivable_created` and +# `receivable_updated` events, `event_data` is an empty object `{}`. + attr_reader :event_data + # @return [Monite::ReceivableHistoryEventTypeEnum] The type of the event or change. See [Event +# ypes](https://docs.monite.com/accounts-receivable/document-history#event-types). + attr_reader :event_type + # @return [String] ID of the receivable document that was changed or triggered an event. + attr_reader :receivable_id + # @return [DateTime] UTC date and time when the event or change occurred. + attr_reader :timestamp + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of the history record. + # @param current_pdf_url [String] A URL of the PDF file that shows the document state after the change. Available +# only for the following event types: `receivable_created`, `receivable_updated`, +# `status_changed`, and `payment_received`. In other event types the +# `current_pdf_url` value is `null`. +# In `payment_received` events, the `current_pdf_url` value is available only in +# case of full payments and only if the entity setting `generate_paid_invoice_pdf` +# is `true`. +# Note that Monite generates PDFs asynchronously. This means that the initial +# value of `current_pdf_url` for the abovementioned events right after they +# occurred is usually `null` and the value gets populated later after the PDF +# document has been generated. + # @param entity_user_id [String] ID of the entity user who made the change or trigger the event, or `null` if it +# was done by using a partner access token. + # @param event_data [Monite::ReceivableHistoryResponseEventData] An object containing additional information about the event or change. The +# object structure varies based on the `event_type`. In `receivable_created` and +# `receivable_updated` events, `event_data` is an empty object `{}`. + # @param event_type [Monite::ReceivableHistoryEventTypeEnum] The type of the event or change. See [Event +# ypes](https://docs.monite.com/accounts-receivable/document-history#event-types). + # @param receivable_id [String] ID of the receivable document that was changed or triggered an event. + # @param timestamp [DateTime] UTC date and time when the event or change occurred. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableHistoryResponse] + def initialize(id:, current_pdf_url: OMIT, entity_user_id: OMIT, event_data:, event_type:, receivable_id:, timestamp:, additional_properties: nil) + @id = id + @current_pdf_url = current_pdf_url if current_pdf_url != OMIT + @entity_user_id = entity_user_id if entity_user_id != OMIT + @event_data = event_data + @event_type = event_type + @receivable_id = receivable_id + @timestamp = timestamp + @additional_properties = additional_properties + @_field_set = { "id": id, "current_pdf_url": current_pdf_url, "entity_user_id": entity_user_id, "event_data": event_data, "event_type": event_type, "receivable_id": receivable_id, "timestamp": timestamp }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableHistoryResponse + # + # @param json_object [String] + # @return [Monite::ReceivableHistoryResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + current_pdf_url = parsed_json["current_pdf_url"] + entity_user_id = parsed_json["entity_user_id"] + unless parsed_json["event_data"].nil? + event_data = parsed_json["event_data"].to_json + event_data = Monite::ReceivableHistoryResponseEventData.from_json(json_object: event_data) + else + event_data = nil + end + event_type = parsed_json["event_type"] + receivable_id = parsed_json["receivable_id"] + timestamp = unless parsed_json["timestamp"].nil? + DateTime.parse(parsed_json["timestamp"]) +else + nil +end + new( + id: id, + current_pdf_url: current_pdf_url, + entity_user_id: entity_user_id, + event_data: event_data, + event_type: event_type, + receivable_id: receivable_id, + timestamp: timestamp, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableHistoryResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.current_pdf_url&.is_a?(String) != false || raise("Passed value for field obj.current_pdf_url is not the expected type, validation failed.") + obj.entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.entity_user_id is not the expected type, validation failed.") + Monite::ReceivableHistoryResponseEventData.validate_raw(obj: obj.event_data) + obj.event_type.is_a?(Monite::ReceivableHistoryEventTypeEnum) != false || raise("Passed value for field obj.event_type is not the expected type, validation failed.") + obj.receivable_id.is_a?(String) != false || raise("Passed value for field obj.receivable_id is not the expected type, validation failed.") + obj.timestamp.is_a?(DateTime) != false || raise("Passed value for field obj.timestamp is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_history_response_event_data.rb b/lib/monite/types/receivable_history_response_event_data.rb new file mode 100644 index 0000000..ccefa73 --- /dev/null +++ b/lib/monite/types/receivable_history_response_event_data.rb @@ -0,0 +1,141 @@ +# frozen_string_literal: true +require "json" +require_relative "status_changed_event_data" +require_relative "receivable_updated_event_data" +require_relative "receivable_created_event_data" +require_relative "based_on_receivable_created_event_data" +require_relative "payment_received_event_data" +require_relative "mail_sent_event_data" +require_relative "reminder_mail_sent_event_data" + +module Monite +# An object containing additional information about the event or change. The +# object structure varies based on the `event_type`. In `receivable_created` and +# `receivable_updated` events, `event_data` is an empty object `{}`. + class ReceivableHistoryResponseEventData + + +# Deserialize a JSON object to an instance of ReceivableHistoryResponseEventData + # + # @param json_object [String] + # @return [Monite::ReceivableHistoryResponseEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::StatusChangedEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::StatusChangedEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::ReceivableUpdatedEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::ReceivableUpdatedEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::ReceivableCreatedEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::ReceivableCreatedEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::BasedOnReceivableCreatedEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::BasedOnReceivableCreatedEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::PaymentReceivedEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::PaymentReceivedEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::MailSentEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::MailSentEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::ReminderMailSentEventData.validate_raw(obj: struct) + unless struct.nil? + return Monite::ReminderMailSentEventData.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::StatusChangedEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::ReceivableUpdatedEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::ReceivableCreatedEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::BasedOnReceivableCreatedEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::PaymentReceivedEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::MailSentEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::ReminderMailSentEventData.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_mail_cursor_fields.rb b/lib/monite/types/receivable_mail_cursor_fields.rb new file mode 100644 index 0000000..c008cbb --- /dev/null +++ b/lib/monite/types/receivable_mail_cursor_fields.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class ReceivableMailCursorFields + + STATUS = "status" + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_mail_pagination_response.rb b/lib/monite/types/receivable_mail_pagination_response.rb new file mode 100644 index 0000000..876e01b --- /dev/null +++ b/lib/monite/types/receivable_mail_pagination_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "receivable_mail_response" +require "ostruct" +require "json" + +module Monite + class ReceivableMailPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableMailPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableMailPaginationResponse + # + # @param json_object [String] + # @return [Monite::ReceivableMailPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ReceivableMailResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableMailPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_mail_recipient_state.rb b/lib/monite/types/receivable_mail_recipient_state.rb new file mode 100644 index 0000000..9199b3b --- /dev/null +++ b/lib/monite/types/receivable_mail_recipient_state.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivableMailRecipientState + # @return [String] An email address of the recipient. + attr_reader :email + # @return [String] An error message in case the mailing was unsuccessful. + attr_reader :error + # @return [Boolean] Whether mail was sent successfully. + attr_reader :is_success + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] An email address of the recipient. + # @param error [String] An error message in case the mailing was unsuccessful. + # @param is_success [Boolean] Whether mail was sent successfully. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableMailRecipientState] + def initialize(email:, error: OMIT, is_success:, additional_properties: nil) + @email = email + @error = error if error != OMIT + @is_success = is_success + @additional_properties = additional_properties + @_field_set = { "email": email, "error": error, "is_success": is_success }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableMailRecipientState + # + # @param json_object [String] + # @return [Monite::ReceivableMailRecipientState] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + error = parsed_json["error"] + is_success = parsed_json["is_success"] + new( + email: email, + error: error, + is_success: is_success, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableMailRecipientState to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.error&.is_a?(String) != false || raise("Passed value for field obj.error is not the expected type, validation failed.") + obj.is_success.is_a?(Boolean) != false || raise("Passed value for field obj.is_success is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_mail_recipients.rb b/lib/monite/types/receivable_mail_recipients.rb new file mode 100644 index 0000000..e133a02 --- /dev/null +++ b/lib/monite/types/receivable_mail_recipients.rb @@ -0,0 +1,80 @@ +# frozen_string_literal: true +require_relative "receivable_mail_recipient_state" +require "ostruct" +require "json" + +module Monite + class ReceivableMailRecipients + # @return [Array] + attr_reader :bcc + # @return [Array] + attr_reader :cc + # @return [Array] + attr_reader :to + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param bcc [Array] + # @param cc [Array] + # @param to [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableMailRecipients] + def initialize(bcc: OMIT, cc: OMIT, to: OMIT, additional_properties: nil) + @bcc = bcc if bcc != OMIT + @cc = cc if cc != OMIT + @to = to if to != OMIT + @additional_properties = additional_properties + @_field_set = { "bcc": bcc, "cc": cc, "to": to }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableMailRecipients + # + # @param json_object [String] + # @return [Monite::ReceivableMailRecipients] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + bcc = parsed_json["bcc"]&.map do | item | + item = item.to_json + Monite::ReceivableMailRecipientState.from_json(json_object: item) +end + cc = parsed_json["cc"]&.map do | item | + item = item.to_json + Monite::ReceivableMailRecipientState.from_json(json_object: item) +end + to = parsed_json["to"]&.map do | item | + item = item.to_json + Monite::ReceivableMailRecipientState.from_json(json_object: item) +end + new( + bcc: bcc, + cc: cc, + to: to, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableMailRecipients to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.bcc&.is_a?(Array) != false || raise("Passed value for field obj.bcc is not the expected type, validation failed.") + obj.cc&.is_a?(Array) != false || raise("Passed value for field obj.cc is not the expected type, validation failed.") + obj.to&.is_a?(Array) != false || raise("Passed value for field obj.to is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_mail_response.rb b/lib/monite/types/receivable_mail_response.rb new file mode 100644 index 0000000..0bc5e02 --- /dev/null +++ b/lib/monite/types/receivable_mail_response.rb @@ -0,0 +1,101 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "receivable_mail_recipients" +require_relative "receivable_mail_status_enum" +require "ostruct" +require "json" + +module Monite + class ReceivableMailResponse + # @return [String] + attr_reader :id + # @return [DateTime] The time the mail task was created + attr_reader :created_at + # @return [DateTime] The time the mail task was updated + attr_reader :updated_at + # @return [Monite::ReceivableMailRecipients] + attr_reader :recipients + # @return [Monite::ReceivableMailStatusEnum] The status of the mail sent by receivable + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] The time the mail task was created + # @param updated_at [DateTime] The time the mail task was updated + # @param recipients [Monite::ReceivableMailRecipients] + # @param status [Monite::ReceivableMailStatusEnum] The status of the mail sent by receivable + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableMailResponse] + def initialize(id:, created_at:, updated_at:, recipients: OMIT, status:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @recipients = recipients if recipients != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "recipients": recipients, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableMailResponse + # + # @param json_object [String] + # @return [Monite::ReceivableMailResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + unless parsed_json["recipients"].nil? + recipients = parsed_json["recipients"].to_json + recipients = Monite::ReceivableMailRecipients.from_json(json_object: recipients) + else + recipients = nil + end + status = parsed_json["status"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + recipients: recipients, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableMailResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.recipients.nil? || Monite::ReceivableMailRecipients.validate_raw(obj: obj.recipients) + obj.status.is_a?(Monite::ReceivableMailStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_mail_status_enum.rb b/lib/monite/types/receivable_mail_status_enum.rb new file mode 100644 index 0000000..2bdd595 --- /dev/null +++ b/lib/monite/types/receivable_mail_status_enum.rb @@ -0,0 +1,13 @@ +# frozen_string_literal: true + +module Monite + class ReceivableMailStatusEnum + + PENDING = "pending" + PROCESSING = "processing" + SENT = "sent" + PARTIALLY_SENT = "partially_sent" + FAILED = "failed" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_pagination_response.rb b/lib/monite/types/receivable_pagination_response.rb new file mode 100644 index 0000000..7c78e26 --- /dev/null +++ b/lib/monite/types/receivable_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "receivable_response" +require "ostruct" +require "json" + +module Monite +# A paginated list of receivables + class ReceivablePaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablePaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivablePaginationResponse + # + # @param json_object [String] + # @return [Monite::ReceivablePaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ReceivableResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of ReceivablePaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_preview_response.rb b/lib/monite/types/receivable_preview_response.rb new file mode 100644 index 0000000..56eec11 --- /dev/null +++ b/lib/monite/types/receivable_preview_response.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema for receiving a request for previewing an email with a receivable +# document + class ReceivablePreviewResponse + # @return [String] + attr_reader :body_preview + # @return [String] + attr_reader :subject_preview + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param body_preview [String] + # @param subject_preview [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablePreviewResponse] + def initialize(body_preview:, subject_preview:, additional_properties: nil) + @body_preview = body_preview + @subject_preview = subject_preview + @additional_properties = additional_properties + @_field_set = { "body_preview": body_preview, "subject_preview": subject_preview } + end +# Deserialize a JSON object to an instance of ReceivablePreviewResponse + # + # @param json_object [String] + # @return [Monite::ReceivablePreviewResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + body_preview = parsed_json["body_preview"] + subject_preview = parsed_json["subject_preview"] + new( + body_preview: body_preview, + subject_preview: subject_preview, + additional_properties: struct + ) + end +# Serialize an instance of ReceivablePreviewResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body_preview.is_a?(String) != false || raise("Passed value for field obj.body_preview is not the expected type, validation failed.") + obj.subject_preview.is_a?(String) != false || raise("Passed value for field obj.subject_preview is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_response.rb b/lib/monite/types/receivable_response.rb new file mode 100644 index 0000000..72614eb --- /dev/null +++ b/lib/monite/types/receivable_response.rb @@ -0,0 +1,99 @@ +# frozen_string_literal: true +require "json" +require_relative "quote_response_payload" +require_relative "invoice_response_payload" +require_relative "credit_note_response_payload" + +module Monite + class ReceivableResponse + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::ReceivableResponse] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of ReceivableResponse + # + # @param json_object [String] + # @return [Monite::ReceivableResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "quote" + member = Monite::QuoteResponsePayload.from_json(json_object: json_object) + when "invoice" + member = Monite::InvoiceResponsePayload.from_json(json_object: json_object) + when "credit_note" + member = Monite::CreditNoteResponsePayload.from_json(json_object: json_object) + else + member = Monite::QuoteResponsePayload.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "quote" + { **@member.to_json, type: @discriminant }.to_json + when "invoice" + { **@member.to_json, type: @discriminant }.to_json + when "credit_note" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "quote" + Monite::QuoteResponsePayload.validate_raw(obj: obj) + when "invoice" + Monite::InvoiceResponsePayload.validate_raw(obj: obj) + when "credit_note" + Monite::CreditNoteResponsePayload.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::QuoteResponsePayload] + # @return [Monite::ReceivableResponse] + def self.quote(member:) + new(member: member, discriminant: "quote") + end + # @param member [Monite::InvoiceResponsePayload] + # @return [Monite::ReceivableResponse] + def self.invoice(member:) + new(member: member, discriminant: "invoice") + end + # @param member [Monite::CreditNoteResponsePayload] + # @return [Monite::ReceivableResponse] + def self.credit_note(member:) + new(member: member, discriminant: "credit_note") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_send_response.rb b/lib/monite/types/receivable_send_response.rb new file mode 100644 index 0000000..5fe777d --- /dev/null +++ b/lib/monite/types/receivable_send_response.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema for returning a response an email with a link to receivable document +# has been sent + class ReceivableSendResponse + # @return [String] + attr_reader :mail_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param mail_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableSendResponse] + def initialize(mail_id:, additional_properties: nil) + @mail_id = mail_id + @additional_properties = additional_properties + @_field_set = { "mail_id": mail_id } + end +# Deserialize a JSON object to an instance of ReceivableSendResponse + # + # @param json_object [String] + # @return [Monite::ReceivableSendResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + mail_id = parsed_json["mail_id"] + new(mail_id: mail_id, additional_properties: struct) + end +# Serialize an instance of ReceivableSendResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mail_id.is_a?(String) != false || raise("Passed value for field obj.mail_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_settings.rb b/lib/monite/types/receivable_settings.rb new file mode 100644 index 0000000..8712564 --- /dev/null +++ b/lib/monite/types/receivable_settings.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivableSettings + # @return [Boolean] + attr_reader :create_without_personal_info + # @return [String] + attr_reader :deduction_title + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param create_without_personal_info [Boolean] + # @param deduction_title [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableSettings] + def initialize(create_without_personal_info:, deduction_title: OMIT, additional_properties: nil) + @create_without_personal_info = create_without_personal_info + @deduction_title = deduction_title if deduction_title != OMIT + @additional_properties = additional_properties + @_field_set = { "create_without_personal_info": create_without_personal_info, "deduction_title": deduction_title }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivableSettings + # + # @param json_object [String] + # @return [Monite::ReceivableSettings] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + create_without_personal_info = parsed_json["create_without_personal_info"] + deduction_title = parsed_json["deduction_title"] + new( + create_without_personal_info: create_without_personal_info, + deduction_title: deduction_title, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableSettings to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.create_without_personal_info.is_a?(Boolean) != false || raise("Passed value for field obj.create_without_personal_info is not the expected type, validation failed.") + obj.deduction_title&.is_a?(String) != false || raise("Passed value for field obj.deduction_title is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_templates_variable.rb b/lib/monite/types/receivable_templates_variable.rb new file mode 100644 index 0000000..de0abac --- /dev/null +++ b/lib/monite/types/receivable_templates_variable.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivableTemplatesVariable + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableTemplatesVariable] + def initialize(description:, name:, additional_properties: nil) + @description = description + @name = name + @additional_properties = additional_properties + @_field_set = { "description": description, "name": name } + end +# Deserialize a JSON object to an instance of ReceivableTemplatesVariable + # + # @param json_object [String] + # @return [Monite::ReceivableTemplatesVariable] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + name = parsed_json["name"] + new( + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableTemplatesVariable to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_templates_variables_object.rb b/lib/monite/types/receivable_templates_variables_object.rb new file mode 100644 index 0000000..0ea6da1 --- /dev/null +++ b/lib/monite/types/receivable_templates_variables_object.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true +require_relative "variables_type" +require_relative "receivable_templates_variable" +require "ostruct" +require "json" + +module Monite + class ReceivableTemplatesVariablesObject + # @return [Monite::VariablesType] + attr_reader :object_subtype + # @return [String] + attr_reader :object_type + # @return [Array] + attr_reader :variables + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object_subtype [Monite::VariablesType] + # @param object_type [String] + # @param variables [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableTemplatesVariablesObject] + def initialize(object_subtype:, object_type:, variables:, additional_properties: nil) + @object_subtype = object_subtype + @object_type = object_type + @variables = variables + @additional_properties = additional_properties + @_field_set = { "object_subtype": object_subtype, "object_type": object_type, "variables": variables } + end +# Deserialize a JSON object to an instance of ReceivableTemplatesVariablesObject + # + # @param json_object [String] + # @return [Monite::ReceivableTemplatesVariablesObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + object_subtype = parsed_json["object_subtype"] + object_type = parsed_json["object_type"] + variables = parsed_json["variables"]&.map do | item | + item = item.to_json + Monite::ReceivableTemplatesVariable.from_json(json_object: item) +end + new( + object_subtype: object_subtype, + object_type: object_type, + variables: variables, + additional_properties: struct + ) + end +# Serialize an instance of ReceivableTemplatesVariablesObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.object_subtype.is_a?(Monite::VariablesType) != false || raise("Passed value for field obj.object_subtype is not the expected type, validation failed.") + obj.object_type.is_a?(String) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.variables.is_a?(Array) != false || raise("Passed value for field obj.variables is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_templates_variables_object_list.rb b/lib/monite/types/receivable_templates_variables_object_list.rb new file mode 100644 index 0000000..87c5adb --- /dev/null +++ b/lib/monite/types/receivable_templates_variables_object_list.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true +require_relative "receivable_templates_variables_object" +require "ostruct" +require "json" + +module Monite + class ReceivableTemplatesVariablesObjectList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableTemplatesVariablesObjectList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of +# ReceivableTemplatesVariablesObjectList + # + # @param json_object [String] + # @return [Monite::ReceivableTemplatesVariablesObjectList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::ReceivableTemplatesVariablesObject.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of ReceivableTemplatesVariablesObjectList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_type.rb b/lib/monite/types/receivable_type.rb new file mode 100644 index 0000000..b69c8df --- /dev/null +++ b/lib/monite/types/receivable_type.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class ReceivableType + + QUOTE = "quote" + INVOICE = "invoice" + CREDIT_NOTE = "credit_note" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_update_payload.rb b/lib/monite/types/receivable_update_payload.rb new file mode 100644 index 0000000..df9ffb8 --- /dev/null +++ b/lib/monite/types/receivable_update_payload.rb @@ -0,0 +1,90 @@ +# frozen_string_literal: true +require "json" +require_relative "update_quote_payload" +require_relative "update_invoice_payload" +require_relative "update_credit_note_payload" +require_relative "update_issued_invoice_payload" + +module Monite + class ReceivableUpdatePayload + + +# Deserialize a JSON object to an instance of ReceivableUpdatePayload + # + # @param json_object [String] + # @return [Monite::ReceivableUpdatePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + Monite::UpdateQuotePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::UpdateQuotePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::UpdateInvoicePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::UpdateInvoicePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::UpdateCreditNotePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::UpdateCreditNotePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + begin + Monite::UpdateIssuedInvoicePayload.validate_raw(obj: struct) + unless struct.nil? + return Monite::UpdateIssuedInvoicePayload.from_json(json_object: struct) +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return Monite::UpdateQuotePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::UpdateInvoicePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::UpdateCreditNotePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + begin + return Monite::UpdateIssuedInvoicePayload.validate_raw(obj: obj) + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivable_updated_event_data.rb b/lib/monite/types/receivable_updated_event_data.rb new file mode 100644 index 0000000..d51f386 --- /dev/null +++ b/lib/monite/types/receivable_updated_event_data.rb @@ -0,0 +1,44 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivableUpdatedEventData + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivableUpdatedEventData] + def initialize(additional_properties: nil) + @additional_properties = additional_properties + @_field_set = { } + end +# Deserialize a JSON object to an instance of ReceivableUpdatedEventData + # + # @param json_object [String] + # @return [Monite::ReceivableUpdatedEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + new(additional_properties: struct) + end +# Serialize an instance of ReceivableUpdatedEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_preview_type_enum.rb b/lib/monite/types/receivables_preview_type_enum.rb new file mode 100644 index 0000000..4d621ff --- /dev/null +++ b/lib/monite/types/receivables_preview_type_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class ReceivablesPreviewTypeEnum + + RECEIVABLE = "receivable" + DISCOUNT_REMINDER = "discount_reminder" + FINAL_REMINDER = "final_reminder" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_reminders_warning_message.rb b/lib/monite/types/receivables_reminders_warning_message.rb new file mode 100644 index 0000000..34425ad --- /dev/null +++ b/lib/monite/types/receivables_reminders_warning_message.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivablesRemindersWarningMessage + # @return [String] Warning message for payment reminder + attr_reader :payment_reminders + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param payment_reminders [String] Warning message for payment reminder + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablesRemindersWarningMessage] + def initialize(payment_reminders: OMIT, additional_properties: nil) + @payment_reminders = payment_reminders if payment_reminders != OMIT + @additional_properties = additional_properties + @_field_set = { "payment_reminders": payment_reminders }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivablesRemindersWarningMessage + # + # @param json_object [String] + # @return [Monite::ReceivablesRemindersWarningMessage] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + payment_reminders = parsed_json["payment_reminders"] + new(payment_reminders: payment_reminders, additional_properties: struct) + end +# Serialize an instance of ReceivablesRemindersWarningMessage to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.payment_reminders&.is_a?(String) != false || raise("Passed value for field obj.payment_reminders is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_representation_of_counterpart_address.rb b/lib/monite/types/receivables_representation_of_counterpart_address.rb new file mode 100644 index 0000000..a25619a --- /dev/null +++ b/lib/monite/types/receivables_representation_of_counterpart_address.rb @@ -0,0 +1,103 @@ +# frozen_string_literal: true +require_relative "allowed_countries" +require "ostruct" +require "json" + +module Monite + class ReceivablesRepresentationOfCounterpartAddress + # @return [String] Unique ID of the address in the system + attr_reader :id + # @return [String] City name. + attr_reader :city + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [String] Street address. + attr_reader :line_1 + # @return [String] Additional address information (if any). + attr_reader :line_2 + # @return [String] ZIP or postal code. + attr_reader :postal_code + # @return [String] State, region, province, or county. + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the address in the system + # @param city [String] City name. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param line_1 [String] Street address. + # @param line_2 [String] Additional address information (if any). + # @param postal_code [String] ZIP or postal code. + # @param state [String] State, region, province, or county. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] + def initialize(id: OMIT, city:, country:, line_1:, line_2: OMIT, postal_code:, state: OMIT, additional_properties: nil) + @id = id if id != OMIT + @city = city + @country = country + @line_1 = line_1 + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "city": city, "country": country, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# ReceivablesRepresentationOfCounterpartAddress + # + # @param json_object [String] + # @return [Monite::ReceivablesRepresentationOfCounterpartAddress] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + city = parsed_json["city"] + country = parsed_json["country"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + id: id, + city: city, + country: country, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of ReceivablesRepresentationOfCounterpartAddress to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.city.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.line_1.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_representation_of_entity_bank_account.rb b/lib/monite/types/receivables_representation_of_entity_bank_account.rb new file mode 100644 index 0000000..af386b5 --- /dev/null +++ b/lib/monite/types/receivables_representation_of_entity_bank_account.rb @@ -0,0 +1,107 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class ReceivablesRepresentationOfEntityBankAccount + # @return [String] Unique ID of the entity bank account. + attr_reader :id + # @return [String] Account holder's name + attr_reader :account_holder_name + # @return [String] Account number (required if IBAN is not provided) + attr_reader :account_number + # @return [String] The name of the entity's bank account. + attr_reader :bank_name + # @return [String] The BIC of the entity's bank account. + attr_reader :bic + # @return [String] The IBAN of the entity's bank account. + attr_reader :iban + # @return [String] Routing number (US) + attr_reader :routing_number + # @return [String] Sort code (GB) + attr_reader :sort_code + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique ID of the entity bank account. + # @param account_holder_name [String] Account holder's name + # @param account_number [String] Account number (required if IBAN is not provided) + # @param bank_name [String] The name of the entity's bank account. + # @param bic [String] The BIC of the entity's bank account. + # @param iban [String] The IBAN of the entity's bank account. + # @param routing_number [String] Routing number (US) + # @param sort_code [String] Sort code (GB) + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablesRepresentationOfEntityBankAccount] + def initialize(id: OMIT, account_holder_name: OMIT, account_number: OMIT, bank_name: OMIT, bic: OMIT, iban: OMIT, routing_number: OMIT, sort_code: OMIT, additional_properties: nil) + @id = id if id != OMIT + @account_holder_name = account_holder_name if account_holder_name != OMIT + @account_number = account_number if account_number != OMIT + @bank_name = bank_name if bank_name != OMIT + @bic = bic if bic != OMIT + @iban = iban if iban != OMIT + @routing_number = routing_number if routing_number != OMIT + @sort_code = sort_code if sort_code != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "account_holder_name": account_holder_name, "account_number": account_number, "bank_name": bank_name, "bic": bic, "iban": iban, "routing_number": routing_number, "sort_code": sort_code }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# ReceivablesRepresentationOfEntityBankAccount + # + # @param json_object [String] + # @return [Monite::ReceivablesRepresentationOfEntityBankAccount] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + account_holder_name = parsed_json["account_holder_name"] + account_number = parsed_json["account_number"] + bank_name = parsed_json["bank_name"] + bic = parsed_json["bic"] + iban = parsed_json["iban"] + routing_number = parsed_json["routing_number"] + sort_code = parsed_json["sort_code"] + new( + id: id, + account_holder_name: account_holder_name, + account_number: account_number, + bank_name: bank_name, + bic: bic, + iban: iban, + routing_number: routing_number, + sort_code: sort_code, + additional_properties: struct + ) + end +# Serialize an instance of ReceivablesRepresentationOfEntityBankAccount to a JSON +# object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.account_holder_name&.is_a?(String) != false || raise("Passed value for field obj.account_holder_name is not the expected type, validation failed.") + obj.account_number&.is_a?(String) != false || raise("Passed value for field obj.account_number is not the expected type, validation failed.") + obj.bank_name&.is_a?(String) != false || raise("Passed value for field obj.bank_name is not the expected type, validation failed.") + obj.bic&.is_a?(String) != false || raise("Passed value for field obj.bic is not the expected type, validation failed.") + obj.iban&.is_a?(String) != false || raise("Passed value for field obj.iban is not the expected type, validation failed.") + obj.routing_number&.is_a?(String) != false || raise("Passed value for field obj.routing_number is not the expected type, validation failed.") + obj.sort_code&.is_a?(String) != false || raise("Passed value for field obj.sort_code is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_send_response.rb b/lib/monite/types/receivables_send_response.rb new file mode 100644 index 0000000..92064c2 --- /dev/null +++ b/lib/monite/types/receivables_send_response.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# A schema for returning a response with list of ids by which user check sending +# status + class ReceivablesSendResponse + # @return [Array] + attr_reader :mail_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param mail_ids [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablesSendResponse] + def initialize(mail_ids:, additional_properties: nil) + @mail_ids = mail_ids + @additional_properties = additional_properties + @_field_set = { "mail_ids": mail_ids } + end +# Deserialize a JSON object to an instance of ReceivablesSendResponse + # + # @param json_object [String] + # @return [Monite::ReceivablesSendResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + mail_ids = parsed_json["mail_ids"] + new(mail_ids: mail_ids, additional_properties: struct) + end +# Serialize an instance of ReceivablesSendResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mail_ids.is_a?(Array) != false || raise("Passed value for field obj.mail_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_status_enum.rb b/lib/monite/types/receivables_status_enum.rb new file mode 100644 index 0000000..a217711 --- /dev/null +++ b/lib/monite/types/receivables_status_enum.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module Monite + class ReceivablesStatusEnum + + DRAFT = "draft" + ISSUED = "issued" + ACCEPTED = "accepted" + EXPIRED = "expired" + DECLINED = "declined" + RECURRING = "recurring" + PARTIALLY_PAID = "partially_paid" + PAID = "paid" + OVERDUE = "overdue" + UNCOLLECTIBLE = "uncollectible" + CANCELED = "canceled" + DELETED = "deleted" + + end +end \ No newline at end of file diff --git a/lib/monite/types/receivables_verify_response.rb b/lib/monite/types/receivables_verify_response.rb new file mode 100644 index 0000000..919e501 --- /dev/null +++ b/lib/monite/types/receivables_verify_response.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require_relative "missing_fields" +require_relative "receivables_reminders_warning_message" +require "ostruct" +require "json" + +module Monite +# A schema for returning a response with validation results + class ReceivablesVerifyResponse + # @return [Monite::MissingFields] Missing fields of receivable + attr_reader :errors + # @return [Monite::ReceivablesRemindersWarningMessage] Warning message for payment reminder + attr_reader :warnings + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param errors [Monite::MissingFields] Missing fields of receivable + # @param warnings [Monite::ReceivablesRemindersWarningMessage] Warning message for payment reminder + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReceivablesVerifyResponse] + def initialize(errors: OMIT, warnings: OMIT, additional_properties: nil) + @errors = errors if errors != OMIT + @warnings = warnings if warnings != OMIT + @additional_properties = additional_properties + @_field_set = { "errors": errors, "warnings": warnings }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ReceivablesVerifyResponse + # + # @param json_object [String] + # @return [Monite::ReceivablesVerifyResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["errors"].nil? + errors = parsed_json["errors"].to_json + errors = Monite::MissingFields.from_json(json_object: errors) + else + errors = nil + end + unless parsed_json["warnings"].nil? + warnings = parsed_json["warnings"].to_json + warnings = Monite::ReceivablesRemindersWarningMessage.from_json(json_object: warnings) + else + warnings = nil + end + new( + errors: errors, + warnings: warnings, + additional_properties: struct + ) + end +# Serialize an instance of ReceivablesVerifyResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.errors.nil? || Monite::MissingFields.validate_raw(obj: obj.errors) + obj.warnings.nil? || Monite::ReceivablesRemindersWarningMessage.validate_raw(obj: obj.warnings) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/recipient.rb b/lib/monite/types/recipient.rb new file mode 100644 index 0000000..f2af226 --- /dev/null +++ b/lib/monite/types/recipient.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "recipient_type" +require "ostruct" +require "json" + +module Monite + class Recipient + # @return [String] + attr_reader :id + # @return [Monite::RecipientType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param type [Monite::RecipientType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Recipient] + def initialize(id:, type:, additional_properties: nil) + @id = id + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "type": type } + end +# Deserialize a JSON object to an instance of Recipient + # + # @param json_object [String] + # @return [Monite::Recipient] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + type = parsed_json["type"] + new( + id: id, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of Recipient to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.type.is_a?(Monite::RecipientType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/recipient_account_response.rb b/lib/monite/types/recipient_account_response.rb new file mode 100644 index 0000000..1821687 --- /dev/null +++ b/lib/monite/types/recipient_account_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "bank_account" +require_relative "payment_account_type" +require "ostruct" +require "json" + +module Monite + class RecipientAccountResponse + # @return [String] ID of a payment account + attr_reader :id + # @return [Array] List of bank accounts + attr_reader :bank_accounts + # @return [String] Display name of a payment account + attr_reader :name + # @return [Monite::PaymentAccountType] Type of a payment account. Can be `entity` or `counterpart` + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] ID of a payment account + # @param bank_accounts [Array] List of bank accounts + # @param name [String] Display name of a payment account + # @param type [Monite::PaymentAccountType] Type of a payment account. Can be `entity` or `counterpart` + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RecipientAccountResponse] + def initialize(id:, bank_accounts: OMIT, name: OMIT, type:, additional_properties: nil) + @id = id + @bank_accounts = bank_accounts if bank_accounts != OMIT + @name = name if name != OMIT + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "bank_accounts": bank_accounts, "name": name, "type": type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of RecipientAccountResponse + # + # @param json_object [String] + # @return [Monite::RecipientAccountResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + bank_accounts = parsed_json["bank_accounts"]&.map do | item | + item = item.to_json + Monite::BankAccount.from_json(json_object: item) +end + name = parsed_json["name"] + type = parsed_json["type"] + new( + id: id, + bank_accounts: bank_accounts, + name: name, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of RecipientAccountResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.bank_accounts&.is_a?(Array) != false || raise("Passed value for field obj.bank_accounts is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.type.is_a?(Monite::PaymentAccountType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/recipient_type.rb b/lib/monite/types/recipient_type.rb new file mode 100644 index 0000000..0c1334a --- /dev/null +++ b/lib/monite/types/recipient_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class RecipientType + + ENTITY = "entity" + COUNTERPART = "counterpart" + + end +end \ No newline at end of file diff --git a/lib/monite/types/recipients.rb b/lib/monite/types/recipients.rb new file mode 100644 index 0000000..91b0584 --- /dev/null +++ b/lib/monite/types/recipients.rb @@ -0,0 +1,70 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class Recipients + # @return [Array] + attr_reader :bcc + # @return [Array] + attr_reader :cc + # @return [Array] + attr_reader :to + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param bcc [Array] + # @param cc [Array] + # @param to [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Recipients] + def initialize(bcc: OMIT, cc: OMIT, to: OMIT, additional_properties: nil) + @bcc = bcc if bcc != OMIT + @cc = cc if cc != OMIT + @to = to if to != OMIT + @additional_properties = additional_properties + @_field_set = { "bcc": bcc, "cc": cc, "to": to }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of Recipients + # + # @param json_object [String] + # @return [Monite::Recipients] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + bcc = parsed_json["bcc"] + cc = parsed_json["cc"] + to = parsed_json["to"] + new( + bcc: bcc, + cc: cc, + to: to, + additional_properties: struct + ) + end +# Serialize an instance of Recipients to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.bcc&.is_a?(Array) != false || raise("Passed value for field obj.bcc is not the expected type, validation failed.") + obj.cc&.is_a?(Array) != false || raise("Passed value for field obj.cc is not the expected type, validation failed.") + obj.to&.is_a?(Array) != false || raise("Passed value for field obj.to is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/recurrence.rb b/lib/monite/types/recurrence.rb new file mode 100644 index 0000000..d3e7b3e --- /dev/null +++ b/lib/monite/types/recurrence.rb @@ -0,0 +1,180 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "day_of_month" +require_relative "recurrence_iteration" +require_relative "recipients" +require_relative "recurrence_status" +require "ostruct" +require "json" + +module Monite + class Recurrence + # @return [String] + attr_reader :id + # @return [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + attr_reader :created_at + # @return [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + attr_reader :updated_at + # @return [String] + attr_reader :body_text + # @return [Integer] + attr_reader :current_iteration + # @return [Monite::DayOfMonth] + attr_reader :day_of_month + # @return [Integer] + attr_reader :end_month + # @return [Integer] + attr_reader :end_year + # @return [String] + attr_reader :invoice_id + # @return [Array] + attr_reader :iterations + # @return [Monite::Recipients] + attr_reader :recipients + # @return [Integer] + attr_reader :start_month + # @return [Integer] + attr_reader :start_year + # @return [Monite::RecurrenceStatus] + attr_reader :status + # @return [String] + attr_reader :subject_text + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] Time at which the receivable was created. Timestamps follow the ISO 8601 +# standard. + # @param updated_at [DateTime] Time at which the receivable was last updated. Timestamps follow the ISO 8601 +# standard. + # @param body_text [String] + # @param current_iteration [Integer] + # @param day_of_month [Monite::DayOfMonth] + # @param end_month [Integer] + # @param end_year [Integer] + # @param invoice_id [String] + # @param iterations [Array] + # @param recipients [Monite::Recipients] + # @param start_month [Integer] + # @param start_year [Integer] + # @param status [Monite::RecurrenceStatus] + # @param subject_text [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Recurrence] + def initialize(id:, created_at:, updated_at:, body_text: OMIT, current_iteration:, day_of_month:, end_month:, end_year:, invoice_id:, iterations:, recipients: OMIT, start_month:, start_year:, status:, subject_text: OMIT, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @body_text = body_text if body_text != OMIT + @current_iteration = current_iteration + @day_of_month = day_of_month + @end_month = end_month + @end_year = end_year + @invoice_id = invoice_id + @iterations = iterations + @recipients = recipients if recipients != OMIT + @start_month = start_month + @start_year = start_year + @status = status + @subject_text = subject_text if subject_text != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "body_text": body_text, "current_iteration": current_iteration, "day_of_month": day_of_month, "end_month": end_month, "end_year": end_year, "invoice_id": invoice_id, "iterations": iterations, "recipients": recipients, "start_month": start_month, "start_year": start_year, "status": status, "subject_text": subject_text }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of Recurrence + # + # @param json_object [String] + # @return [Monite::Recurrence] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + body_text = parsed_json["body_text"] + current_iteration = parsed_json["current_iteration"] + day_of_month = parsed_json["day_of_month"] + end_month = parsed_json["end_month"] + end_year = parsed_json["end_year"] + invoice_id = parsed_json["invoice_id"] + iterations = parsed_json["iterations"]&.map do | item | + item = item.to_json + Monite::RecurrenceIteration.from_json(json_object: item) +end + unless parsed_json["recipients"].nil? + recipients = parsed_json["recipients"].to_json + recipients = Monite::Recipients.from_json(json_object: recipients) + else + recipients = nil + end + start_month = parsed_json["start_month"] + start_year = parsed_json["start_year"] + status = parsed_json["status"] + subject_text = parsed_json["subject_text"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + body_text: body_text, + current_iteration: current_iteration, + day_of_month: day_of_month, + end_month: end_month, + end_year: end_year, + invoice_id: invoice_id, + iterations: iterations, + recipients: recipients, + start_month: start_month, + start_year: start_year, + status: status, + subject_text: subject_text, + additional_properties: struct + ) + end +# Serialize an instance of Recurrence to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.body_text&.is_a?(String) != false || raise("Passed value for field obj.body_text is not the expected type, validation failed.") + obj.current_iteration.is_a?(Integer) != false || raise("Passed value for field obj.current_iteration is not the expected type, validation failed.") + obj.day_of_month.is_a?(Monite::DayOfMonth) != false || raise("Passed value for field obj.day_of_month is not the expected type, validation failed.") + obj.end_month.is_a?(Integer) != false || raise("Passed value for field obj.end_month is not the expected type, validation failed.") + obj.end_year.is_a?(Integer) != false || raise("Passed value for field obj.end_year is not the expected type, validation failed.") + obj.invoice_id.is_a?(String) != false || raise("Passed value for field obj.invoice_id is not the expected type, validation failed.") + obj.iterations.is_a?(Array) != false || raise("Passed value for field obj.iterations is not the expected type, validation failed.") + obj.recipients.nil? || Monite::Recipients.validate_raw(obj: obj.recipients) + obj.start_month.is_a?(Integer) != false || raise("Passed value for field obj.start_month is not the expected type, validation failed.") + obj.start_year.is_a?(Integer) != false || raise("Passed value for field obj.start_year is not the expected type, validation failed.") + obj.status.is_a?(Monite::RecurrenceStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.subject_text&.is_a?(String) != false || raise("Passed value for field obj.subject_text is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/recurrence_iteration.rb b/lib/monite/types/recurrence_iteration.rb new file mode 100644 index 0000000..d4d16e7 --- /dev/null +++ b/lib/monite/types/recurrence_iteration.rb @@ -0,0 +1,78 @@ +# frozen_string_literal: true +require_relative "iteration_status" +require "ostruct" +require "json" + +module Monite + class RecurrenceIteration + # @return [String] + attr_reader :issue_at + # @return [String] + attr_reader :issued_invoice_id + # @return [Integer] + attr_reader :iteration + # @return [Monite::IterationStatus] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param issue_at [String] + # @param issued_invoice_id [String] + # @param iteration [Integer] + # @param status [Monite::IterationStatus] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RecurrenceIteration] + def initialize(issue_at:, issued_invoice_id: OMIT, iteration: OMIT, status:, additional_properties: nil) + @issue_at = issue_at + @issued_invoice_id = issued_invoice_id if issued_invoice_id != OMIT + @iteration = iteration if iteration != OMIT + @status = status + @additional_properties = additional_properties + @_field_set = { "issue_at": issue_at, "issued_invoice_id": issued_invoice_id, "iteration": iteration, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of RecurrenceIteration + # + # @param json_object [String] + # @return [Monite::RecurrenceIteration] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + issue_at = parsed_json["issue_at"] + issued_invoice_id = parsed_json["issued_invoice_id"] + iteration = parsed_json["iteration"] + status = parsed_json["status"] + new( + issue_at: issue_at, + issued_invoice_id: issued_invoice_id, + iteration: iteration, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of RecurrenceIteration to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.issue_at.is_a?(String) != false || raise("Passed value for field obj.issue_at is not the expected type, validation failed.") + obj.issued_invoice_id&.is_a?(String) != false || raise("Passed value for field obj.issued_invoice_id is not the expected type, validation failed.") + obj.iteration&.is_a?(Integer) != false || raise("Passed value for field obj.iteration is not the expected type, validation failed.") + obj.status.is_a?(Monite::IterationStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/recurrence_status.rb b/lib/monite/types/recurrence_status.rb new file mode 100644 index 0000000..b495211 --- /dev/null +++ b/lib/monite/types/recurrence_status.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class RecurrenceStatus + + ACTIVE = "active" + CANCELED = "canceled" + COMPLETED = "completed" + + end +end \ No newline at end of file diff --git a/lib/monite/types/related_documents.rb b/lib/monite/types/related_documents.rb new file mode 100644 index 0000000..4c66297 --- /dev/null +++ b/lib/monite/types/related_documents.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class RelatedDocuments + # @return [Array] + attr_reader :credit_note_ids + # @return [String] + attr_reader :proforma_invoice_id + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param credit_note_ids [Array] + # @param proforma_invoice_id [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RelatedDocuments] + def initialize(credit_note_ids: OMIT, proforma_invoice_id: OMIT, additional_properties: nil) + @credit_note_ids = credit_note_ids if credit_note_ids != OMIT + @proforma_invoice_id = proforma_invoice_id if proforma_invoice_id != OMIT + @additional_properties = additional_properties + @_field_set = { "credit_note_ids": credit_note_ids, "proforma_invoice_id": proforma_invoice_id }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of RelatedDocuments + # + # @param json_object [String] + # @return [Monite::RelatedDocuments] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + credit_note_ids = parsed_json["credit_note_ids"] + proforma_invoice_id = parsed_json["proforma_invoice_id"] + new( + credit_note_ids: credit_note_ids, + proforma_invoice_id: proforma_invoice_id, + additional_properties: struct + ) + end +# Serialize an instance of RelatedDocuments to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.credit_note_ids&.is_a?(Array) != false || raise("Passed value for field obj.credit_note_ids is not the expected type, validation failed.") + obj.proforma_invoice_id&.is_a?(String) != false || raise("Passed value for field obj.proforma_invoice_id is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/reminder.rb b/lib/monite/types/reminder.rb new file mode 100644 index 0000000..71073dd --- /dev/null +++ b/lib/monite/types/reminder.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class Reminder + # @return [String] + attr_reader :body + # @return [Integer] + attr_reader :days_before + # @return [String] + attr_reader :subject + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param body [String] + # @param days_before [Integer] + # @param subject [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Reminder] + def initialize(body:, days_before:, subject:, additional_properties: nil) + @body = body + @days_before = days_before + @subject = subject + @additional_properties = additional_properties + @_field_set = { "body": body, "days_before": days_before, "subject": subject } + end +# Deserialize a JSON object to an instance of Reminder + # + # @param json_object [String] + # @return [Monite::Reminder] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + body = parsed_json["body"] + days_before = parsed_json["days_before"] + subject = parsed_json["subject"] + new( + body: body, + days_before: days_before, + subject: subject, + additional_properties: struct + ) + end +# Serialize an instance of Reminder to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body.is_a?(String) != false || raise("Passed value for field obj.body is not the expected type, validation failed.") + obj.days_before.is_a?(Integer) != false || raise("Passed value for field obj.days_before is not the expected type, validation failed.") + obj.subject.is_a?(String) != false || raise("Passed value for field obj.subject is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/reminder_mail_sent_event_data.rb b/lib/monite/types/reminder_mail_sent_event_data.rb new file mode 100644 index 0000000..2951a08 --- /dev/null +++ b/lib/monite/types/reminder_mail_sent_event_data.rb @@ -0,0 +1,104 @@ +# frozen_string_literal: true +require_relative "receivable_mail_status_enum" +require_relative "receivable_mail_recipients" +require_relative "reminder_type_enum" +require "ostruct" +require "json" + +module Monite +# Contains information about an invoice reminder sent via email. + class ReminderMailSentEventData + # @return [String] ID of the email sending operation. Can be used to get the email sending status +# from `GET /receivables/{receivable_id}/mails/{mail_id}`. + attr_reader :mail_id + # @return [Monite::ReceivableMailStatusEnum] The overall email sending status across all recipients. + attr_reader :mail_status + # @return [Monite::ReceivableMailRecipients] Contains a list of email recipients (To, CC, BCC) and the email sending status +# for each recipient. + attr_reader :recipients + # @return [Monite::ReminderTypeEnum] Invoice reminder type: +# * `term_1` - [payment +# eminder](https://docs.monite.com/accounts-receivable/invoices/payment-reminders) +# sent before discount date 1, +# * `term_2` - payment reminder sent before discount date 2, +# * `term_final` - payment reminder sent before the invoice due date. +# * `overdue` - [overdue +# eminder](https://docs.monite.com/accounts-receivable/invoices/overdue-reminders) +# sent after the due date. + attr_reader :term + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param mail_id [String] ID of the email sending operation. Can be used to get the email sending status +# from `GET /receivables/{receivable_id}/mails/{mail_id}`. + # @param mail_status [Monite::ReceivableMailStatusEnum] The overall email sending status across all recipients. + # @param recipients [Monite::ReceivableMailRecipients] Contains a list of email recipients (To, CC, BCC) and the email sending status +# for each recipient. + # @param term [Monite::ReminderTypeEnum] Invoice reminder type: +# * `term_1` - [payment +# eminder](https://docs.monite.com/accounts-receivable/invoices/payment-reminders) +# sent before discount date 1, +# * `term_2` - payment reminder sent before discount date 2, +# * `term_final` - payment reminder sent before the invoice due date. +# * `overdue` - [overdue +# eminder](https://docs.monite.com/accounts-receivable/invoices/overdue-reminders) +# sent after the due date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ReminderMailSentEventData] + def initialize(mail_id:, mail_status:, recipients:, term:, additional_properties: nil) + @mail_id = mail_id + @mail_status = mail_status + @recipients = recipients + @term = term + @additional_properties = additional_properties + @_field_set = { "mail_id": mail_id, "mail_status": mail_status, "recipients": recipients, "term": term } + end +# Deserialize a JSON object to an instance of ReminderMailSentEventData + # + # @param json_object [String] + # @return [Monite::ReminderMailSentEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + mail_id = parsed_json["mail_id"] + mail_status = parsed_json["mail_status"] + unless parsed_json["recipients"].nil? + recipients = parsed_json["recipients"].to_json + recipients = Monite::ReceivableMailRecipients.from_json(json_object: recipients) + else + recipients = nil + end + term = parsed_json["term"] + new( + mail_id: mail_id, + mail_status: mail_status, + recipients: recipients, + term: term, + additional_properties: struct + ) + end +# Serialize an instance of ReminderMailSentEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.mail_id.is_a?(String) != false || raise("Passed value for field obj.mail_id is not the expected type, validation failed.") + obj.mail_status.is_a?(Monite::ReceivableMailStatusEnum) != false || raise("Passed value for field obj.mail_status is not the expected type, validation failed.") + Monite::ReceivableMailRecipients.validate_raw(obj: obj.recipients) + obj.term.is_a?(Monite::ReminderTypeEnum) != false || raise("Passed value for field obj.term is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/reminder_type_enum.rb b/lib/monite/types/reminder_type_enum.rb new file mode 100644 index 0000000..b7078bf --- /dev/null +++ b/lib/monite/types/reminder_type_enum.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +module Monite + class ReminderTypeEnum + + TERM_1 = "term_1" + TERM_2 = "term_2" + TERM_FINAL = "term_final" + OVERDUE = "overdue" + + end +end \ No newline at end of file diff --git a/lib/monite/types/reminders_settings.rb b/lib/monite/types/reminders_settings.rb new file mode 100644 index 0000000..2ecd0f9 --- /dev/null +++ b/lib/monite/types/reminders_settings.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class RemindersSettings + # @return [Boolean] + attr_reader :enabled + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param enabled [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RemindersSettings] + def initialize(enabled: OMIT, additional_properties: nil) + @enabled = enabled if enabled != OMIT + @additional_properties = additional_properties + @_field_set = { "enabled": enabled }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of RemindersSettings + # + # @param json_object [String] + # @return [Monite::RemindersSettings] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + enabled = parsed_json["enabled"] + new(enabled: enabled, additional_properties: struct) + end +# Serialize an instance of RemindersSettings to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.enabled&.is_a?(Boolean) != false || raise("Passed value for field obj.enabled is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/repayment_schedule.rb b/lib/monite/types/repayment_schedule.rb new file mode 100644 index 0000000..c7ece1a --- /dev/null +++ b/lib/monite/types/repayment_schedule.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Repayment schedule model + class RepaymentSchedule + # @return [String] Repayment date in ISO 8601 format + attr_reader :repayment_date + # @return [Integer] Repayment amount in minor units + attr_reader :repayment_amount + # @return [Integer] Repayment fee amount in minor units + attr_reader :repayment_fee_amount + # @return [Integer] Repayment principal amount in minor units + attr_reader :repayment_principal_amount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param repayment_date [String] Repayment date in ISO 8601 format + # @param repayment_amount [Integer] Repayment amount in minor units + # @param repayment_fee_amount [Integer] Repayment fee amount in minor units + # @param repayment_principal_amount [Integer] Repayment principal amount in minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RepaymentSchedule] + def initialize(repayment_date:, repayment_amount:, repayment_fee_amount:, repayment_principal_amount:, additional_properties: nil) + @repayment_date = repayment_date + @repayment_amount = repayment_amount + @repayment_fee_amount = repayment_fee_amount + @repayment_principal_amount = repayment_principal_amount + @additional_properties = additional_properties + @_field_set = { "repayment_date": repayment_date, "repayment_amount": repayment_amount, "repayment_fee_amount": repayment_fee_amount, "repayment_principal_amount": repayment_principal_amount } + end +# Deserialize a JSON object to an instance of RepaymentSchedule + # + # @param json_object [String] + # @return [Monite::RepaymentSchedule] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + repayment_date = parsed_json["repayment_date"] + repayment_amount = parsed_json["repayment_amount"] + repayment_fee_amount = parsed_json["repayment_fee_amount"] + repayment_principal_amount = parsed_json["repayment_principal_amount"] + new( + repayment_date: repayment_date, + repayment_amount: repayment_amount, + repayment_fee_amount: repayment_fee_amount, + repayment_principal_amount: repayment_principal_amount, + additional_properties: struct + ) + end +# Serialize an instance of RepaymentSchedule to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.repayment_date.is_a?(String) != false || raise("Passed value for field obj.repayment_date is not the expected type, validation failed.") + obj.repayment_amount.is_a?(Integer) != false || raise("Passed value for field obj.repayment_amount is not the expected type, validation failed.") + obj.repayment_fee_amount.is_a?(Integer) != false || raise("Passed value for field obj.repayment_fee_amount is not the expected type, validation failed.") + obj.repayment_principal_amount.is_a?(Integer) != false || raise("Passed value for field obj.repayment_principal_amount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/requirements_error.rb b/lib/monite/types/requirements_error.rb new file mode 100644 index 0000000..5c43867 --- /dev/null +++ b/lib/monite/types/requirements_error.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class RequirementsError + # @return [String] + attr_reader :code + # @return [String] + attr_reader :reason + # @return [String] + attr_reader :requirement + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param code [String] + # @param reason [String] + # @param requirement [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RequirementsError] + def initialize(code:, reason:, requirement:, additional_properties: nil) + @code = code + @reason = reason + @requirement = requirement + @additional_properties = additional_properties + @_field_set = { "code": code, "reason": reason, "requirement": requirement } + end +# Deserialize a JSON object to an instance of RequirementsError + # + # @param json_object [String] + # @return [Monite::RequirementsError] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + code = parsed_json["code"] + reason = parsed_json["reason"] + requirement = parsed_json["requirement"] + new( + code: code, + reason: reason, + requirement: requirement, + additional_properties: struct + ) + end +# Serialize an instance of RequirementsError to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.code.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") + obj.reason.is_a?(String) != false || raise("Passed value for field obj.reason is not the expected type, validation failed.") + obj.requirement.is_a?(String) != false || raise("Passed value for field obj.requirement is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/response_item.rb b/lib/monite/types/response_item.rb new file mode 100644 index 0000000..02f25e9 --- /dev/null +++ b/lib/monite/types/response_item.rb @@ -0,0 +1,93 @@ +# frozen_string_literal: true +require_relative "discount" +require_relative "line_item_product" +require "ostruct" +require "json" + +module Monite + class ResponseItem + # @return [Monite::Discount] The discount for a product. + attr_reader :discount + # @return [Monite::LineItemProduct] + attr_reader :product + # @return [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + attr_reader :quantity + # @return [Integer] Total of line_item before VAT in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :total_before_vat + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param discount [Monite::Discount] The discount for a product. + # @param product [Monite::LineItemProduct] + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + # @param total_before_vat [Integer] Total of line_item before VAT in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ResponseItem] + def initialize(discount: OMIT, product:, quantity:, total_before_vat:, additional_properties: nil) + @discount = discount if discount != OMIT + @product = product + @quantity = quantity + @total_before_vat = total_before_vat + @additional_properties = additional_properties + @_field_set = { "discount": discount, "product": product, "quantity": quantity, "total_before_vat": total_before_vat }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of ResponseItem + # + # @param json_object [String] + # @return [Monite::ResponseItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + unless parsed_json["product"].nil? + product = parsed_json["product"].to_json + product = Monite::LineItemProduct.from_json(json_object: product) + else + product = nil + end + quantity = parsed_json["quantity"] + total_before_vat = parsed_json["total_before_vat"] + new( + discount: discount, + product: product, + quantity: quantity, + total_before_vat: total_before_vat, + additional_properties: struct + ) + end +# Serialize an instance of ResponseItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + Monite::LineItemProduct.validate_raw(obj: obj.product) + obj.quantity.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + obj.total_before_vat.is_a?(Integer) != false || raise("Passed value for field obj.total_before_vat is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/role_cursor_fields.rb b/lib/monite/types/role_cursor_fields.rb new file mode 100644 index 0000000..d9bd554 --- /dev/null +++ b/lib/monite/types/role_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class RoleCursorFields + + UPDATED_AT = "updated_at" + CREATED_AT = "created_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/role_pagination_response.rb b/lib/monite/types/role_pagination_response.rb new file mode 100644 index 0000000..1ed3043 --- /dev/null +++ b/lib/monite/types/role_pagination_response.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "role_response" +require "ostruct" +require "json" + +module Monite + class RolePaginationResponse + # @return [Array] array of records + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] array of records + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RolePaginationResponse] + def initialize(data:, prev_pagination_token: OMIT, next_pagination_token: OMIT, additional_properties: nil) + @data = data + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "prev_pagination_token": prev_pagination_token, "next_pagination_token": next_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of RolePaginationResponse + # + # @param json_object [String] + # @return [Monite::RolePaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::RoleResponse.from_json(json_object: item) +end + prev_pagination_token = parsed_json["prev_pagination_token"] + next_pagination_token = parsed_json["next_pagination_token"] + new( + data: data, + prev_pagination_token: prev_pagination_token, + next_pagination_token: next_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of RolePaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/role_response.rb b/lib/monite/types/role_response.rb new file mode 100644 index 0000000..cc7b363 --- /dev/null +++ b/lib/monite/types/role_response.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true +require_relative "biz_objects_schema_output" +require_relative "status_enum" +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class RoleResponse + # @return [String] UUID role ID + attr_reader :id + # @return [String] Role name + attr_reader :name + # @return [Monite::BizObjectsSchemaOutput] Access permissions + attr_reader :permissions + # @return [Monite::StatusEnum] record status, 'active' by default + attr_reader :status + # @return [DateTime] UTC datetime + attr_reader :created_at + # @return [DateTime] UTC datetime + attr_reader :updated_at + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] UUID role ID + # @param name [String] Role name + # @param permissions [Monite::BizObjectsSchemaOutput] Access permissions + # @param status [Monite::StatusEnum] record status, 'active' by default + # @param created_at [DateTime] UTC datetime + # @param updated_at [DateTime] UTC datetime + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::RoleResponse] + def initialize(id:, name:, permissions:, status:, created_at:, updated_at:, additional_properties: nil) + @id = id + @name = name + @permissions = permissions + @status = status + @created_at = created_at + @updated_at = updated_at + @additional_properties = additional_properties + @_field_set = { "id": id, "name": name, "permissions": permissions, "status": status, "created_at": created_at, "updated_at": updated_at } + end +# Deserialize a JSON object to an instance of RoleResponse + # + # @param json_object [String] + # @return [Monite::RoleResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + name = parsed_json["name"] + unless parsed_json["permissions"].nil? + permissions = parsed_json["permissions"].to_json + permissions = Monite::BizObjectsSchemaOutput.from_json(json_object: permissions) + else + permissions = nil + end + status = parsed_json["status"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + new( + id: id, + name: name, + permissions: permissions, + status: status, + created_at: created_at, + updated_at: updated_at, + additional_properties: struct + ) + end +# Serialize an instance of RoleResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + Monite::BizObjectsSchemaOutput.validate_raw(obj: obj.permissions) + obj.status.is_a?(Monite::StatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/root_schema_input.rb b/lib/monite/types/root_schema_input.rb new file mode 100644 index 0000000..913ed97 --- /dev/null +++ b/lib/monite/types/root_schema_input.rb @@ -0,0 +1,373 @@ +# frozen_string_literal: true +require "json" +require_relative "common_schema_input" +require_relative "payable_schema_input" + +module Monite + class RootSchemaInput + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::RootSchemaInput] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of RootSchemaInput + # + # @param json_object [String] + # @return [Monite::RootSchemaInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.object_type + when "approval_policy" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "approval_request" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "comment" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "counterpart" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "counterpart_vat_id" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "entity" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "entity_bank_account" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "entity_user" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "entity_vat_ids" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "export" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "mailbox" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "onboarding" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "overdue_reminder" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "payable" + member = Monite::PayableSchemaInput.from_json(json_object: json_object) + when "payables_purchase_order" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "payment_record" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "payment_reminder" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "person" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "product" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "project" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "receivable" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "reconciliation" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "role" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "tag" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "todo_task" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "todo_task_mute" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "transaction" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + when "workflow" + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + else + member = Monite::CommonSchemaInput.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.object_type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "approval_policy" + { **@member.to_json, object_type: @discriminant }.to_json + when "approval_request" + { **@member.to_json, object_type: @discriminant }.to_json + when "comment" + { **@member.to_json, object_type: @discriminant }.to_json + when "counterpart" + { **@member.to_json, object_type: @discriminant }.to_json + when "counterpart_vat_id" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity_bank_account" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity_user" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity_vat_ids" + { **@member.to_json, object_type: @discriminant }.to_json + when "export" + { **@member.to_json, object_type: @discriminant }.to_json + when "mailbox" + { **@member.to_json, object_type: @discriminant }.to_json + when "onboarding" + { **@member.to_json, object_type: @discriminant }.to_json + when "overdue_reminder" + { **@member.to_json, object_type: @discriminant }.to_json + when "payable" + { **@member.to_json, object_type: @discriminant }.to_json + when "payables_purchase_order" + { **@member.to_json, object_type: @discriminant }.to_json + when "payment_record" + { **@member.to_json, object_type: @discriminant }.to_json + when "payment_reminder" + { **@member.to_json, object_type: @discriminant }.to_json + when "person" + { **@member.to_json, object_type: @discriminant }.to_json + when "product" + { **@member.to_json, object_type: @discriminant }.to_json + when "project" + { **@member.to_json, object_type: @discriminant }.to_json + when "receivable" + { **@member.to_json, object_type: @discriminant }.to_json + when "reconciliation" + { **@member.to_json, object_type: @discriminant }.to_json + when "role" + { **@member.to_json, object_type: @discriminant }.to_json + when "tag" + { **@member.to_json, object_type: @discriminant }.to_json + when "todo_task" + { **@member.to_json, object_type: @discriminant }.to_json + when "todo_task_mute" + { **@member.to_json, object_type: @discriminant }.to_json + when "transaction" + { **@member.to_json, object_type: @discriminant }.to_json + when "workflow" + { **@member.to_json, object_type: @discriminant }.to_json + else + { "object_type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.object_type + when "approval_policy" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "approval_request" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "comment" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "counterpart" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "counterpart_vat_id" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "entity" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "entity_bank_account" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "entity_user" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "entity_vat_ids" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "export" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "mailbox" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "onboarding" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "overdue_reminder" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "payable" + Monite::PayableSchemaInput.validate_raw(obj: obj) + when "payables_purchase_order" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "payment_record" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "payment_reminder" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "person" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "product" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "project" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "receivable" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "reconciliation" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "role" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "tag" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "todo_task" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "todo_task_mute" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "transaction" + Monite::CommonSchemaInput.validate_raw(obj: obj) + when "workflow" + Monite::CommonSchemaInput.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.approval_policy(member:) + new(member: member, discriminant: "approval_policy") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.approval_request(member:) + new(member: member, discriminant: "approval_request") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.comment(member:) + new(member: member, discriminant: "comment") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.counterpart(member:) + new(member: member, discriminant: "counterpart") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.counterpart_vat_id(member:) + new(member: member, discriminant: "counterpart_vat_id") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.entity(member:) + new(member: member, discriminant: "entity") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.entity_bank_account(member:) + new(member: member, discriminant: "entity_bank_account") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.entity_user(member:) + new(member: member, discriminant: "entity_user") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.entity_vat_ids(member:) + new(member: member, discriminant: "entity_vat_ids") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.export(member:) + new(member: member, discriminant: "export") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.mailbox(member:) + new(member: member, discriminant: "mailbox") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.onboarding(member:) + new(member: member, discriminant: "onboarding") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.overdue_reminder(member:) + new(member: member, discriminant: "overdue_reminder") + end + # @param member [Monite::PayableSchemaInput] + # @return [Monite::RootSchemaInput] + def self.payable(member:) + new(member: member, discriminant: "payable") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.payables_purchase_order(member:) + new(member: member, discriminant: "payables_purchase_order") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.payment_record(member:) + new(member: member, discriminant: "payment_record") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.payment_reminder(member:) + new(member: member, discriminant: "payment_reminder") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.person(member:) + new(member: member, discriminant: "person") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.product(member:) + new(member: member, discriminant: "product") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.project(member:) + new(member: member, discriminant: "project") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.receivable(member:) + new(member: member, discriminant: "receivable") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.reconciliation(member:) + new(member: member, discriminant: "reconciliation") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.role(member:) + new(member: member, discriminant: "role") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.tag(member:) + new(member: member, discriminant: "tag") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.todo_task(member:) + new(member: member, discriminant: "todo_task") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.todo_task_mute(member:) + new(member: member, discriminant: "todo_task_mute") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.transaction(member:) + new(member: member, discriminant: "transaction") + end + # @param member [Monite::CommonSchemaInput] + # @return [Monite::RootSchemaInput] + def self.workflow(member:) + new(member: member, discriminant: "workflow") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/root_schema_output.rb b/lib/monite/types/root_schema_output.rb new file mode 100644 index 0000000..d07915f --- /dev/null +++ b/lib/monite/types/root_schema_output.rb @@ -0,0 +1,373 @@ +# frozen_string_literal: true +require "json" +require_relative "common_schema_output" +require_relative "payable_schema_output" + +module Monite + class RootSchemaOutput + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::RootSchemaOutput] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of RootSchemaOutput + # + # @param json_object [String] + # @return [Monite::RootSchemaOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.object_type + when "approval_policy" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "approval_request" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "comment" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "counterpart" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "counterpart_vat_id" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "entity" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "entity_bank_account" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "entity_user" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "entity_vat_ids" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "export" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "mailbox" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "onboarding" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "overdue_reminder" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "payable" + member = Monite::PayableSchemaOutput.from_json(json_object: json_object) + when "payables_purchase_order" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "payment_record" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "payment_reminder" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "person" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "product" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "project" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "receivable" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "reconciliation" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "role" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "tag" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "todo_task" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "todo_task_mute" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "transaction" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + when "workflow" + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + else + member = Monite::CommonSchemaOutput.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.object_type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "approval_policy" + { **@member.to_json, object_type: @discriminant }.to_json + when "approval_request" + { **@member.to_json, object_type: @discriminant }.to_json + when "comment" + { **@member.to_json, object_type: @discriminant }.to_json + when "counterpart" + { **@member.to_json, object_type: @discriminant }.to_json + when "counterpart_vat_id" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity_bank_account" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity_user" + { **@member.to_json, object_type: @discriminant }.to_json + when "entity_vat_ids" + { **@member.to_json, object_type: @discriminant }.to_json + when "export" + { **@member.to_json, object_type: @discriminant }.to_json + when "mailbox" + { **@member.to_json, object_type: @discriminant }.to_json + when "onboarding" + { **@member.to_json, object_type: @discriminant }.to_json + when "overdue_reminder" + { **@member.to_json, object_type: @discriminant }.to_json + when "payable" + { **@member.to_json, object_type: @discriminant }.to_json + when "payables_purchase_order" + { **@member.to_json, object_type: @discriminant }.to_json + when "payment_record" + { **@member.to_json, object_type: @discriminant }.to_json + when "payment_reminder" + { **@member.to_json, object_type: @discriminant }.to_json + when "person" + { **@member.to_json, object_type: @discriminant }.to_json + when "product" + { **@member.to_json, object_type: @discriminant }.to_json + when "project" + { **@member.to_json, object_type: @discriminant }.to_json + when "receivable" + { **@member.to_json, object_type: @discriminant }.to_json + when "reconciliation" + { **@member.to_json, object_type: @discriminant }.to_json + when "role" + { **@member.to_json, object_type: @discriminant }.to_json + when "tag" + { **@member.to_json, object_type: @discriminant }.to_json + when "todo_task" + { **@member.to_json, object_type: @discriminant }.to_json + when "todo_task_mute" + { **@member.to_json, object_type: @discriminant }.to_json + when "transaction" + { **@member.to_json, object_type: @discriminant }.to_json + when "workflow" + { **@member.to_json, object_type: @discriminant }.to_json + else + { "object_type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.object_type + when "approval_policy" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "approval_request" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "comment" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "counterpart" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "counterpart_vat_id" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "entity" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "entity_bank_account" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "entity_user" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "entity_vat_ids" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "export" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "mailbox" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "onboarding" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "overdue_reminder" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "payable" + Monite::PayableSchemaOutput.validate_raw(obj: obj) + when "payables_purchase_order" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "payment_record" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "payment_reminder" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "person" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "product" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "project" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "receivable" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "reconciliation" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "role" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "tag" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "todo_task" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "todo_task_mute" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "transaction" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + when "workflow" + Monite::CommonSchemaOutput.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.approval_policy(member:) + new(member: member, discriminant: "approval_policy") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.approval_request(member:) + new(member: member, discriminant: "approval_request") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.comment(member:) + new(member: member, discriminant: "comment") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.counterpart(member:) + new(member: member, discriminant: "counterpart") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.counterpart_vat_id(member:) + new(member: member, discriminant: "counterpart_vat_id") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.entity(member:) + new(member: member, discriminant: "entity") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.entity_bank_account(member:) + new(member: member, discriminant: "entity_bank_account") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.entity_user(member:) + new(member: member, discriminant: "entity_user") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.entity_vat_ids(member:) + new(member: member, discriminant: "entity_vat_ids") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.export(member:) + new(member: member, discriminant: "export") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.mailbox(member:) + new(member: member, discriminant: "mailbox") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.onboarding(member:) + new(member: member, discriminant: "onboarding") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.overdue_reminder(member:) + new(member: member, discriminant: "overdue_reminder") + end + # @param member [Monite::PayableSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.payable(member:) + new(member: member, discriminant: "payable") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.payables_purchase_order(member:) + new(member: member, discriminant: "payables_purchase_order") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.payment_record(member:) + new(member: member, discriminant: "payment_record") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.payment_reminder(member:) + new(member: member, discriminant: "payment_reminder") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.person(member:) + new(member: member, discriminant: "person") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.product(member:) + new(member: member, discriminant: "product") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.project(member:) + new(member: member, discriminant: "project") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.receivable(member:) + new(member: member, discriminant: "receivable") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.reconciliation(member:) + new(member: member, discriminant: "reconciliation") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.role(member:) + new(member: member, discriminant: "role") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.tag(member:) + new(member: member, discriminant: "tag") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.todo_task(member:) + new(member: member, discriminant: "todo_task") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.todo_task_mute(member:) + new(member: member, discriminant: "todo_task_mute") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.transaction(member:) + new(member: member, discriminant: "transaction") + end + # @param member [Monite::CommonSchemaOutput] + # @return [Monite::RootSchemaOutput] + def self.workflow(member:) + new(member: member, discriminant: "workflow") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/service_providers_enum.rb b/lib/monite/types/service_providers_enum.rb new file mode 100644 index 0000000..3048595 --- /dev/null +++ b/lib/monite/types/service_providers_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class ServiceProvidersEnum + + CODAT = "codat" + RAILZ = "railz" + + end +end \ No newline at end of file diff --git a/lib/monite/types/settings_response.rb b/lib/monite/types/settings_response.rb new file mode 100644 index 0000000..d8583e8 --- /dev/null +++ b/lib/monite/types/settings_response.rb @@ -0,0 +1,171 @@ +# frozen_string_literal: true +require_relative "language_code_enum" +require_relative "currency_settings_output" +require_relative "reminders_settings" +require_relative "vat_mode_enum" +require_relative "payment_priority_enum" +require_relative "receivable_edit_flow" +require_relative "document_i_ds_settings" +require_relative "ocr_auto_tagging_settings_request" +require_relative "accounting_settings" +require "ostruct" +require "json" + +module Monite + class SettingsResponse + # @return [Monite::LanguageCodeEnum] + attr_reader :language + # @return [Monite::CurrencySettingsOutput] + attr_reader :currency + # @return [Monite::RemindersSettings] + attr_reader :reminder + # @return [Monite::VatModeEnum] Defines whether the prices of products in receivables will already include VAT +# or not. + attr_reader :vat_mode + # @return [Monite::PaymentPriorityEnum] Payment preferences for entity to automate calculating suggested payment date +# based on payment terms and entity preferences. + attr_reader :payment_priority + # @return [Boolean] Automatically attempt to find a corresponding purchase order for all incoming +# payables. + attr_reader :allow_purchase_order_autolinking + # @return [Monite::ReceivableEditFlow] + attr_reader :receivable_edit_flow + # @return [Monite::DocumentIDsSettings] + attr_reader :document_ids + # @return [Array] Auto tagging settings for all incoming OCR payable documents. + attr_reader :payables_ocr_auto_tagging + # @return [Boolean] Sets the default behavior of whether a signature is required to accept quotes. + attr_reader :quote_signature_required + # @return [Boolean] If enabled, the paid invoice's PDF will be in a new layout set by the user. + attr_reader :generate_paid_invoice_pdf + # @return [Monite::AccountingSettings] + attr_reader :accounting + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param language [Monite::LanguageCodeEnum] + # @param currency [Monite::CurrencySettingsOutput] + # @param reminder [Monite::RemindersSettings] + # @param vat_mode [Monite::VatModeEnum] Defines whether the prices of products in receivables will already include VAT +# or not. + # @param payment_priority [Monite::PaymentPriorityEnum] Payment preferences for entity to automate calculating suggested payment date +# based on payment terms and entity preferences. + # @param allow_purchase_order_autolinking [Boolean] Automatically attempt to find a corresponding purchase order for all incoming +# payables. + # @param receivable_edit_flow [Monite::ReceivableEditFlow] + # @param document_ids [Monite::DocumentIDsSettings] + # @param payables_ocr_auto_tagging [Array] Auto tagging settings for all incoming OCR payable documents. + # @param quote_signature_required [Boolean] Sets the default behavior of whether a signature is required to accept quotes. + # @param generate_paid_invoice_pdf [Boolean] If enabled, the paid invoice's PDF will be in a new layout set by the user. + # @param accounting [Monite::AccountingSettings] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SettingsResponse] + def initialize(language: OMIT, currency: OMIT, reminder: OMIT, vat_mode: OMIT, payment_priority: OMIT, allow_purchase_order_autolinking: OMIT, receivable_edit_flow: OMIT, document_ids: OMIT, payables_ocr_auto_tagging: OMIT, quote_signature_required: OMIT, generate_paid_invoice_pdf: OMIT, accounting: OMIT, additional_properties: nil) + @language = language if language != OMIT + @currency = currency if currency != OMIT + @reminder = reminder if reminder != OMIT + @vat_mode = vat_mode if vat_mode != OMIT + @payment_priority = payment_priority if payment_priority != OMIT + @allow_purchase_order_autolinking = allow_purchase_order_autolinking if allow_purchase_order_autolinking != OMIT + @receivable_edit_flow = receivable_edit_flow if receivable_edit_flow != OMIT + @document_ids = document_ids if document_ids != OMIT + @payables_ocr_auto_tagging = payables_ocr_auto_tagging if payables_ocr_auto_tagging != OMIT + @quote_signature_required = quote_signature_required if quote_signature_required != OMIT + @generate_paid_invoice_pdf = generate_paid_invoice_pdf if generate_paid_invoice_pdf != OMIT + @accounting = accounting if accounting != OMIT + @additional_properties = additional_properties + @_field_set = { "language": language, "currency": currency, "reminder": reminder, "vat_mode": vat_mode, "payment_priority": payment_priority, "allow_purchase_order_autolinking": allow_purchase_order_autolinking, "receivable_edit_flow": receivable_edit_flow, "document_ids": document_ids, "payables_ocr_auto_tagging": payables_ocr_auto_tagging, "quote_signature_required": quote_signature_required, "generate_paid_invoice_pdf": generate_paid_invoice_pdf, "accounting": accounting }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SettingsResponse + # + # @param json_object [String] + # @return [Monite::SettingsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + language = parsed_json["language"] + unless parsed_json["currency"].nil? + currency = parsed_json["currency"].to_json + currency = Monite::CurrencySettingsOutput.from_json(json_object: currency) + else + currency = nil + end + unless parsed_json["reminder"].nil? + reminder = parsed_json["reminder"].to_json + reminder = Monite::RemindersSettings.from_json(json_object: reminder) + else + reminder = nil + end + vat_mode = parsed_json["vat_mode"] + payment_priority = parsed_json["payment_priority"] + allow_purchase_order_autolinking = parsed_json["allow_purchase_order_autolinking"] + receivable_edit_flow = parsed_json["receivable_edit_flow"] + unless parsed_json["document_ids"].nil? + document_ids = parsed_json["document_ids"].to_json + document_ids = Monite::DocumentIDsSettings.from_json(json_object: document_ids) + else + document_ids = nil + end + payables_ocr_auto_tagging = parsed_json["payables_ocr_auto_tagging"]&.map do | item | + item = item.to_json + Monite::OcrAutoTaggingSettingsRequest.from_json(json_object: item) +end + quote_signature_required = parsed_json["quote_signature_required"] + generate_paid_invoice_pdf = parsed_json["generate_paid_invoice_pdf"] + unless parsed_json["accounting"].nil? + accounting = parsed_json["accounting"].to_json + accounting = Monite::AccountingSettings.from_json(json_object: accounting) + else + accounting = nil + end + new( + language: language, + currency: currency, + reminder: reminder, + vat_mode: vat_mode, + payment_priority: payment_priority, + allow_purchase_order_autolinking: allow_purchase_order_autolinking, + receivable_edit_flow: receivable_edit_flow, + document_ids: document_ids, + payables_ocr_auto_tagging: payables_ocr_auto_tagging, + quote_signature_required: quote_signature_required, + generate_paid_invoice_pdf: generate_paid_invoice_pdf, + accounting: accounting, + additional_properties: struct + ) + end +# Serialize an instance of SettingsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.language&.is_a?(Monite::LanguageCodeEnum) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.currency.nil? || Monite::CurrencySettingsOutput.validate_raw(obj: obj.currency) + obj.reminder.nil? || Monite::RemindersSettings.validate_raw(obj: obj.reminder) + obj.vat_mode&.is_a?(Monite::VatModeEnum) != false || raise("Passed value for field obj.vat_mode is not the expected type, validation failed.") + obj.payment_priority&.is_a?(Monite::PaymentPriorityEnum) != false || raise("Passed value for field obj.payment_priority is not the expected type, validation failed.") + obj.allow_purchase_order_autolinking&.is_a?(Boolean) != false || raise("Passed value for field obj.allow_purchase_order_autolinking is not the expected type, validation failed.") + obj.receivable_edit_flow&.is_a?(Monite::ReceivableEditFlow) != false || raise("Passed value for field obj.receivable_edit_flow is not the expected type, validation failed.") + obj.document_ids.nil? || Monite::DocumentIDsSettings.validate_raw(obj: obj.document_ids) + obj.payables_ocr_auto_tagging&.is_a?(Array) != false || raise("Passed value for field obj.payables_ocr_auto_tagging is not the expected type, validation failed.") + obj.quote_signature_required&.is_a?(Boolean) != false || raise("Passed value for field obj.quote_signature_required is not the expected type, validation failed.") + obj.generate_paid_invoice_pdf&.is_a?(Boolean) != false || raise("Passed value for field obj.generate_paid_invoice_pdf is not the expected type, validation failed.") + obj.accounting.nil? || Monite::AccountingSettings.validate_raw(obj: obj.accounting) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/signature.rb b/lib/monite/types/signature.rb new file mode 100644 index 0000000..b36c2c7 --- /dev/null +++ b/lib/monite/types/signature.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class Signature + # @return [String] The email of a person who signed a quote + attr_reader :email + # @return [String] The full name of a person who signed a quote + attr_reader :full_name + # @return [String] Base64 encoded PNG image of a signature + attr_reader :signature_image + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param email [String] The email of a person who signed a quote + # @param full_name [String] The full name of a person who signed a quote + # @param signature_image [String] Base64 encoded PNG image of a signature + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Signature] + def initialize(email:, full_name:, signature_image:, additional_properties: nil) + @email = email + @full_name = full_name + @signature_image = signature_image + @additional_properties = additional_properties + @_field_set = { "email": email, "full_name": full_name, "signature_image": signature_image } + end +# Deserialize a JSON object to an instance of Signature + # + # @param json_object [String] + # @return [Monite::Signature] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + email = parsed_json["email"] + full_name = parsed_json["full_name"] + signature_image = parsed_json["signature_image"] + new( + email: email, + full_name: full_name, + signature_image: signature_image, + additional_properties: struct + ) + end +# Serialize an instance of Signature to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.email.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.full_name.is_a?(String) != false || raise("Passed value for field obj.full_name is not the expected type, validation failed.") + obj.signature_image.is_a?(String) != false || raise("Passed value for field obj.signature_image is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/single_onboarding_requirements_response.rb b/lib/monite/types/single_onboarding_requirements_response.rb new file mode 100644 index 0000000..09ee39b --- /dev/null +++ b/lib/monite/types/single_onboarding_requirements_response.rb @@ -0,0 +1,106 @@ +# frozen_string_literal: true +require_relative "payment_method_requirements" +require_relative "onboarding_requirements_error" +require_relative "onboarding_verification_error" +require_relative "onboarding_verification_status_enum" +require "ostruct" +require "json" + +module Monite + class SingleOnboardingRequirementsResponse + # @return [String] + attr_reader :disabled_reason + # @return [String] + attr_reader :payment_method + # @return [Monite::PaymentMethodRequirements] + attr_reader :requirements + # @return [Array] + attr_reader :requirements_errors + # @return [Array] + attr_reader :verification_errors + # @return [Monite::OnboardingVerificationStatusEnum] + attr_reader :verification_status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param disabled_reason [String] + # @param payment_method [String] + # @param requirements [Monite::PaymentMethodRequirements] + # @param requirements_errors [Array] + # @param verification_errors [Array] + # @param verification_status [Monite::OnboardingVerificationStatusEnum] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SingleOnboardingRequirementsResponse] + def initialize(disabled_reason: OMIT, payment_method:, requirements:, requirements_errors:, verification_errors:, verification_status:, additional_properties: nil) + @disabled_reason = disabled_reason if disabled_reason != OMIT + @payment_method = payment_method + @requirements = requirements + @requirements_errors = requirements_errors + @verification_errors = verification_errors + @verification_status = verification_status + @additional_properties = additional_properties + @_field_set = { "disabled_reason": disabled_reason, "payment_method": payment_method, "requirements": requirements, "requirements_errors": requirements_errors, "verification_errors": verification_errors, "verification_status": verification_status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SingleOnboardingRequirementsResponse + # + # @param json_object [String] + # @return [Monite::SingleOnboardingRequirementsResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + disabled_reason = parsed_json["disabled_reason"] + payment_method = parsed_json["payment_method"] + unless parsed_json["requirements"].nil? + requirements = parsed_json["requirements"].to_json + requirements = Monite::PaymentMethodRequirements.from_json(json_object: requirements) + else + requirements = nil + end + requirements_errors = parsed_json["requirements_errors"]&.map do | item | + item = item.to_json + Monite::OnboardingRequirementsError.from_json(json_object: item) +end + verification_errors = parsed_json["verification_errors"]&.map do | item | + item = item.to_json + Monite::OnboardingVerificationError.from_json(json_object: item) +end + verification_status = parsed_json["verification_status"] + new( + disabled_reason: disabled_reason, + payment_method: payment_method, + requirements: requirements, + requirements_errors: requirements_errors, + verification_errors: verification_errors, + verification_status: verification_status, + additional_properties: struct + ) + end +# Serialize an instance of SingleOnboardingRequirementsResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.disabled_reason&.is_a?(String) != false || raise("Passed value for field obj.disabled_reason is not the expected type, validation failed.") + obj.payment_method.is_a?(String) != false || raise("Passed value for field obj.payment_method is not the expected type, validation failed.") + Monite::PaymentMethodRequirements.validate_raw(obj: obj.requirements) + obj.requirements_errors.is_a?(Array) != false || raise("Passed value for field obj.requirements_errors is not the expected type, validation failed.") + obj.verification_errors.is_a?(Array) != false || raise("Passed value for field obj.verification_errors is not the expected type, validation failed.") + obj.verification_status.is_a?(Monite::OnboardingVerificationStatusEnum) != false || raise("Passed value for field obj.verification_status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/single_payment_intent.rb b/lib/monite/types/single_payment_intent.rb new file mode 100644 index 0000000..7445581 --- /dev/null +++ b/lib/monite/types/single_payment_intent.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "payment_object_payable" +require_relative "payment_intents_recipient" +require "ostruct" +require "json" + +module Monite + class SinglePaymentIntent + # @return [Monite::PaymentObjectPayable] + attr_reader :object + # @return [String] Must be provided if payable's document id is missing. + attr_reader :payment_reference + # @return [Monite::PaymentIntentsRecipient] + attr_reader :recipient + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object [Monite::PaymentObjectPayable] + # @param payment_reference [String] Must be provided if payable's document id is missing. + # @param recipient [Monite::PaymentIntentsRecipient] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SinglePaymentIntent] + def initialize(object:, payment_reference: OMIT, recipient:, additional_properties: nil) + @object = object + @payment_reference = payment_reference if payment_reference != OMIT + @recipient = recipient + @additional_properties = additional_properties + @_field_set = { "object": object, "payment_reference": payment_reference, "recipient": recipient }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SinglePaymentIntent + # + # @param json_object [String] + # @return [Monite::SinglePaymentIntent] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["object"].nil? + object = parsed_json["object"].to_json + object = Monite::PaymentObjectPayable.from_json(json_object: object) + else + object = nil + end + payment_reference = parsed_json["payment_reference"] + unless parsed_json["recipient"].nil? + recipient = parsed_json["recipient"].to_json + recipient = Monite::PaymentIntentsRecipient.from_json(json_object: recipient) + else + recipient = nil + end + new( + object: object, + payment_reference: payment_reference, + recipient: recipient, + additional_properties: struct + ) + end +# Serialize an instance of SinglePaymentIntent to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::PaymentObjectPayable.validate_raw(obj: obj.object) + obj.payment_reference&.is_a?(String) != false || raise("Passed value for field obj.payment_reference is not the expected type, validation failed.") + Monite::PaymentIntentsRecipient.validate_raw(obj: obj.recipient) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/single_payment_intent_response.rb b/lib/monite/types/single_payment_intent_response.rb new file mode 100644 index 0000000..dad31ac --- /dev/null +++ b/lib/monite/types/single_payment_intent_response.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true +require "date" +require_relative "currency_enum" +require_relative "payment_object_payable" +require_relative "payment_intents_recipient" +require "ostruct" +require "json" + +module Monite + class SinglePaymentIntentResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [Integer] + attr_reader :amount + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [Hash{String => Object}] + attr_reader :error + # @return [Monite::PaymentObjectPayable] + attr_reader :object + # @return [String] + attr_reader :payment_reference + # @return [Monite::PaymentIntentsRecipient] + attr_reader :recipient + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param amount [Integer] + # @param currency [Monite::CurrencyEnum] + # @param error [Hash{String => Object}] + # @param object [Monite::PaymentObjectPayable] + # @param payment_reference [String] + # @param recipient [Monite::PaymentIntentsRecipient] + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SinglePaymentIntentResponse] + def initialize(id:, created_at:, amount:, currency:, error: OMIT, object:, payment_reference:, recipient:, status:, additional_properties: nil) + @id = id + @created_at = created_at + @amount = amount + @currency = currency + @error = error if error != OMIT + @object = object + @payment_reference = payment_reference + @recipient = recipient + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "amount": amount, "currency": currency, "error": error, "object": object, "payment_reference": payment_reference, "recipient": recipient, "status": status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SinglePaymentIntentResponse + # + # @param json_object [String] + # @return [Monite::SinglePaymentIntentResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + amount = parsed_json["amount"] + currency = parsed_json["currency"] + error = parsed_json["error"] + unless parsed_json["object"].nil? + object = parsed_json["object"].to_json + object = Monite::PaymentObjectPayable.from_json(json_object: object) + else + object = nil + end + payment_reference = parsed_json["payment_reference"] + unless parsed_json["recipient"].nil? + recipient = parsed_json["recipient"].to_json + recipient = Monite::PaymentIntentsRecipient.from_json(json_object: recipient) + else + recipient = nil + end + status = parsed_json["status"] + new( + id: id, + created_at: created_at, + amount: amount, + currency: currency, + error: error, + object: object, + payment_reference: payment_reference, + recipient: recipient, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of SinglePaymentIntentResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.amount.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.currency.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.error&.is_a?(Hash) != false || raise("Passed value for field obj.error is not the expected type, validation failed.") + Monite::PaymentObjectPayable.validate_raw(obj: obj.object) + obj.payment_reference.is_a?(String) != false || raise("Passed value for field obj.payment_reference is not the expected type, validation failed.") + Monite::PaymentIntentsRecipient.validate_raw(obj: obj.recipient) + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/source_of_payable_data_enum.rb b/lib/monite/types/source_of_payable_data_enum.rb new file mode 100644 index 0000000..775a39a --- /dev/null +++ b/lib/monite/types/source_of_payable_data_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class SourceOfPayableDataEnum + + OCR = "ocr" + USER_SPECIFIED = "user_specified" + EINVOICING = "einvoicing" + + end +end \ No newline at end of file diff --git a/lib/monite/types/status_changed_event_data.rb b/lib/monite/types/status_changed_event_data.rb new file mode 100644 index 0000000..2d99980 --- /dev/null +++ b/lib/monite/types/status_changed_event_data.rb @@ -0,0 +1,67 @@ +# frozen_string_literal: true +require_relative "receivables_status_enum" +require "ostruct" +require "json" + +module Monite +# Contains information about a document's status change. See the applicable +# [invoice statuses](https://docs.monite.com/accounts-receivable/invoices/index), +# [quote statuses](https://docs.monite.com/accounts-receivable/quotes/index), +# and [credit note +# https://docs.monite.com/accounts-receivable/credit-notes#credit-note-lifecycle). + class StatusChangedEventData + # @return [Monite::ReceivablesStatusEnum] The new status of a document. + attr_reader :new_status + # @return [Monite::ReceivablesStatusEnum] The old status of a document. + attr_reader :old_status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param new_status [Monite::ReceivablesStatusEnum] The new status of a document. + # @param old_status [Monite::ReceivablesStatusEnum] The old status of a document. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::StatusChangedEventData] + def initialize(new_status:, old_status:, additional_properties: nil) + @new_status = new_status + @old_status = old_status + @additional_properties = additional_properties + @_field_set = { "new_status": new_status, "old_status": old_status } + end +# Deserialize a JSON object to an instance of StatusChangedEventData + # + # @param json_object [String] + # @return [Monite::StatusChangedEventData] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + new_status = parsed_json["new_status"] + old_status = parsed_json["old_status"] + new( + new_status: new_status, + old_status: old_status, + additional_properties: struct + ) + end +# Serialize an instance of StatusChangedEventData to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.new_status.is_a?(Monite::ReceivablesStatusEnum) != false || raise("Passed value for field obj.new_status is not the expected type, validation failed.") + obj.old_status.is_a?(Monite::ReceivablesStatusEnum) != false || raise("Passed value for field obj.old_status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/status_enum.rb b/lib/monite/types/status_enum.rb new file mode 100644 index 0000000..93e1013 --- /dev/null +++ b/lib/monite/types/status_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class StatusEnum + + ACTIVE = "active" + DELETED = "deleted" + + end +end \ No newline at end of file diff --git a/lib/monite/types/success_result.rb b/lib/monite/types/success_result.rb new file mode 100644 index 0000000..24444f1 --- /dev/null +++ b/lib/monite/types/success_result.rb @@ -0,0 +1,53 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class SuccessResult + # @return [Boolean] + attr_reader :success + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param success [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SuccessResult] + def initialize(success: OMIT, additional_properties: nil) + @success = success if success != OMIT + @additional_properties = additional_properties + @_field_set = { "success": success }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SuccessResult + # + # @param json_object [String] + # @return [Monite::SuccessResult] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + success = parsed_json["success"] + new(success: success, additional_properties: struct) + end +# Serialize an instance of SuccessResult to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.success&.is_a?(Boolean) != false || raise("Passed value for field obj.success is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/suggested_payment_term.rb b/lib/monite/types/suggested_payment_term.rb new file mode 100644 index 0000000..5484379 --- /dev/null +++ b/lib/monite/types/suggested_payment_term.rb @@ -0,0 +1,64 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite +# Suggested payment date and corresponding discount + class SuggestedPaymentTerm + # @return [String] + attr_reader :date + # @return [Integer] + attr_reader :discount + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date [String] + # @param discount [Integer] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SuggestedPaymentTerm] + def initialize(date:, discount: OMIT, additional_properties: nil) + @date = date + @discount = discount if discount != OMIT + @additional_properties = additional_properties + @_field_set = { "date": date, "discount": discount }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SuggestedPaymentTerm + # + # @param json_object [String] + # @return [Monite::SuggestedPaymentTerm] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date = parsed_json["date"] + discount = parsed_json["discount"] + new( + date: date, + discount: discount, + additional_properties: struct + ) + end +# Serialize an instance of SuggestedPaymentTerm to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date.is_a?(String) != false || raise("Passed value for field obj.date is not the expected type, validation failed.") + obj.discount&.is_a?(Integer) != false || raise("Passed value for field obj.discount is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/supported_field_names.rb b/lib/monite/types/supported_field_names.rb new file mode 100644 index 0000000..ec2e644 --- /dev/null +++ b/lib/monite/types/supported_field_names.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class SupportedFieldNames + + DEFAULT_ACCOUNT_CODE = "default_account_code" + DEFAULT_TAX_RATE_CODE = "default_tax_rate_code" + + end +end \ No newline at end of file diff --git a/lib/monite/types/supported_format_schema.rb b/lib/monite/types/supported_format_schema.rb new file mode 100644 index 0000000..11d5dab --- /dev/null +++ b/lib/monite/types/supported_format_schema.rb @@ -0,0 +1,62 @@ +# frozen_string_literal: true +require_relative "supported_format_schema_object_type" +require "ostruct" +require "json" + +module Monite + class SupportedFormatSchema + # @return [Hash{String => Array}] + attr_reader :available_types + # @return [Monite::SupportedFormatSchemaObjectType] + attr_reader :object_type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param available_types [Hash{String => Array}] + # @param object_type [Monite::SupportedFormatSchemaObjectType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SupportedFormatSchema] + def initialize(available_types:, object_type:, additional_properties: nil) + @available_types = available_types + @object_type = object_type + @additional_properties = additional_properties + @_field_set = { "available_types": available_types, "object_type": object_type } + end +# Deserialize a JSON object to an instance of SupportedFormatSchema + # + # @param json_object [String] + # @return [Monite::SupportedFormatSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + available_types = parsed_json["available_types"] + object_type = parsed_json["object_type"] + new( + available_types: available_types, + object_type: object_type, + additional_properties: struct + ) + end +# Serialize an instance of SupportedFormatSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.available_types.is_a?(Hash) != false || raise("Passed value for field obj.available_types is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::SupportedFormatSchemaObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/supported_format_schema_object_type.rb b/lib/monite/types/supported_format_schema_object_type.rb new file mode 100644 index 0000000..77777a3 --- /dev/null +++ b/lib/monite/types/supported_format_schema_object_type.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class SupportedFormatSchemaObjectType + + PAYABLE = "payable" + RECEIVABLE = "receivable" + + end +end \ No newline at end of file diff --git a/lib/monite/types/sync_record_cursor_fields.rb b/lib/monite/types/sync_record_cursor_fields.rb new file mode 100644 index 0000000..0c3604b --- /dev/null +++ b/lib/monite/types/sync_record_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class SyncRecordCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/sync_record_resource.rb b/lib/monite/types/sync_record_resource.rb new file mode 100644 index 0000000..c9732cb --- /dev/null +++ b/lib/monite/types/sync_record_resource.rb @@ -0,0 +1,188 @@ +# frozen_string_literal: true +require "date" +require "date" +require "date" +require_relative "object_match_types" +require "date" +require_relative "platform" +require "date" +require_relative "service_providers_enum" +require "date" +require_relative "sync_status" +require "ostruct" +require "json" + +module Monite + class SyncRecordResource + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [Hash{String => Object}] + attr_reader :errors + # @return [DateTime] + attr_reader :last_pulled_at + # @return [String] + attr_reader :object_id + # @return [Monite::ObjectMatchTypes] + attr_reader :object_type + # @return [DateTime] + attr_reader :object_updated_at + # @return [Monite::Platform] + attr_reader :platform + # @return [String] + attr_reader :platform_object_id + # @return [DateTime] + attr_reader :platform_updated_at + # @return [Monite::ServiceProvidersEnum] + attr_reader :provider + # @return [String] + attr_reader :provider_object_id + # @return [DateTime] + attr_reader :provider_updated_at + # @return [Monite::SyncStatus] + attr_reader :sync_status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param errors [Hash{String => Object}] + # @param last_pulled_at [DateTime] + # @param object_id [String] + # @param object_type [Monite::ObjectMatchTypes] + # @param object_updated_at [DateTime] + # @param platform [Monite::Platform] + # @param platform_object_id [String] + # @param platform_updated_at [DateTime] + # @param provider [Monite::ServiceProvidersEnum] + # @param provider_object_id [String] + # @param provider_updated_at [DateTime] + # @param sync_status [Monite::SyncStatus] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SyncRecordResource] + def initialize(id:, created_at:, updated_at:, errors: OMIT, last_pulled_at:, object_id: OMIT, object_type:, object_updated_at: OMIT, platform: OMIT, platform_object_id: OMIT, platform_updated_at: OMIT, provider: OMIT, provider_object_id: OMIT, provider_updated_at: OMIT, sync_status:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @errors = errors if errors != OMIT + @last_pulled_at = last_pulled_at + @object_id = object_id if object_id != OMIT + @object_type = object_type + @object_updated_at = object_updated_at if object_updated_at != OMIT + @platform = platform if platform != OMIT + @platform_object_id = platform_object_id if platform_object_id != OMIT + @platform_updated_at = platform_updated_at if platform_updated_at != OMIT + @provider = provider if provider != OMIT + @provider_object_id = provider_object_id if provider_object_id != OMIT + @provider_updated_at = provider_updated_at if provider_updated_at != OMIT + @sync_status = sync_status + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "errors": errors, "last_pulled_at": last_pulled_at, "object_id": object_id, "object_type": object_type, "object_updated_at": object_updated_at, "platform": platform, "platform_object_id": platform_object_id, "platform_updated_at": platform_updated_at, "provider": provider, "provider_object_id": provider_object_id, "provider_updated_at": provider_updated_at, "sync_status": sync_status }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SyncRecordResource + # + # @param json_object [String] + # @return [Monite::SyncRecordResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + errors = parsed_json["errors"] + last_pulled_at = unless parsed_json["last_pulled_at"].nil? + DateTime.parse(parsed_json["last_pulled_at"]) +else + nil +end + object_id = parsed_json["object_id"] + object_type = parsed_json["object_type"] + object_updated_at = unless parsed_json["object_updated_at"].nil? + DateTime.parse(parsed_json["object_updated_at"]) +else + nil +end + platform = parsed_json["platform"] + platform_object_id = parsed_json["platform_object_id"] + platform_updated_at = unless parsed_json["platform_updated_at"].nil? + DateTime.parse(parsed_json["platform_updated_at"]) +else + nil +end + provider = parsed_json["provider"] + provider_object_id = parsed_json["provider_object_id"] + provider_updated_at = unless parsed_json["provider_updated_at"].nil? + DateTime.parse(parsed_json["provider_updated_at"]) +else + nil +end + sync_status = parsed_json["sync_status"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + errors: errors, + last_pulled_at: last_pulled_at, + object_id: object_id, + object_type: object_type, + object_updated_at: object_updated_at, + platform: platform, + platform_object_id: platform_object_id, + platform_updated_at: platform_updated_at, + provider: provider, + provider_object_id: provider_object_id, + provider_updated_at: provider_updated_at, + sync_status: sync_status, + additional_properties: struct + ) + end +# Serialize an instance of SyncRecordResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.errors&.is_a?(Hash) != false || raise("Passed value for field obj.errors is not the expected type, validation failed.") + obj.last_pulled_at.is_a?(DateTime) != false || raise("Passed value for field obj.last_pulled_at is not the expected type, validation failed.") + obj.object_id&.is_a?(String) != false || raise("Passed value for field obj.object_id is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::ObjectMatchTypes) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.object_updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.object_updated_at is not the expected type, validation failed.") + obj.platform&.is_a?(Monite::Platform) != false || raise("Passed value for field obj.platform is not the expected type, validation failed.") + obj.platform_object_id&.is_a?(String) != false || raise("Passed value for field obj.platform_object_id is not the expected type, validation failed.") + obj.platform_updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.platform_updated_at is not the expected type, validation failed.") + obj.provider&.is_a?(Monite::ServiceProvidersEnum) != false || raise("Passed value for field obj.provider is not the expected type, validation failed.") + obj.provider_object_id&.is_a?(String) != false || raise("Passed value for field obj.provider_object_id is not the expected type, validation failed.") + obj.provider_updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.provider_updated_at is not the expected type, validation failed.") + obj.sync_status.is_a?(Monite::SyncStatus) != false || raise("Passed value for field obj.sync_status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/sync_record_resource_list.rb b/lib/monite/types/sync_record_resource_list.rb new file mode 100644 index 0000000..aa4aad2 --- /dev/null +++ b/lib/monite/types/sync_record_resource_list.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "sync_record_resource" +require "ostruct" +require "json" + +module Monite + class SyncRecordResourceList + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SyncRecordResourceList] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of SyncRecordResourceList + # + # @param json_object [String] + # @return [Monite::SyncRecordResourceList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::SyncRecordResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of SyncRecordResourceList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/sync_status.rb b/lib/monite/types/sync_status.rb new file mode 100644 index 0000000..49091d6 --- /dev/null +++ b/lib/monite/types/sync_status.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class SyncStatus + + PENDING = "pending" + ERROR = "error" + DONE = "done" + + end +end \ No newline at end of file diff --git a/lib/monite/types/system_template_data_schema.rb b/lib/monite/types/system_template_data_schema.rb new file mode 100644 index 0000000..3df516a --- /dev/null +++ b/lib/monite/types/system_template_data_schema.rb @@ -0,0 +1,65 @@ +# frozen_string_literal: true +require_relative "template_data_schema" +require "ostruct" +require "json" + +module Monite + class SystemTemplateDataSchema + # @return [Array] Array of templates + attr_reader :available_templates + # @return [String] Name of the template + attr_reader :template_name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param available_templates [Array] Array of templates + # @param template_name [String] Name of the template + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SystemTemplateDataSchema] + def initialize(available_templates:, template_name:, additional_properties: nil) + @available_templates = available_templates + @template_name = template_name + @additional_properties = additional_properties + @_field_set = { "available_templates": available_templates, "template_name": template_name } + end +# Deserialize a JSON object to an instance of SystemTemplateDataSchema + # + # @param json_object [String] + # @return [Monite::SystemTemplateDataSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + available_templates = parsed_json["available_templates"]&.map do | item | + item = item.to_json + Monite::TemplateDataSchema.from_json(json_object: item) +end + template_name = parsed_json["template_name"] + new( + available_templates: available_templates, + template_name: template_name, + additional_properties: struct + ) + end +# Serialize an instance of SystemTemplateDataSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.available_templates.is_a?(Array) != false || raise("Passed value for field obj.available_templates is not the expected type, validation failed.") + obj.template_name.is_a?(String) != false || raise("Passed value for field obj.template_name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/system_templates.rb b/lib/monite/types/system_templates.rb new file mode 100644 index 0000000..8ea5815 --- /dev/null +++ b/lib/monite/types/system_templates.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "system_template_data_schema" +require "ostruct" +require "json" + +module Monite + class SystemTemplates + # @return [Array] All pre-defined email templates + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] All pre-defined email templates + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::SystemTemplates] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of SystemTemplates + # + # @param json_object [String] + # @return [Monite::SystemTemplates] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::SystemTemplateDataSchema.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of SystemTemplates to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/tag_category.rb b/lib/monite/types/tag_category.rb new file mode 100644 index 0000000..67ffad0 --- /dev/null +++ b/lib/monite/types/tag_category.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Monite + class TagCategory + + DOCUMENT_TYPE = "document_type" + DEPARTMENT = "department" + PROJECT = "project" + COST_CENTER = "cost_center" + VENDOR_TYPE = "vendor_type" + PAYMENT_METHOD = "payment_method" + APPROVAL_STATUS = "approval_status" + + end +end \ No newline at end of file diff --git a/lib/monite/types/tag_cursor_fields.rb b/lib/monite/types/tag_cursor_fields.rb new file mode 100644 index 0000000..5ebb02e --- /dev/null +++ b/lib/monite/types/tag_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class TagCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/tag_read_schema.rb b/lib/monite/types/tag_read_schema.rb new file mode 100644 index 0000000..a219958 --- /dev/null +++ b/lib/monite/types/tag_read_schema.rb @@ -0,0 +1,114 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "tag_category" +require "ostruct" +require "json" + +module Monite +# Represents a user-defined tag that can be assigned to resources to filter them. + class TagReadSchema + # @return [String] A unique ID of this tag. + attr_reader :id + # @return [DateTime] Date and time when the tag was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :created_at + # @return [DateTime] Date and time when the tag was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + attr_reader :updated_at + # @return [Monite::TagCategory] The tag category. + attr_reader :category + # @return [String] ID of the user who created the tag. + attr_reader :created_by_entity_user_id + # @return [String] The tag description. + attr_reader :description + # @return [String] The tag name. + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] A unique ID of this tag. + # @param created_at [DateTime] Date and time when the tag was created. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param updated_at [DateTime] Date and time when the tag was last updated. Timestamps follow the [ISO +# 8601](https://en.wikipedia.org/wiki/ISO_8601) standard. + # @param category [Monite::TagCategory] The tag category. + # @param created_by_entity_user_id [String] ID of the user who created the tag. + # @param description [String] The tag description. + # @param name [String] The tag name. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TagReadSchema] + def initialize(id:, created_at:, updated_at:, category: OMIT, created_by_entity_user_id: OMIT, description: OMIT, name:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @category = category if category != OMIT + @created_by_entity_user_id = created_by_entity_user_id if created_by_entity_user_id != OMIT + @description = description if description != OMIT + @name = name + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "category": category, "created_by_entity_user_id": created_by_entity_user_id, "description": description, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TagReadSchema + # + # @param json_object [String] + # @return [Monite::TagReadSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + category = parsed_json["category"] + created_by_entity_user_id = parsed_json["created_by_entity_user_id"] + description = parsed_json["description"] + name = parsed_json["name"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + category: category, + created_by_entity_user_id: created_by_entity_user_id, + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of TagReadSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.category&.is_a?(Monite::TagCategory) != false || raise("Passed value for field obj.category is not the expected type, validation failed.") + obj.created_by_entity_user_id&.is_a?(String) != false || raise("Passed value for field obj.created_by_entity_user_id is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/tags_pagination_response.rb b/lib/monite/types/tags_pagination_response.rb new file mode 100644 index 0000000..c82604d --- /dev/null +++ b/lib/monite/types/tags_pagination_response.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "tag_read_schema" +require "ostruct" +require "json" + +module Monite +# A paginated list of tags. + class TagsPaginationResponse + # @return [Array] + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TagsPaginationResponse] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TagsPaginationResponse + # + # @param json_object [String] + # @return [Monite::TagsPaginationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::TagReadSchema.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of TagsPaginationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/tax_component_response.rb b/lib/monite/types/tax_component_response.rb new file mode 100644 index 0000000..d1fb5e6 --- /dev/null +++ b/lib/monite/types/tax_component_response.rb @@ -0,0 +1,76 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class TaxComponentResponse + # @return [Boolean] A flag to indicate with the tax is calculated using the principle of +# compounding. + attr_reader :is_compound + # @return [String] + attr_reader :name + # @return [Integer] Component tax rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + attr_reader :rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param is_compound [Boolean] A flag to indicate with the tax is calculated using the principle of +# compounding. + # @param name [String] + # @param rate [Integer] Component tax rate in percent [minor +# units](https://docs.monite.com/references/currencies#minor-units). Example: +# 12.5% is 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TaxComponentResponse] + def initialize(is_compound: OMIT, name: OMIT, rate: OMIT, additional_properties: nil) + @is_compound = is_compound if is_compound != OMIT + @name = name if name != OMIT + @rate = rate if rate != OMIT + @additional_properties = additional_properties + @_field_set = { "is_compound": is_compound, "name": name, "rate": rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TaxComponentResponse + # + # @param json_object [String] + # @return [Monite::TaxComponentResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + is_compound = parsed_json["is_compound"] + name = parsed_json["name"] + rate = parsed_json["rate"] + new( + is_compound: is_compound, + name: name, + rate: rate, + additional_properties: struct + ) + end +# Serialize an instance of TaxComponentResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.is_compound&.is_a?(Boolean) != false || raise("Passed value for field obj.is_compound is not the expected type, validation failed.") + obj.name&.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.rate&.is_a?(Integer) != false || raise("Passed value for field obj.rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/tax_rate_account_cursor_fields.rb b/lib/monite/types/tax_rate_account_cursor_fields.rb new file mode 100644 index 0000000..a080cea --- /dev/null +++ b/lib/monite/types/tax_rate_account_cursor_fields.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + TAX_RATE_ACCOUNT_CURSOR_FIELDS = String +end \ No newline at end of file diff --git a/lib/monite/types/template_data_schema.rb b/lib/monite/types/template_data_schema.rb new file mode 100644 index 0000000..114f67f --- /dev/null +++ b/lib/monite/types/template_data_schema.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class TemplateDataSchema + # @return [String] Jinja2 compatible email body template + attr_reader :body_template + # @return [String] Lowercase ISO code of language + attr_reader :language + # @return [String] Jinja2 compatible email subject template + attr_reader :subject_template + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param body_template [String] Jinja2 compatible email body template + # @param language [String] Lowercase ISO code of language + # @param subject_template [String] Jinja2 compatible email subject template + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TemplateDataSchema] + def initialize(body_template:, language:, subject_template:, additional_properties: nil) + @body_template = body_template + @language = language + @subject_template = subject_template + @additional_properties = additional_properties + @_field_set = { "body_template": body_template, "language": language, "subject_template": subject_template } + end +# Deserialize a JSON object to an instance of TemplateDataSchema + # + # @param json_object [String] + # @return [Monite::TemplateDataSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + body_template = parsed_json["body_template"] + language = parsed_json["language"] + subject_template = parsed_json["subject_template"] + new( + body_template: body_template, + language: language, + subject_template: subject_template, + additional_properties: struct + ) + end +# Serialize an instance of TemplateDataSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.body_template.is_a?(String) != false || raise("Passed value for field obj.body_template is not the expected type, validation failed.") + obj.language.is_a?(String) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.subject_template.is_a?(String) != false || raise("Passed value for field obj.subject_template is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/template_list_response.rb b/lib/monite/types/template_list_response.rb new file mode 100644 index 0000000..6d8012a --- /dev/null +++ b/lib/monite/types/template_list_response.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "template_receivable_response" +require "ostruct" +require "json" + +module Monite + class TemplateListResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TemplateListResponse] + def initialize(data: OMIT, additional_properties: nil) + @data = data if data != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TemplateListResponse + # + # @param json_object [String] + # @return [Monite::TemplateListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::TemplateReceivableResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of TemplateListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data&.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/template_receivable_response.rb b/lib/monite/types/template_receivable_response.rb new file mode 100644 index 0000000..18c7b03 --- /dev/null +++ b/lib/monite/types/template_receivable_response.rb @@ -0,0 +1,144 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "document_type_enum" +require_relative "file_schema" +require_relative "template_type_enum" +require "ostruct" +require "json" + +module Monite + class TemplateReceivableResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [Array] + attr_reader :blocks + # @return [Monite::DocumentTypeEnum] + attr_reader :document_type + # @return [Boolean] + attr_reader :is_default + # @return [String] + attr_reader :language + # @return [String] + attr_reader :name + # @return [Monite::FileSchema] + attr_reader :preview + # @return [String] + attr_reader :template + # @return [Monite::TemplateTypeEnum] + attr_reader :template_type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param blocks [Array] + # @param document_type [Monite::DocumentTypeEnum] + # @param is_default [Boolean] + # @param language [String] + # @param name [String] + # @param preview [Monite::FileSchema] + # @param template [String] + # @param template_type [Monite::TemplateTypeEnum] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TemplateReceivableResponse] + def initialize(id:, created_at: OMIT, updated_at: OMIT, blocks: OMIT, document_type:, is_default:, language:, name:, preview: OMIT, template:, template_type: OMIT, additional_properties: nil) + @id = id + @created_at = created_at if created_at != OMIT + @updated_at = updated_at if updated_at != OMIT + @blocks = blocks if blocks != OMIT + @document_type = document_type + @is_default = is_default + @language = language + @name = name + @preview = preview if preview != OMIT + @template = template + @template_type = template_type if template_type != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "blocks": blocks, "document_type": document_type, "is_default": is_default, "language": language, "name": name, "preview": preview, "template": template, "template_type": template_type }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TemplateReceivableResponse + # + # @param json_object [String] + # @return [Monite::TemplateReceivableResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + blocks = parsed_json["blocks"] + document_type = parsed_json["document_type"] + is_default = parsed_json["is_default"] + language = parsed_json["language"] + name = parsed_json["name"] + unless parsed_json["preview"].nil? + preview = parsed_json["preview"].to_json + preview = Monite::FileSchema.from_json(json_object: preview) + else + preview = nil + end + template = parsed_json["template"] + template_type = parsed_json["template_type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + blocks: blocks, + document_type: document_type, + is_default: is_default, + language: language, + name: name, + preview: preview, + template: template, + template_type: template_type, + additional_properties: struct + ) + end +# Serialize an instance of TemplateReceivableResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at&.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at&.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.blocks&.is_a?(Array) != false || raise("Passed value for field obj.blocks is not the expected type, validation failed.") + obj.document_type.is_a?(Monite::DocumentTypeEnum) != false || raise("Passed value for field obj.document_type is not the expected type, validation failed.") + obj.is_default.is_a?(Boolean) != false || raise("Passed value for field obj.is_default is not the expected type, validation failed.") + obj.language.is_a?(String) != false || raise("Passed value for field obj.language is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.preview.nil? || Monite::FileSchema.validate_raw(obj: obj.preview) + obj.template.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.") + obj.template_type&.is_a?(Monite::TemplateTypeEnum) != false || raise("Passed value for field obj.template_type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/template_type_enum.rb b/lib/monite/types/template_type_enum.rb new file mode 100644 index 0000000..3ab1ead --- /dev/null +++ b/lib/monite/types/template_type_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class TemplateTypeEnum + + BLOCK = "block" + SOURCE_OBJECT = "source_object" + + end +end \ No newline at end of file diff --git a/lib/monite/types/term_final_with_date.rb b/lib/monite/types/term_final_with_date.rb new file mode 100644 index 0000000..a150125 --- /dev/null +++ b/lib/monite/types/term_final_with_date.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class TermFinalWithDate + # @return [String] + attr_reader :end_date + # @return [Integer] The amount of days after the invoice issue date. + attr_reader :number_of_days + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param end_date [String] + # @param number_of_days [Integer] The amount of days after the invoice issue date. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TermFinalWithDate] + def initialize(end_date: OMIT, number_of_days:, additional_properties: nil) + @end_date = end_date if end_date != OMIT + @number_of_days = number_of_days + @additional_properties = additional_properties + @_field_set = { "end_date": end_date, "number_of_days": number_of_days }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TermFinalWithDate + # + # @param json_object [String] + # @return [Monite::TermFinalWithDate] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + end_date = parsed_json["end_date"] + number_of_days = parsed_json["number_of_days"] + new( + end_date: end_date, + number_of_days: number_of_days, + additional_properties: struct + ) + end +# Serialize an instance of TermFinalWithDate to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.end_date&.is_a?(String) != false || raise("Passed value for field obj.end_date is not the expected type, validation failed.") + obj.number_of_days.is_a?(Integer) != false || raise("Passed value for field obj.number_of_days is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/terms_of_service_acceptance_input.rb b/lib/monite/types/terms_of_service_acceptance_input.rb new file mode 100644 index 0000000..a7b908f --- /dev/null +++ b/lib/monite/types/terms_of_service_acceptance_input.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class TermsOfServiceAcceptanceInput + # @return [DateTime] The date and time (in the ISO 8601 format) when the entity representative +# accepted the service agreement. + attr_reader :date + # @return [String] The IP address from which the entity representative accepted the service +# agreement. If omitted or set to `null` in the request, the IP address is +# inferred from the request origin or the `X-Forwarded-For` request header. + attr_reader :ip + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date [DateTime] The date and time (in the ISO 8601 format) when the entity representative +# accepted the service agreement. + # @param ip [String] The IP address from which the entity representative accepted the service +# agreement. If omitted or set to `null` in the request, the IP address is +# inferred from the request origin or the `X-Forwarded-For` request header. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TermsOfServiceAcceptanceInput] + def initialize(date: OMIT, ip: OMIT, additional_properties: nil) + @date = date if date != OMIT + @ip = ip if ip != OMIT + @additional_properties = additional_properties + @_field_set = { "date": date, "ip": ip }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TermsOfServiceAcceptanceInput + # + # @param json_object [String] + # @return [Monite::TermsOfServiceAcceptanceInput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date = unless parsed_json["date"].nil? + DateTime.parse(parsed_json["date"]) +else + nil +end + ip = parsed_json["ip"] + new( + date: date, + ip: ip, + additional_properties: struct + ) + end +# Serialize an instance of TermsOfServiceAcceptanceInput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date&.is_a?(DateTime) != false || raise("Passed value for field obj.date is not the expected type, validation failed.") + obj.ip&.is_a?(String) != false || raise("Passed value for field obj.ip is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/terms_of_service_acceptance_output.rb b/lib/monite/types/terms_of_service_acceptance_output.rb new file mode 100644 index 0000000..e5c3788 --- /dev/null +++ b/lib/monite/types/terms_of_service_acceptance_output.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class TermsOfServiceAcceptanceOutput + # @return [DateTime] The date and time (in the ISO 8601 format) when the entity representative +# accepted the service agreement. + attr_reader :date + # @return [String] The IP address from which the entity representative accepted the service +# agreement. If omitted or set to `null` in the request, the IP address is +# inferred from the request origin or the `X-Forwarded-For` request header. + attr_reader :ip + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param date [DateTime] The date and time (in the ISO 8601 format) when the entity representative +# accepted the service agreement. + # @param ip [String] The IP address from which the entity representative accepted the service +# agreement. If omitted or set to `null` in the request, the IP address is +# inferred from the request origin or the `X-Forwarded-For` request header. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TermsOfServiceAcceptanceOutput] + def initialize(date: OMIT, ip: OMIT, additional_properties: nil) + @date = date if date != OMIT + @ip = ip if ip != OMIT + @additional_properties = additional_properties + @_field_set = { "date": date, "ip": ip }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TermsOfServiceAcceptanceOutput + # + # @param json_object [String] + # @return [Monite::TermsOfServiceAcceptanceOutput] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + date = unless parsed_json["date"].nil? + DateTime.parse(parsed_json["date"]) +else + nil +end + ip = parsed_json["ip"] + new( + date: date, + ip: ip, + additional_properties: struct + ) + end +# Serialize an instance of TermsOfServiceAcceptanceOutput to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.date&.is_a?(DateTime) != false || raise("Passed value for field obj.date is not the expected type, validation failed.") + obj.ip&.is_a?(String) != false || raise("Passed value for field obj.ip is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/text_template_response.rb b/lib/monite/types/text_template_response.rb new file mode 100644 index 0000000..bc76fea --- /dev/null +++ b/lib/monite/types/text_template_response.rb @@ -0,0 +1,115 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "document_type_enum" +require_relative "text_template_type" +require "ostruct" +require "json" + +module Monite + class TextTemplateResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [Monite::DocumentTypeEnum] + attr_reader :document_type + # @return [Boolean] + attr_reader :is_default + # @return [String] + attr_reader :name + # @return [String] + attr_reader :template + # @return [Monite::TextTemplateType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param document_type [Monite::DocumentTypeEnum] + # @param is_default [Boolean] + # @param name [String] + # @param template [String] + # @param type [Monite::TextTemplateType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TextTemplateResponse] + def initialize(id:, created_at:, updated_at:, document_type:, is_default:, name:, template:, type:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @document_type = document_type + @is_default = is_default + @name = name + @template = template + @type = type + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "document_type": document_type, "is_default": is_default, "name": name, "template": template, "type": type } + end +# Deserialize a JSON object to an instance of TextTemplateResponse + # + # @param json_object [String] + # @return [Monite::TextTemplateResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + document_type = parsed_json["document_type"] + is_default = parsed_json["is_default"] + name = parsed_json["name"] + template = parsed_json["template"] + type = parsed_json["type"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + document_type: document_type, + is_default: is_default, + name: name, + template: template, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of TextTemplateResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.document_type.is_a?(Monite::DocumentTypeEnum) != false || raise("Passed value for field obj.document_type is not the expected type, validation failed.") + obj.is_default.is_a?(Boolean) != false || raise("Passed value for field obj.is_default is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + obj.template.is_a?(String) != false || raise("Passed value for field obj.template is not the expected type, validation failed.") + obj.type.is_a?(Monite::TextTemplateType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/text_template_response_list.rb b/lib/monite/types/text_template_response_list.rb new file mode 100644 index 0000000..5d50cc0 --- /dev/null +++ b/lib/monite/types/text_template_response_list.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require_relative "text_template_response" +require "ostruct" +require "json" + +module Monite + class TextTemplateResponseList + # @return [Array] + attr_reader :data + # @return [String] + attr_reader :next_pagination_token + # @return [String] + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param next_pagination_token [String] + # @param prev_pagination_token [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TextTemplateResponseList] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TextTemplateResponseList + # + # @param json_object [String] + # @return [Monite::TextTemplateResponseList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::TextTemplateResponse.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of TextTemplateResponseList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/text_template_type.rb b/lib/monite/types/text_template_type.rb new file mode 100644 index 0000000..4e5090b --- /dev/null +++ b/lib/monite/types/text_template_type.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class TextTemplateType + + EMAIL_HEADER = "email_header" + EMAIL_BODY = "email_body" + MEMO = "memo" + + end +end \ No newline at end of file diff --git a/lib/monite/types/total_vat_amount_item.rb b/lib/monite/types/total_vat_amount_item.rb new file mode 100644 index 0000000..d2cdc12 --- /dev/null +++ b/lib/monite/types/total_vat_amount_item.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class TotalVatAmountItem + # @return [String] + attr_reader :id + # @return [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + attr_reader :amount + # @return [Integer] Percent minor units. Example: 12.5% is 1250. + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param amount [Integer] The total VAT of all line items, in [minor +# units](https://docs.monite.com/references/currencies#minor-units). + # @param value [Integer] Percent minor units. Example: 12.5% is 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::TotalVatAmountItem] + def initialize(id: OMIT, amount:, value:, additional_properties: nil) + @id = id if id != OMIT + @amount = amount + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "amount": amount, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of TotalVatAmountItem + # + # @param json_object [String] + # @return [Monite::TotalVatAmountItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + amount = parsed_json["amount"] + value = parsed_json["value"] + new( + id: id, + amount: amount, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of TotalVatAmountItem to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id&.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.amount.is_a?(Integer) != false || raise("Passed value for field obj.amount is not the expected type, validation failed.") + obj.value.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/unit.rb b/lib/monite/types/unit.rb new file mode 100644 index 0000000..f723912 --- /dev/null +++ b/lib/monite/types/unit.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class Unit + # @return [String] + attr_reader :designation + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param designation [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Unit] + def initialize(designation:, name:, additional_properties: nil) + @designation = designation + @name = name + @additional_properties = additional_properties + @_field_set = { "designation": designation, "name": name } + end +# Deserialize a JSON object to an instance of Unit + # + # @param json_object [String] + # @return [Monite::Unit] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + designation = parsed_json["designation"] + name = parsed_json["name"] + new( + designation: designation, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of Unit to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.designation.is_a?(String) != false || raise("Passed value for field obj.designation is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/unit_list_response.rb b/lib/monite/types/unit_list_response.rb new file mode 100644 index 0000000..09f2a65 --- /dev/null +++ b/lib/monite/types/unit_list_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "unit_response" +require "ostruct" +require "json" + +module Monite + class UnitListResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UnitListResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of UnitListResponse + # + # @param json_object [String] + # @return [Monite::UnitListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::UnitResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of UnitListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/unit_request.rb b/lib/monite/types/unit_request.rb new file mode 100644 index 0000000..8e99a64 --- /dev/null +++ b/lib/monite/types/unit_request.rb @@ -0,0 +1,63 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class UnitRequest + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UnitRequest] + def initialize(description: OMIT, name:, additional_properties: nil) + @description = description if description != OMIT + @name = name + @additional_properties = additional_properties + @_field_set = { "description": description, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UnitRequest + # + # @param json_object [String] + # @return [Monite::UnitRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + name = parsed_json["name"] + new( + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of UnitRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/unit_response.rb b/lib/monite/types/unit_response.rb new file mode 100644 index 0000000..c950c12 --- /dev/null +++ b/lib/monite/types/unit_response.rb @@ -0,0 +1,94 @@ +# frozen_string_literal: true +require "date" +require "date" +require "ostruct" +require "json" + +module Monite + class UnitResponse + # @return [String] + attr_reader :id + # @return [DateTime] + attr_reader :created_at + # @return [DateTime] + attr_reader :updated_at + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param created_at [DateTime] + # @param updated_at [DateTime] + # @param description [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UnitResponse] + def initialize(id:, created_at:, updated_at:, description: OMIT, name:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @description = description if description != OMIT + @name = name + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "description": description, "name": name }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UnitResponse + # + # @param json_object [String] + # @return [Monite::UnitResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + description = parsed_json["description"] + name = parsed_json["name"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of UnitResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.description&.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_credit_note.rb b/lib/monite/types/update_credit_note.rb new file mode 100644 index 0000000..e81ab30 --- /dev/null +++ b/lib/monite/types/update_credit_note.rb @@ -0,0 +1,130 @@ +# frozen_string_literal: true +require_relative "receivable_counterpart_contact" +require_relative "receivable_entity_base" +require_relative "update_line_item_for_credit_note" +require "ostruct" +require "json" + +module Monite + class UpdateCreditNote + # @return [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address_id + # @return [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + attr_reader :counterpart_contact + # @return [String] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address_id + # @return [Monite::ReceivableEntityBase] + attr_reader :entity + # @return [Monite::UPDATE_LINE_ITEM_FOR_CREDIT_NOTE] + attr_reader :line_items + # @return [String] A note with additional information for a receivable + attr_reader :memo + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param counterpart_billing_address_id [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_contact [Monite::ReceivableCounterpartContact] Additional information about counterpart contacts. + # @param counterpart_shipping_address_id [String] Address where goods were shipped / where services were provided. + # @param entity [Monite::ReceivableEntityBase] + # @param line_items [Monite::UPDATE_LINE_ITEM_FOR_CREDIT_NOTE] + # @param memo [String] A note with additional information for a receivable + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param project_id [String] A project related to current receivable + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateCreditNote] + def initialize(counterpart_billing_address_id: OMIT, counterpart_contact: OMIT, counterpart_shipping_address_id: OMIT, entity: OMIT, line_items: OMIT, memo: OMIT, partner_metadata: OMIT, project_id: OMIT, tag_ids: OMIT, additional_properties: nil) + @counterpart_billing_address_id = counterpart_billing_address_id if counterpart_billing_address_id != OMIT + @counterpart_contact = counterpart_contact if counterpart_contact != OMIT + @counterpart_shipping_address_id = counterpart_shipping_address_id if counterpart_shipping_address_id != OMIT + @entity = entity if entity != OMIT + @line_items = line_items if line_items != OMIT + @memo = memo if memo != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @project_id = project_id if project_id != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @additional_properties = additional_properties + @_field_set = { "counterpart_billing_address_id": counterpart_billing_address_id, "counterpart_contact": counterpart_contact, "counterpart_shipping_address_id": counterpart_shipping_address_id, "entity": entity, "line_items": line_items, "memo": memo, "partner_metadata": partner_metadata, "project_id": project_id, "tag_ids": tag_ids }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateCreditNote + # + # @param json_object [String] + # @return [Monite::UpdateCreditNote] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + counterpart_billing_address_id = parsed_json["counterpart_billing_address_id"] + unless parsed_json["counterpart_contact"].nil? + counterpart_contact = parsed_json["counterpart_contact"].to_json + counterpart_contact = Monite::ReceivableCounterpartContact.from_json(json_object: counterpart_contact) + else + counterpart_contact = nil + end + counterpart_shipping_address_id = parsed_json["counterpart_shipping_address_id"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::ReceivableEntityBase.from_json(json_object: entity) + else + entity = nil + end + line_items = parsed_json["line_items"]&.transform_values do | value | + value = value.to_json + Monite::UpdateProductForCreditNote.from_json(json_object: value) +end + memo = parsed_json["memo"] + partner_metadata = parsed_json["partner_metadata"] + project_id = parsed_json["project_id"] + tag_ids = parsed_json["tag_ids"] + new( + counterpart_billing_address_id: counterpart_billing_address_id, + counterpart_contact: counterpart_contact, + counterpart_shipping_address_id: counterpart_shipping_address_id, + entity: entity, + line_items: line_items, + memo: memo, + partner_metadata: partner_metadata, + project_id: project_id, + tag_ids: tag_ids, + additional_properties: struct + ) + end +# Serialize an instance of UpdateCreditNote to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.counterpart_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_billing_address_id is not the expected type, validation failed.") + obj.counterpart_contact.nil? || Monite::ReceivableCounterpartContact.validate_raw(obj: obj.counterpart_contact) + obj.counterpart_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_shipping_address_id is not the expected type, validation failed.") + obj.entity.nil? || Monite::ReceivableEntityBase.validate_raw(obj: obj.entity) + obj.line_items&.is_a?(Hash) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_credit_note_payload.rb b/lib/monite/types/update_credit_note_payload.rb new file mode 100644 index 0000000..cd959ef --- /dev/null +++ b/lib/monite/types/update_credit_note_payload.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "update_credit_note" +require "ostruct" +require "json" + +module Monite + class UpdateCreditNotePayload + # @return [Monite::UpdateCreditNote] + attr_reader :credit_note + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param credit_note [Monite::UpdateCreditNote] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateCreditNotePayload] + def initialize(credit_note:, additional_properties: nil) + @credit_note = credit_note + @additional_properties = additional_properties + @_field_set = { "credit_note": credit_note } + end +# Deserialize a JSON object to an instance of UpdateCreditNotePayload + # + # @param json_object [String] + # @return [Monite::UpdateCreditNotePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["credit_note"].nil? + credit_note = parsed_json["credit_note"].to_json + credit_note = Monite::UpdateCreditNote.from_json(json_object: credit_note) + else + credit_note = nil + end + new(credit_note: credit_note, additional_properties: struct) + end +# Serialize an instance of UpdateCreditNotePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::UpdateCreditNote.validate_raw(obj: obj.credit_note) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_entity_address_schema.rb b/lib/monite/types/update_entity_address_schema.rb new file mode 100644 index 0000000..82d7997 --- /dev/null +++ b/lib/monite/types/update_entity_address_schema.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class UpdateEntityAddressSchema + # @return [String] A city (a full name) where the entity is registered + attr_reader :city + # @return [String] A street where the entity is registered + attr_reader :line_1 + # @return [String] An alternative street used by the entity + attr_reader :line_2 + # @return [String] A postal code of the address where the entity is registered + attr_reader :postal_code + # @return [String] A state in a country where the entity is registered + attr_reader :state + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param city [String] A city (a full name) where the entity is registered + # @param line_1 [String] A street where the entity is registered + # @param line_2 [String] An alternative street used by the entity + # @param postal_code [String] A postal code of the address where the entity is registered + # @param state [String] A state in a country where the entity is registered + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateEntityAddressSchema] + def initialize(city: OMIT, line_1: OMIT, line_2: OMIT, postal_code: OMIT, state: OMIT, additional_properties: nil) + @city = city if city != OMIT + @line_1 = line_1 if line_1 != OMIT + @line_2 = line_2 if line_2 != OMIT + @postal_code = postal_code if postal_code != OMIT + @state = state if state != OMIT + @additional_properties = additional_properties + @_field_set = { "city": city, "line1": line_1, "line2": line_2, "postal_code": postal_code, "state": state }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateEntityAddressSchema + # + # @param json_object [String] + # @return [Monite::UpdateEntityAddressSchema] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + city = parsed_json["city"] + line_1 = parsed_json["line1"] + line_2 = parsed_json["line2"] + postal_code = parsed_json["postal_code"] + state = parsed_json["state"] + new( + city: city, + line_1: line_1, + line_2: line_2, + postal_code: postal_code, + state: state, + additional_properties: struct + ) + end +# Serialize an instance of UpdateEntityAddressSchema to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.city&.is_a?(String) != false || raise("Passed value for field obj.city is not the expected type, validation failed.") + obj.line_1&.is_a?(String) != false || raise("Passed value for field obj.line_1 is not the expected type, validation failed.") + obj.line_2&.is_a?(String) != false || raise("Passed value for field obj.line_2 is not the expected type, validation failed.") + obj.postal_code&.is_a?(String) != false || raise("Passed value for field obj.postal_code is not the expected type, validation failed.") + obj.state&.is_a?(String) != false || raise("Passed value for field obj.state is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_entity_request.rb b/lib/monite/types/update_entity_request.rb new file mode 100644 index 0000000..cf5db5e --- /dev/null +++ b/lib/monite/types/update_entity_request.rb @@ -0,0 +1,121 @@ +# frozen_string_literal: true +require_relative "update_entity_address_schema" +require_relative "optional_organization_schema" +require_relative "optional_individual_schema" +require "ostruct" +require "json" + +module Monite +# A schema for a request to update an entity + class UpdateEntityRequest + # @return [Monite::UpdateEntityAddressSchema] An address description of the entity + attr_reader :address + # @return [String] An official email address of the entity + attr_reader :email + # @return [String] The contact phone number of the entity. Required for US organizations to use +# payments. + attr_reader :phone + # @return [String] A website of the entity + attr_reader :website + # @return [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + attr_reader :tax_id + # @return [Monite::OptionalOrganizationSchema] A set of meta data describing the organization + attr_reader :organization + # @return [Monite::OptionalIndividualSchema] A set of meta data describing the individual + attr_reader :individual + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param address [Monite::UpdateEntityAddressSchema] An address description of the entity + # @param email [String] An official email address of the entity + # @param phone [String] The contact phone number of the entity. Required for US organizations to use +# payments. + # @param website [String] A website of the entity + # @param tax_id [String] The entity's taxpayer identification number or tax ID. This field is required +# for entities that are non-VAT registered. + # @param organization [Monite::OptionalOrganizationSchema] A set of meta data describing the organization + # @param individual [Monite::OptionalIndividualSchema] A set of meta data describing the individual + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateEntityRequest] + def initialize(address: OMIT, email: OMIT, phone: OMIT, website: OMIT, tax_id: OMIT, organization: OMIT, individual: OMIT, additional_properties: nil) + @address = address if address != OMIT + @email = email if email != OMIT + @phone = phone if phone != OMIT + @website = website if website != OMIT + @tax_id = tax_id if tax_id != OMIT + @organization = organization if organization != OMIT + @individual = individual if individual != OMIT + @additional_properties = additional_properties + @_field_set = { "address": address, "email": email, "phone": phone, "website": website, "tax_id": tax_id, "organization": organization, "individual": individual }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateEntityRequest + # + # @param json_object [String] + # @return [Monite::UpdateEntityRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["address"].nil? + address = parsed_json["address"].to_json + address = Monite::UpdateEntityAddressSchema.from_json(json_object: address) + else + address = nil + end + email = parsed_json["email"] + phone = parsed_json["phone"] + website = parsed_json["website"] + tax_id = parsed_json["tax_id"] + unless parsed_json["organization"].nil? + organization = parsed_json["organization"].to_json + organization = Monite::OptionalOrganizationSchema.from_json(json_object: organization) + else + organization = nil + end + unless parsed_json["individual"].nil? + individual = parsed_json["individual"].to_json + individual = Monite::OptionalIndividualSchema.from_json(json_object: individual) + else + individual = nil + end + new( + address: address, + email: email, + phone: phone, + website: website, + tax_id: tax_id, + organization: organization, + individual: individual, + additional_properties: struct + ) + end +# Serialize an instance of UpdateEntityRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.address.nil? || Monite::UpdateEntityAddressSchema.validate_raw(obj: obj.address) + obj.email&.is_a?(String) != false || raise("Passed value for field obj.email is not the expected type, validation failed.") + obj.phone&.is_a?(String) != false || raise("Passed value for field obj.phone is not the expected type, validation failed.") + obj.website&.is_a?(String) != false || raise("Passed value for field obj.website is not the expected type, validation failed.") + obj.tax_id&.is_a?(String) != false || raise("Passed value for field obj.tax_id is not the expected type, validation failed.") + obj.organization.nil? || Monite::OptionalOrganizationSchema.validate_raw(obj: obj.organization) + obj.individual.nil? || Monite::OptionalIndividualSchema.validate_raw(obj: obj.individual) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_invoice.rb b/lib/monite/types/update_invoice.rb new file mode 100644 index 0000000..d395ec4 --- /dev/null +++ b/lib/monite/types/update_invoice.rb @@ -0,0 +1,258 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "discount" +require_relative "receivable_entity_base" +require_relative "line_item_update" +require "ostruct" +require "json" + +module Monite + class UpdateInvoice + # @return [String] Unique ID of the counterpart contact. + attr_reader :contact_id + # @return [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address_id + # @return [String] Unique ID of the counterpart. + attr_reader :counterpart_id + # @return [String] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address_id + # @return [String] Counterpart VAT ID id + attr_reader :counterpart_vat_id_id + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [Monite::ReceivableEntityBase] + attr_reader :entity + # @return [String] Entity bank account ID + attr_reader :entity_bank_account_id + # @return [String] Entity VAT ID id + attr_reader :entity_vat_id_id + # @return [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. +# If omitted or `null`, defaults to the invoice issue date and the value is +# automatically set when the invoice is moved to the `issued` status. + attr_reader :fulfillment_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable + attr_reader :memo + # @return [String] + attr_reader :overdue_reminder_id + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] Link to your invoice's custom payment rails or external payment link. + attr_reader :payment_page_url + # @return [String] + attr_reader :payment_reminder_id + # @return [String] Unique ID of the payment terms. + attr_reader :payment_terms_id + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param contact_id [String] Unique ID of the counterpart contact. + # @param counterpart_billing_address_id [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_id [String] Unique ID of the counterpart. + # @param counterpart_shipping_address_id [String] Address where goods were shipped / where services were provided. + # @param counterpart_vat_id_id [String] Counterpart VAT ID id + # @param currency [Monite::CurrencyEnum] + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param entity [Monite::ReceivableEntityBase] + # @param entity_bank_account_id [String] Entity bank account ID + # @param entity_vat_id_id [String] Entity VAT ID id + # @param fulfillment_date [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. +# If omitted or `null`, defaults to the invoice issue date and the value is +# automatically set when the invoice is moved to the `issued` status. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable + # @param overdue_reminder_id [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_page_url [String] Link to your invoice's custom payment rails or external payment link. + # @param payment_reminder_id [String] + # @param payment_terms_id [String] Unique ID of the payment terms. + # @param project_id [String] A project related to current receivable + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param trade_name [String] Trade name of the entity + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateInvoice] + def initialize(contact_id: OMIT, counterpart_billing_address_id: OMIT, counterpart_id: OMIT, counterpart_shipping_address_id: OMIT, counterpart_vat_id_id: OMIT, currency: OMIT, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, entity: OMIT, entity_bank_account_id: OMIT, entity_vat_id_id: OMIT, fulfillment_date: OMIT, line_items: OMIT, memo: OMIT, overdue_reminder_id: OMIT, partner_metadata: OMIT, payment_page_url: OMIT, payment_reminder_id: OMIT, payment_terms_id: OMIT, project_id: OMIT, tag_ids: OMIT, trade_name: OMIT, vat_exempt: OMIT, vat_exemption_rationale: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @contact_id = contact_id if contact_id != OMIT + @counterpart_billing_address_id = counterpart_billing_address_id if counterpart_billing_address_id != OMIT + @counterpart_id = counterpart_id if counterpart_id != OMIT + @counterpart_shipping_address_id = counterpart_shipping_address_id if counterpart_shipping_address_id != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @currency = currency if currency != OMIT + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @entity = entity if entity != OMIT + @entity_bank_account_id = entity_bank_account_id if entity_bank_account_id != OMIT + @entity_vat_id_id = entity_vat_id_id if entity_vat_id_id != OMIT + @fulfillment_date = fulfillment_date if fulfillment_date != OMIT + @line_items = line_items if line_items != OMIT + @memo = memo if memo != OMIT + @overdue_reminder_id = overdue_reminder_id if overdue_reminder_id != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @payment_page_url = payment_page_url if payment_page_url != OMIT + @payment_reminder_id = payment_reminder_id if payment_reminder_id != OMIT + @payment_terms_id = payment_terms_id if payment_terms_id != OMIT + @project_id = project_id if project_id != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @trade_name = trade_name if trade_name != OMIT + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "contact_id": contact_id, "counterpart_billing_address_id": counterpart_billing_address_id, "counterpart_id": counterpart_id, "counterpart_shipping_address_id": counterpart_shipping_address_id, "counterpart_vat_id_id": counterpart_vat_id_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "entity": entity, "entity_bank_account_id": entity_bank_account_id, "entity_vat_id_id": entity_vat_id_id, "fulfillment_date": fulfillment_date, "line_items": line_items, "memo": memo, "overdue_reminder_id": overdue_reminder_id, "partner_metadata": partner_metadata, "payment_page_url": payment_page_url, "payment_reminder_id": payment_reminder_id, "payment_terms_id": payment_terms_id, "project_id": project_id, "tag_ids": tag_ids, "trade_name": trade_name, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateInvoice + # + # @param json_object [String] + # @return [Monite::UpdateInvoice] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + contact_id = parsed_json["contact_id"] + counterpart_billing_address_id = parsed_json["counterpart_billing_address_id"] + counterpart_id = parsed_json["counterpart_id"] + counterpart_shipping_address_id = parsed_json["counterpart_shipping_address_id"] + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::ReceivableEntityBase.from_json(json_object: entity) + else + entity = nil + end + entity_bank_account_id = parsed_json["entity_bank_account_id"] + entity_vat_id_id = parsed_json["entity_vat_id_id"] + fulfillment_date = parsed_json["fulfillment_date"] + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::LineItemUpdate.from_json(json_object: item) +end + memo = parsed_json["memo"] + overdue_reminder_id = parsed_json["overdue_reminder_id"] + partner_metadata = parsed_json["partner_metadata"] + payment_page_url = parsed_json["payment_page_url"] + payment_reminder_id = parsed_json["payment_reminder_id"] + payment_terms_id = parsed_json["payment_terms_id"] + project_id = parsed_json["project_id"] + tag_ids = parsed_json["tag_ids"] + trade_name = parsed_json["trade_name"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + contact_id: contact_id, + counterpart_billing_address_id: counterpart_billing_address_id, + counterpart_id: counterpart_id, + counterpart_shipping_address_id: counterpart_shipping_address_id, + counterpart_vat_id_id: counterpart_vat_id_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + entity: entity, + entity_bank_account_id: entity_bank_account_id, + entity_vat_id_id: entity_vat_id_id, + fulfillment_date: fulfillment_date, + line_items: line_items, + memo: memo, + overdue_reminder_id: overdue_reminder_id, + partner_metadata: partner_metadata, + payment_page_url: payment_page_url, + payment_reminder_id: payment_reminder_id, + payment_terms_id: payment_terms_id, + project_id: project_id, + tag_ids: tag_ids, + trade_name: trade_name, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of UpdateInvoice to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.contact_id&.is_a?(String) != false || raise("Passed value for field obj.contact_id is not the expected type, validation failed.") + obj.counterpart_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_billing_address_id is not the expected type, validation failed.") + obj.counterpart_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_shipping_address_id is not the expected type, validation failed.") + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.entity.nil? || Monite::ReceivableEntityBase.validate_raw(obj: obj.entity) + obj.entity_bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.entity_bank_account_id is not the expected type, validation failed.") + obj.entity_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.entity_vat_id_id is not the expected type, validation failed.") + obj.fulfillment_date&.is_a?(String) != false || raise("Passed value for field obj.fulfillment_date is not the expected type, validation failed.") + obj.line_items&.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.overdue_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.overdue_reminder_id is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.payment_page_url&.is_a?(String) != false || raise("Passed value for field obj.payment_page_url is not the expected type, validation failed.") + obj.payment_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.payment_reminder_id is not the expected type, validation failed.") + obj.payment_terms_id&.is_a?(String) != false || raise("Passed value for field obj.payment_terms_id is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_invoice_payload.rb b/lib/monite/types/update_invoice_payload.rb new file mode 100644 index 0000000..18569eb --- /dev/null +++ b/lib/monite/types/update_invoice_payload.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "update_invoice" +require "ostruct" +require "json" + +module Monite + class UpdateInvoicePayload + # @return [Monite::UpdateInvoice] + attr_reader :invoice + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param invoice [Monite::UpdateInvoice] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateInvoicePayload] + def initialize(invoice:, additional_properties: nil) + @invoice = invoice + @additional_properties = additional_properties + @_field_set = { "invoice": invoice } + end +# Deserialize a JSON object to an instance of UpdateInvoicePayload + # + # @param json_object [String] + # @return [Monite::UpdateInvoicePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["invoice"].nil? + invoice = parsed_json["invoice"].to_json + invoice = Monite::UpdateInvoice.from_json(json_object: invoice) + else + invoice = nil + end + new(invoice: invoice, additional_properties: struct) + end +# Serialize an instance of UpdateInvoicePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::UpdateInvoice.validate_raw(obj: obj.invoice) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_issued_invoice.rb b/lib/monite/types/update_issued_invoice.rb new file mode 100644 index 0000000..0ce6ab3 --- /dev/null +++ b/lib/monite/types/update_issued_invoice.rb @@ -0,0 +1,161 @@ +# frozen_string_literal: true +require_relative "update_issued_invoice_entity" +require_relative "receivable_entity_address_schema" +require "ostruct" +require "json" + +module Monite + class UpdateIssuedInvoice + # @return [String] Unique ID of the counterpart contact. + attr_reader :contact_id + # @return [String] Id of a new or updated counterpart + attr_reader :counterpart_id + # @return [String] Counterpart VAT ID id + attr_reader :counterpart_vat_id_id + # @return [Monite::UpdateIssuedInvoiceEntity] + attr_reader :entity + # @return [Monite::ReceivableEntityAddressSchema] + attr_reader :entity_address + # @return [String] Entity VAT ID id + attr_reader :entity_vat_id_id + # @return [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. + attr_reader :fulfillment_date + # @return [String] A note with additional information for a receivable + attr_reader :memo + # @return [String] + attr_reader :overdue_reminder_id + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] + attr_reader :payment_reminder_id + # @return [String] + attr_reader :payment_terms_id + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param contact_id [String] Unique ID of the counterpart contact. + # @param counterpart_id [String] Id of a new or updated counterpart + # @param counterpart_vat_id_id [String] Counterpart VAT ID id + # @param entity [Monite::UpdateIssuedInvoiceEntity] + # @param entity_address [Monite::ReceivableEntityAddressSchema] + # @param entity_vat_id_id [String] Entity VAT ID id + # @param fulfillment_date [String] The date when the goods are shipped or the service is provided. Can be a +# current, past, or future date. + # @param memo [String] A note with additional information for a receivable + # @param overdue_reminder_id [String] + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_reminder_id [String] + # @param payment_terms_id [String] + # @param project_id [String] A project related to current receivable + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateIssuedInvoice] + def initialize(contact_id: OMIT, counterpart_id: OMIT, counterpart_vat_id_id: OMIT, entity: OMIT, entity_address: OMIT, entity_vat_id_id: OMIT, fulfillment_date: OMIT, memo: OMIT, overdue_reminder_id: OMIT, partner_metadata: OMIT, payment_reminder_id: OMIT, payment_terms_id: OMIT, project_id: OMIT, tag_ids: OMIT, additional_properties: nil) + @contact_id = contact_id if contact_id != OMIT + @counterpart_id = counterpart_id if counterpart_id != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @entity = entity if entity != OMIT + @entity_address = entity_address if entity_address != OMIT + @entity_vat_id_id = entity_vat_id_id if entity_vat_id_id != OMIT + @fulfillment_date = fulfillment_date if fulfillment_date != OMIT + @memo = memo if memo != OMIT + @overdue_reminder_id = overdue_reminder_id if overdue_reminder_id != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @payment_reminder_id = payment_reminder_id if payment_reminder_id != OMIT + @payment_terms_id = payment_terms_id if payment_terms_id != OMIT + @project_id = project_id if project_id != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @additional_properties = additional_properties + @_field_set = { "contact_id": contact_id, "counterpart_id": counterpart_id, "counterpart_vat_id_id": counterpart_vat_id_id, "entity": entity, "entity_address": entity_address, "entity_vat_id_id": entity_vat_id_id, "fulfillment_date": fulfillment_date, "memo": memo, "overdue_reminder_id": overdue_reminder_id, "partner_metadata": partner_metadata, "payment_reminder_id": payment_reminder_id, "payment_terms_id": payment_terms_id, "project_id": project_id, "tag_ids": tag_ids }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateIssuedInvoice + # + # @param json_object [String] + # @return [Monite::UpdateIssuedInvoice] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + contact_id = parsed_json["contact_id"] + counterpart_id = parsed_json["counterpart_id"] + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::UpdateIssuedInvoiceEntity.from_json(json_object: entity) + else + entity = nil + end + unless parsed_json["entity_address"].nil? + entity_address = parsed_json["entity_address"].to_json + entity_address = Monite::ReceivableEntityAddressSchema.from_json(json_object: entity_address) + else + entity_address = nil + end + entity_vat_id_id = parsed_json["entity_vat_id_id"] + fulfillment_date = parsed_json["fulfillment_date"] + memo = parsed_json["memo"] + overdue_reminder_id = parsed_json["overdue_reminder_id"] + partner_metadata = parsed_json["partner_metadata"] + payment_reminder_id = parsed_json["payment_reminder_id"] + payment_terms_id = parsed_json["payment_terms_id"] + project_id = parsed_json["project_id"] + tag_ids = parsed_json["tag_ids"] + new( + contact_id: contact_id, + counterpart_id: counterpart_id, + counterpart_vat_id_id: counterpart_vat_id_id, + entity: entity, + entity_address: entity_address, + entity_vat_id_id: entity_vat_id_id, + fulfillment_date: fulfillment_date, + memo: memo, + overdue_reminder_id: overdue_reminder_id, + partner_metadata: partner_metadata, + payment_reminder_id: payment_reminder_id, + payment_terms_id: payment_terms_id, + project_id: project_id, + tag_ids: tag_ids, + additional_properties: struct + ) + end +# Serialize an instance of UpdateIssuedInvoice to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.contact_id&.is_a?(String) != false || raise("Passed value for field obj.contact_id is not the expected type, validation failed.") + obj.counterpart_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.entity.nil? || Monite::UpdateIssuedInvoiceEntity.validate_raw(obj: obj.entity) + obj.entity_address.nil? || Monite::ReceivableEntityAddressSchema.validate_raw(obj: obj.entity_address) + obj.entity_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.entity_vat_id_id is not the expected type, validation failed.") + obj.fulfillment_date&.is_a?(String) != false || raise("Passed value for field obj.fulfillment_date is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.overdue_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.overdue_reminder_id is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.payment_reminder_id&.is_a?(String) != false || raise("Passed value for field obj.payment_reminder_id is not the expected type, validation failed.") + obj.payment_terms_id&.is_a?(String) != false || raise("Passed value for field obj.payment_terms_id is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_issued_invoice_entity.rb b/lib/monite/types/update_issued_invoice_entity.rb new file mode 100644 index 0000000..91fb0ce --- /dev/null +++ b/lib/monite/types/update_issued_invoice_entity.rb @@ -0,0 +1,87 @@ +# frozen_string_literal: true +require "json" +require_relative "receivable_entity_organization_request" +require_relative "receivable_entity_individual_request" + +module Monite + class UpdateIssuedInvoiceEntity + # @return [Object] + attr_reader :member + # @return [String] + attr_reader :discriminant + + private_class_method :new + alias kind_of? is_a? + + # @param member [Object] + # @param discriminant [String] + # @return [Monite::UpdateIssuedInvoiceEntity] + def initialize(member:, discriminant:) + @member = member + @discriminant = discriminant + end +# Deserialize a JSON object to an instance of UpdateIssuedInvoiceEntity + # + # @param json_object [String] + # @return [Monite::UpdateIssuedInvoiceEntity] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + case struct.type + when "organization" + member = Monite::ReceivableEntityOrganizationRequest.from_json(json_object: json_object) + when "individual" + member = Monite::ReceivableEntityIndividualRequest.from_json(json_object: json_object) + else + member = Monite::ReceivableEntityOrganizationRequest.from_json(json_object: json_object) + end + new(member: member, discriminant: struct.type) + end +# For Union Types, to_json functionality is delegated to the wrapped member. + # + # @return [String] + def to_json + case @discriminant + when "organization" + { **@member.to_json, type: @discriminant }.to_json + when "individual" + { **@member.to_json, type: @discriminant }.to_json + else + { "type": @discriminant, value: @member }.to_json + end + @member.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + case obj.type + when "organization" + Monite::ReceivableEntityOrganizationRequest.validate_raw(obj: obj) + when "individual" + Monite::ReceivableEntityIndividualRequest.validate_raw(obj: obj) + else + raise("Passed value matched no type within the union, validation failed.") + end + end +# For Union Types, is_a? functionality is delegated to the wrapped member. + # + # @param obj [Object] + # @return [Boolean] + def is_a?(obj) + @member.is_a?(obj) + end + # @param member [Monite::ReceivableEntityOrganizationRequest] + # @return [Monite::UpdateIssuedInvoiceEntity] + def self.organization(member:) + new(member: member, discriminant: "organization") + end + # @param member [Monite::ReceivableEntityIndividualRequest] + # @return [Monite::UpdateIssuedInvoiceEntity] + def self.individual(member:) + new(member: member, discriminant: "individual") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_issued_invoice_payload.rb b/lib/monite/types/update_issued_invoice_payload.rb new file mode 100644 index 0000000..a0cfc8f --- /dev/null +++ b/lib/monite/types/update_issued_invoice_payload.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "update_issued_invoice" +require "ostruct" +require "json" + +module Monite + class UpdateIssuedInvoicePayload + # @return [Monite::UpdateIssuedInvoice] + attr_reader :issued_invoice + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param issued_invoice [Monite::UpdateIssuedInvoice] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateIssuedInvoicePayload] + def initialize(issued_invoice:, additional_properties: nil) + @issued_invoice = issued_invoice + @additional_properties = additional_properties + @_field_set = { "issued_invoice": issued_invoice } + end +# Deserialize a JSON object to an instance of UpdateIssuedInvoicePayload + # + # @param json_object [String] + # @return [Monite::UpdateIssuedInvoicePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["issued_invoice"].nil? + issued_invoice = parsed_json["issued_invoice"].to_json + issued_invoice = Monite::UpdateIssuedInvoice.from_json(json_object: issued_invoice) + else + issued_invoice = nil + end + new(issued_invoice: issued_invoice, additional_properties: struct) + end +# Serialize an instance of UpdateIssuedInvoicePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::UpdateIssuedInvoice.validate_raw(obj: obj.issued_invoice) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_line_item_for_credit_note.rb b/lib/monite/types/update_line_item_for_credit_note.rb new file mode 100644 index 0000000..d3871ec --- /dev/null +++ b/lib/monite/types/update_line_item_for_credit_note.rb @@ -0,0 +1,5 @@ +# frozen_string_literal: true + +module Monite + UPDATE_LINE_ITEM_FOR_CREDIT_NOTE = Hash +end \ No newline at end of file diff --git a/lib/monite/types/update_product_for_credit_note.rb b/lib/monite/types/update_product_for_credit_note.rb new file mode 100644 index 0000000..09c676b --- /dev/null +++ b/lib/monite/types/update_product_for_credit_note.rb @@ -0,0 +1,74 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class UpdateProductForCreditNote + # @return [Integer] The old price of the line item. Used to choose for which line item new price +# should be applied + attr_reader :old_price + # @return [Integer] The price diff of the line item, i.e. applied discount + attr_reader :price_diff + # @return [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + attr_reader :quantity + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param old_price [Integer] The old price of the line item. Used to choose for which line item new price +# should be applied + # @param price_diff [Integer] The price diff of the line item, i.e. applied discount + # @param quantity [Float] The quantity of each of the goods, materials, or services listed in the +# receivable. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateProductForCreditNote] + def initialize(old_price: OMIT, price_diff: OMIT, quantity:, additional_properties: nil) + @old_price = old_price if old_price != OMIT + @price_diff = price_diff if price_diff != OMIT + @quantity = quantity + @additional_properties = additional_properties + @_field_set = { "old_price": old_price, "price_diff": price_diff, "quantity": quantity }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateProductForCreditNote + # + # @param json_object [String] + # @return [Monite::UpdateProductForCreditNote] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + old_price = parsed_json["old_price"] + price_diff = parsed_json["price_diff"] + quantity = parsed_json["quantity"] + new( + old_price: old_price, + price_diff: price_diff, + quantity: quantity, + additional_properties: struct + ) + end +# Serialize an instance of UpdateProductForCreditNote to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.old_price&.is_a?(Integer) != false || raise("Passed value for field obj.old_price is not the expected type, validation failed.") + obj.price_diff&.is_a?(Integer) != false || raise("Passed value for field obj.price_diff is not the expected type, validation failed.") + obj.quantity.is_a?(Float) != false || raise("Passed value for field obj.quantity is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_quote.rb b/lib/monite/types/update_quote.rb new file mode 100644 index 0000000..c9da349 --- /dev/null +++ b/lib/monite/types/update_quote.rb @@ -0,0 +1,245 @@ +# frozen_string_literal: true +require_relative "currency_enum" +require_relative "discount" +require_relative "receivable_entity_base" +require_relative "line_item_update" +require "ostruct" +require "json" + +module Monite + class UpdateQuote + # @return [String] Unique ID of the counterpart contact. + attr_reader :contact_id + # @return [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + attr_reader :counterpart_billing_address_id + # @return [String] Unique ID of the counterpart. + attr_reader :counterpart_id + # @return [String] Address where goods were shipped / where services were provided. + attr_reader :counterpart_shipping_address_id + # @return [String] Counterpart VAT ID id + attr_reader :counterpart_vat_id_id + # @return [Monite::CurrencyEnum] + attr_reader :currency + # @return [Integer] The amount of tax deducted in minor units + attr_reader :deduction_amount + # @return [String] A note with additional information about a tax deduction + attr_reader :deduction_memo + # @return [Monite::Discount] The discount for a receivable. + attr_reader :discount + # @return [Monite::ReceivableEntityBase] + attr_reader :entity + # @return [String] Entity bank account ID + attr_reader :entity_bank_account_id + # @return [String] Entity VAT ID id + attr_reader :entity_vat_id_id + # @return [String] The date (in ISO 8601 format) until which the quote is valid. + attr_reader :expiry_date + # @return [Array] + attr_reader :line_items + # @return [String] A note with additional information for a receivable + attr_reader :memo + # @return [Hash{String => Object}] Metadata for partner needs + attr_reader :partner_metadata + # @return [String] Unique ID of the payment terms. + attr_reader :payment_terms_id + # @return [String] A project related to current receivable + attr_reader :project_id + # @return [String] Link for custom quote accept page + attr_reader :quote_accept_page_url + # @return [Boolean] Whether acceptance a quote requires a signature. + attr_reader :signature_required + # @return [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + attr_reader :tag_ids + # @return [String] Trade name of the entity + attr_reader :trade_name + # @return [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + attr_reader :vat_exempt + # @return [String] The reason for the VAT exemption, if applicable. + attr_reader :vat_exemption_rationale + # @return [Integer] The amount of tax withheld in percent minor units + attr_reader :withholding_tax_rate + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param contact_id [String] Unique ID of the counterpart contact. + # @param counterpart_billing_address_id [String] Address of invoicing, need to state as a separate fields for some countries if +# it differs from address of a company. + # @param counterpart_id [String] Unique ID of the counterpart. + # @param counterpart_shipping_address_id [String] Address where goods were shipped / where services were provided. + # @param counterpart_vat_id_id [String] Counterpart VAT ID id + # @param currency [Monite::CurrencyEnum] + # @param deduction_amount [Integer] The amount of tax deducted in minor units + # @param deduction_memo [String] A note with additional information about a tax deduction + # @param discount [Monite::Discount] The discount for a receivable. + # @param entity [Monite::ReceivableEntityBase] + # @param entity_bank_account_id [String] Entity bank account ID + # @param entity_vat_id_id [String] Entity VAT ID id + # @param expiry_date [String] The date (in ISO 8601 format) until which the quote is valid. + # @param line_items [Array] + # @param memo [String] A note with additional information for a receivable + # @param partner_metadata [Hash{String => Object}] Metadata for partner needs + # @param payment_terms_id [String] Unique ID of the payment terms. + # @param project_id [String] A project related to current receivable + # @param quote_accept_page_url [String] Link for custom quote accept page + # @param signature_required [Boolean] Whether acceptance a quote requires a signature. + # @param tag_ids [Array] A list of IDs of user-defined tags (labels) assigned to this receivable. + # @param trade_name [String] Trade name of the entity + # @param vat_exempt [Boolean] Indicates whether the goods, materials, or services listed in the receivable are +# exempt from VAT or not. + # @param vat_exemption_rationale [String] The reason for the VAT exemption, if applicable. + # @param withholding_tax_rate [Integer] The amount of tax withheld in percent minor units + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateQuote] + def initialize(contact_id: OMIT, counterpart_billing_address_id: OMIT, counterpart_id: OMIT, counterpart_shipping_address_id: OMIT, counterpart_vat_id_id: OMIT, currency: OMIT, deduction_amount: OMIT, deduction_memo: OMIT, discount: OMIT, entity: OMIT, entity_bank_account_id: OMIT, entity_vat_id_id: OMIT, expiry_date: OMIT, line_items: OMIT, memo: OMIT, partner_metadata: OMIT, payment_terms_id: OMIT, project_id: OMIT, quote_accept_page_url: OMIT, signature_required: OMIT, tag_ids: OMIT, trade_name: OMIT, vat_exempt: OMIT, vat_exemption_rationale: OMIT, withholding_tax_rate: OMIT, additional_properties: nil) + @contact_id = contact_id if contact_id != OMIT + @counterpart_billing_address_id = counterpart_billing_address_id if counterpart_billing_address_id != OMIT + @counterpart_id = counterpart_id if counterpart_id != OMIT + @counterpart_shipping_address_id = counterpart_shipping_address_id if counterpart_shipping_address_id != OMIT + @counterpart_vat_id_id = counterpart_vat_id_id if counterpart_vat_id_id != OMIT + @currency = currency if currency != OMIT + @deduction_amount = deduction_amount if deduction_amount != OMIT + @deduction_memo = deduction_memo if deduction_memo != OMIT + @discount = discount if discount != OMIT + @entity = entity if entity != OMIT + @entity_bank_account_id = entity_bank_account_id if entity_bank_account_id != OMIT + @entity_vat_id_id = entity_vat_id_id if entity_vat_id_id != OMIT + @expiry_date = expiry_date if expiry_date != OMIT + @line_items = line_items if line_items != OMIT + @memo = memo if memo != OMIT + @partner_metadata = partner_metadata if partner_metadata != OMIT + @payment_terms_id = payment_terms_id if payment_terms_id != OMIT + @project_id = project_id if project_id != OMIT + @quote_accept_page_url = quote_accept_page_url if quote_accept_page_url != OMIT + @signature_required = signature_required if signature_required != OMIT + @tag_ids = tag_ids if tag_ids != OMIT + @trade_name = trade_name if trade_name != OMIT + @vat_exempt = vat_exempt if vat_exempt != OMIT + @vat_exemption_rationale = vat_exemption_rationale if vat_exemption_rationale != OMIT + @withholding_tax_rate = withholding_tax_rate if withholding_tax_rate != OMIT + @additional_properties = additional_properties + @_field_set = { "contact_id": contact_id, "counterpart_billing_address_id": counterpart_billing_address_id, "counterpart_id": counterpart_id, "counterpart_shipping_address_id": counterpart_shipping_address_id, "counterpart_vat_id_id": counterpart_vat_id_id, "currency": currency, "deduction_amount": deduction_amount, "deduction_memo": deduction_memo, "discount": discount, "entity": entity, "entity_bank_account_id": entity_bank_account_id, "entity_vat_id_id": entity_vat_id_id, "expiry_date": expiry_date, "line_items": line_items, "memo": memo, "partner_metadata": partner_metadata, "payment_terms_id": payment_terms_id, "project_id": project_id, "quote_accept_page_url": quote_accept_page_url, "signature_required": signature_required, "tag_ids": tag_ids, "trade_name": trade_name, "vat_exempt": vat_exempt, "vat_exemption_rationale": vat_exemption_rationale, "withholding_tax_rate": withholding_tax_rate }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of UpdateQuote + # + # @param json_object [String] + # @return [Monite::UpdateQuote] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + contact_id = parsed_json["contact_id"] + counterpart_billing_address_id = parsed_json["counterpart_billing_address_id"] + counterpart_id = parsed_json["counterpart_id"] + counterpart_shipping_address_id = parsed_json["counterpart_shipping_address_id"] + counterpart_vat_id_id = parsed_json["counterpart_vat_id_id"] + currency = parsed_json["currency"] + deduction_amount = parsed_json["deduction_amount"] + deduction_memo = parsed_json["deduction_memo"] + unless parsed_json["discount"].nil? + discount = parsed_json["discount"].to_json + discount = Monite::Discount.from_json(json_object: discount) + else + discount = nil + end + unless parsed_json["entity"].nil? + entity = parsed_json["entity"].to_json + entity = Monite::ReceivableEntityBase.from_json(json_object: entity) + else + entity = nil + end + entity_bank_account_id = parsed_json["entity_bank_account_id"] + entity_vat_id_id = parsed_json["entity_vat_id_id"] + expiry_date = parsed_json["expiry_date"] + line_items = parsed_json["line_items"]&.map do | item | + item = item.to_json + Monite::LineItemUpdate.from_json(json_object: item) +end + memo = parsed_json["memo"] + partner_metadata = parsed_json["partner_metadata"] + payment_terms_id = parsed_json["payment_terms_id"] + project_id = parsed_json["project_id"] + quote_accept_page_url = parsed_json["quote_accept_page_url"] + signature_required = parsed_json["signature_required"] + tag_ids = parsed_json["tag_ids"] + trade_name = parsed_json["trade_name"] + vat_exempt = parsed_json["vat_exempt"] + vat_exemption_rationale = parsed_json["vat_exemption_rationale"] + withholding_tax_rate = parsed_json["withholding_tax_rate"] + new( + contact_id: contact_id, + counterpart_billing_address_id: counterpart_billing_address_id, + counterpart_id: counterpart_id, + counterpart_shipping_address_id: counterpart_shipping_address_id, + counterpart_vat_id_id: counterpart_vat_id_id, + currency: currency, + deduction_amount: deduction_amount, + deduction_memo: deduction_memo, + discount: discount, + entity: entity, + entity_bank_account_id: entity_bank_account_id, + entity_vat_id_id: entity_vat_id_id, + expiry_date: expiry_date, + line_items: line_items, + memo: memo, + partner_metadata: partner_metadata, + payment_terms_id: payment_terms_id, + project_id: project_id, + quote_accept_page_url: quote_accept_page_url, + signature_required: signature_required, + tag_ids: tag_ids, + trade_name: trade_name, + vat_exempt: vat_exempt, + vat_exemption_rationale: vat_exemption_rationale, + withholding_tax_rate: withholding_tax_rate, + additional_properties: struct + ) + end +# Serialize an instance of UpdateQuote to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.contact_id&.is_a?(String) != false || raise("Passed value for field obj.contact_id is not the expected type, validation failed.") + obj.counterpart_billing_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_billing_address_id is not the expected type, validation failed.") + obj.counterpart_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_id is not the expected type, validation failed.") + obj.counterpart_shipping_address_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_shipping_address_id is not the expected type, validation failed.") + obj.counterpart_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.counterpart_vat_id_id is not the expected type, validation failed.") + obj.currency&.is_a?(Monite::CurrencyEnum) != false || raise("Passed value for field obj.currency is not the expected type, validation failed.") + obj.deduction_amount&.is_a?(Integer) != false || raise("Passed value for field obj.deduction_amount is not the expected type, validation failed.") + obj.deduction_memo&.is_a?(String) != false || raise("Passed value for field obj.deduction_memo is not the expected type, validation failed.") + obj.discount.nil? || Monite::Discount.validate_raw(obj: obj.discount) + obj.entity.nil? || Monite::ReceivableEntityBase.validate_raw(obj: obj.entity) + obj.entity_bank_account_id&.is_a?(String) != false || raise("Passed value for field obj.entity_bank_account_id is not the expected type, validation failed.") + obj.entity_vat_id_id&.is_a?(String) != false || raise("Passed value for field obj.entity_vat_id_id is not the expected type, validation failed.") + obj.expiry_date&.is_a?(String) != false || raise("Passed value for field obj.expiry_date is not the expected type, validation failed.") + obj.line_items&.is_a?(Array) != false || raise("Passed value for field obj.line_items is not the expected type, validation failed.") + obj.memo&.is_a?(String) != false || raise("Passed value for field obj.memo is not the expected type, validation failed.") + obj.partner_metadata&.is_a?(Hash) != false || raise("Passed value for field obj.partner_metadata is not the expected type, validation failed.") + obj.payment_terms_id&.is_a?(String) != false || raise("Passed value for field obj.payment_terms_id is not the expected type, validation failed.") + obj.project_id&.is_a?(String) != false || raise("Passed value for field obj.project_id is not the expected type, validation failed.") + obj.quote_accept_page_url&.is_a?(String) != false || raise("Passed value for field obj.quote_accept_page_url is not the expected type, validation failed.") + obj.signature_required&.is_a?(Boolean) != false || raise("Passed value for field obj.signature_required is not the expected type, validation failed.") + obj.tag_ids&.is_a?(Array) != false || raise("Passed value for field obj.tag_ids is not the expected type, validation failed.") + obj.trade_name&.is_a?(String) != false || raise("Passed value for field obj.trade_name is not the expected type, validation failed.") + obj.vat_exempt&.is_a?(Boolean) != false || raise("Passed value for field obj.vat_exempt is not the expected type, validation failed.") + obj.vat_exemption_rationale&.is_a?(String) != false || raise("Passed value for field obj.vat_exemption_rationale is not the expected type, validation failed.") + obj.withholding_tax_rate&.is_a?(Integer) != false || raise("Passed value for field obj.withholding_tax_rate is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/update_quote_payload.rb b/lib/monite/types/update_quote_payload.rb new file mode 100644 index 0000000..717cc0f --- /dev/null +++ b/lib/monite/types/update_quote_payload.rb @@ -0,0 +1,57 @@ +# frozen_string_literal: true +require_relative "update_quote" +require "ostruct" +require "json" + +module Monite + class UpdateQuotePayload + # @return [Monite::UpdateQuote] + attr_reader :quote + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param quote [Monite::UpdateQuote] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::UpdateQuotePayload] + def initialize(quote:, additional_properties: nil) + @quote = quote + @additional_properties = additional_properties + @_field_set = { "quote": quote } + end +# Deserialize a JSON object to an instance of UpdateQuotePayload + # + # @param json_object [String] + # @return [Monite::UpdateQuotePayload] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["quote"].nil? + quote = parsed_json["quote"].to_json + quote = Monite::UpdateQuote.from_json(json_object: quote) + else + quote = nil + end + new(quote: quote, additional_properties: struct) + end +# Serialize an instance of UpdateQuotePayload to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::UpdateQuote.validate_raw(obj: obj.quote) + end + end +end \ No newline at end of file diff --git a/lib/monite/types/validation_error.rb b/lib/monite/types/validation_error.rb new file mode 100644 index 0000000..149b2d4 --- /dev/null +++ b/lib/monite/types/validation_error.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true +require_relative "validation_error_loc_item" +require "ostruct" +require "json" + +module Monite + class ValidationError + # @return [Array] + attr_reader :loc + # @return [String] + attr_reader :msg + # @return [String] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param loc [Array] + # @param msg [String] + # @param type [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::ValidationError] + def initialize(loc:, msg:, type:, additional_properties: nil) + @loc = loc + @msg = msg + @type = type + @additional_properties = additional_properties + @_field_set = { "loc": loc, "msg": msg, "type": type } + end +# Deserialize a JSON object to an instance of ValidationError + # + # @param json_object [String] + # @return [Monite::ValidationError] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + loc = parsed_json["loc"]&.map do | item | + item = item.to_json + Monite::ValidationErrorLocItem.from_json(json_object: item) +end + msg = parsed_json["msg"] + type = parsed_json["type"] + new( + loc: loc, + msg: msg, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of ValidationError to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.loc.is_a?(Array) != false || raise("Passed value for field obj.loc is not the expected type, validation failed.") + obj.msg.is_a?(String) != false || raise("Passed value for field obj.msg is not the expected type, validation failed.") + obj.type.is_a?(String) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/validation_error_loc_item.rb b/lib/monite/types/validation_error_loc_item.rb new file mode 100644 index 0000000..5588d55 --- /dev/null +++ b/lib/monite/types/validation_error_loc_item.rb @@ -0,0 +1,56 @@ +# frozen_string_literal: true +require "json" + +module Monite + class ValidationErrorLocItem + + +# Deserialize a JSON object to an instance of ValidationErrorLocItem + # + # @param json_object [String] + # @return [Monite::ValidationErrorLocItem] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + begin + struct.is_a?(String) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + begin + struct.is_a?(Integer) != false || raise("Passed value for field struct is not the expected type, validation failed.") + unless struct.nil? + return struct +else + return nil +end + rescue StandardError + # noop + end + return struct + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + begin + return obj.is_a?(String) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + begin + return obj.is_a?(Integer) != false || raise("Passed value for field obj is not the expected type, validation failed.") + rescue StandardError + # noop + end + raise("Passed value matched no type within the union, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/variable.rb b/lib/monite/types/variable.rb new file mode 100644 index 0000000..0164c60 --- /dev/null +++ b/lib/monite/types/variable.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class Variable + # @return [String] + attr_reader :description + # @return [String] + attr_reader :name + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param description [String] + # @param name [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::Variable] + def initialize(description:, name:, additional_properties: nil) + @description = description + @name = name + @additional_properties = additional_properties + @_field_set = { "description": description, "name": name } + end +# Deserialize a JSON object to an instance of Variable + # + # @param json_object [String] + # @return [Monite::Variable] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + description = parsed_json["description"] + name = parsed_json["name"] + new( + description: description, + name: name, + additional_properties: struct + ) + end +# Serialize an instance of Variable to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.description.is_a?(String) != false || raise("Passed value for field obj.description is not the expected type, validation failed.") + obj.name.is_a?(String) != false || raise("Passed value for field obj.name is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/variables_object.rb b/lib/monite/types/variables_object.rb new file mode 100644 index 0000000..d20194e --- /dev/null +++ b/lib/monite/types/variables_object.rb @@ -0,0 +1,73 @@ +# frozen_string_literal: true +require_relative "document_type_enum" +require_relative "variable" +require "ostruct" +require "json" + +module Monite + class VariablesObject + # @return [Monite::DocumentTypeEnum] + attr_reader :object_subtype + # @return [String] + attr_reader :object_type + # @return [Array] + attr_reader :variables + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param object_subtype [Monite::DocumentTypeEnum] + # @param object_type [String] + # @param variables [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VariablesObject] + def initialize(object_subtype:, object_type:, variables:, additional_properties: nil) + @object_subtype = object_subtype + @object_type = object_type + @variables = variables + @additional_properties = additional_properties + @_field_set = { "object_subtype": object_subtype, "object_type": object_type, "variables": variables } + end +# Deserialize a JSON object to an instance of VariablesObject + # + # @param json_object [String] + # @return [Monite::VariablesObject] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + object_subtype = parsed_json["object_subtype"] + object_type = parsed_json["object_type"] + variables = parsed_json["variables"]&.map do | item | + item = item.to_json + Monite::Variable.from_json(json_object: item) +end + new( + object_subtype: object_subtype, + object_type: object_type, + variables: variables, + additional_properties: struct + ) + end +# Serialize an instance of VariablesObject to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.object_subtype.is_a?(Monite::DocumentTypeEnum) != false || raise("Passed value for field obj.object_subtype is not the expected type, validation failed.") + obj.object_type.is_a?(String) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.variables.is_a?(Array) != false || raise("Passed value for field obj.variables is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/variables_object_list.rb b/lib/monite/types/variables_object_list.rb new file mode 100644 index 0000000..4a20238 --- /dev/null +++ b/lib/monite/types/variables_object_list.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "variables_object" +require "ostruct" +require "json" + +module Monite + class VariablesObjectList + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VariablesObjectList] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of VariablesObjectList + # + # @param json_object [String] + # @return [Monite::VariablesObjectList] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::VariablesObject.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of VariablesObjectList to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/variables_type.rb b/lib/monite/types/variables_type.rb new file mode 100644 index 0000000..5aa834b --- /dev/null +++ b/lib/monite/types/variables_type.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite + class VariablesType + + QUOTE = "quote" + INVOICE = "invoice" + CREDIT_NOTE = "credit_note" + DISCOUNT_REMINDER = "discount_reminder" + FINAL_REMINDER = "final_reminder" + OVERDUE_REMINDER = "overdue_reminder" + + end +end \ No newline at end of file diff --git a/lib/monite/types/vat_id_type_enum.rb b/lib/monite/types/vat_id_type_enum.rb new file mode 100644 index 0000000..4e89154 --- /dev/null +++ b/lib/monite/types/vat_id_type_enum.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true + +module Monite + class VatIdTypeEnum + + AE_TRN = "ae_trn" + AU_ABN = "au_abn" + AU_ARN = "au_arn" + BG_UIC = "bg_uic" + BR_CNPJ = "br_cnpj" + BR_CPF = "br_cpf" + CA_BN = "ca_bn" + CA_GST_HST = "ca_gst_hst" + CA_PST_BC = "ca_pst_bc" + CA_PST_MB = "ca_pst_mb" + CA_PST_SK = "ca_pst_sk" + CA_QST = "ca_qst" + CH_VAT = "ch_vat" + CL_TIN = "cl_tin" + ES_CIF = "es_cif" + EU_OSS_VAT = "eu_oss_vat" + EU_VAT = "eu_vat" + GB_VAT = "gb_vat" + GE_VAT = "ge_vat" + HK_BR = "hk_br" + HU_TIN = "hu_tin" + ID_NPWP = "id_npwp" + IL_VAT = "il_vat" + IN_GST = "in_gst" + IS_VAT = "is_vat" + JP_CN = "jp_cn" + JP_RN = "jp_rn" + KR_BRN = "kr_brn" + LI_UID = "li_uid" + MX_RFC = "mx_rfc" + MY_FRP = "my_frp" + MY_ITN = "my_itn" + MY_SST = "my_sst" + NO_VAT = "no_vat" + NZ_GST = "nz_gst" + RU_INN = "ru_inn" + RU_KPP = "ru_kpp" + SA_VAT = "sa_vat" + SG_GST = "sg_gst" + SG_UEN = "sg_uen" + SI_TIN = "si_tin" + TH_VAT = "th_vat" + TW_VAT = "tw_vat" + UA_VAT = "ua_vat" + US_EIN = "us_ein" + ZA_VAT = "za_vat" + UNKNOWN = "unknown" + + end +end \ No newline at end of file diff --git a/lib/monite/types/vat_mode_enum.rb b/lib/monite/types/vat_mode_enum.rb new file mode 100644 index 0000000..2f831de --- /dev/null +++ b/lib/monite/types/vat_mode_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class VatModeEnum + + EXCLUSIVE = "exclusive" + INCLUSIVE = "inclusive" + + end +end \ No newline at end of file diff --git a/lib/monite/types/vat_rate_creator.rb b/lib/monite/types/vat_rate_creator.rb new file mode 100644 index 0000000..af20c7d --- /dev/null +++ b/lib/monite/types/vat_rate_creator.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class VatRateCreator + + MONITE = "monite" + ACCOUNTING = "accounting" + + end +end \ No newline at end of file diff --git a/lib/monite/types/vat_rate_list_response.rb b/lib/monite/types/vat_rate_list_response.rb new file mode 100644 index 0000000..185661a --- /dev/null +++ b/lib/monite/types/vat_rate_list_response.rb @@ -0,0 +1,55 @@ +# frozen_string_literal: true +require_relative "vat_rate_response" +require "ostruct" +require "json" + +module Monite + class VatRateListResponse + # @return [Array] + attr_reader :data + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VatRateListResponse] + def initialize(data:, additional_properties: nil) + @data = data + @additional_properties = additional_properties + @_field_set = { "data": data } + end +# Deserialize a JSON object to an instance of VatRateListResponse + # + # @param json_object [String] + # @return [Monite::VatRateListResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::VatRateResponse.from_json(json_object: item) +end + new(data: data, additional_properties: struct) + end +# Serialize an instance of VatRateListResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/vat_rate_response.rb b/lib/monite/types/vat_rate_response.rb new file mode 100644 index 0000000..0a0387c --- /dev/null +++ b/lib/monite/types/vat_rate_response.rb @@ -0,0 +1,127 @@ +# frozen_string_literal: true +require "date" +require "date" +require_relative "allowed_countries" +require_relative "vat_rate_creator" +require_relative "vat_rate_status_enum" +require "ostruct" +require "json" + +module Monite + class VatRateResponse + # @return [String] Unique identifier of the vat rate object. + attr_reader :id + # @return [DateTime] Date/time when this rate was recorded in the table. + attr_reader :created_at + # @return [DateTime] Date/time when this rate was updated in the table. + attr_reader :updated_at + # @return [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + attr_reader :country + # @return [Monite::VatRateCreator] By whom this rate was recorded: monite employee | accounting system. + attr_reader :created_by + # @return [Monite::VatRateStatusEnum] Status for this vat rate: active | inactive. + attr_reader :status + # @return [String] Date starting from when this rate can be used. + attr_reader :valid_from + # @return [String] Date when this rate was depreciated, after this date rate cannot be used. + attr_reader :valid_until + # @return [Integer] Percent minor units. Example: 12.5% is 1250. + attr_reader :value + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Unique identifier of the vat rate object. + # @param created_at [DateTime] Date/time when this rate was recorded in the table. + # @param updated_at [DateTime] Date/time when this rate was updated in the table. + # @param country [Monite::AllowedCountries] Two-letter ISO country code ([ISO 3166-1 +# alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)). + # @param created_by [Monite::VatRateCreator] By whom this rate was recorded: monite employee | accounting system. + # @param status [Monite::VatRateStatusEnum] Status for this vat rate: active | inactive. + # @param valid_from [String] Date starting from when this rate can be used. + # @param valid_until [String] Date when this rate was depreciated, after this date rate cannot be used. + # @param value [Integer] Percent minor units. Example: 12.5% is 1250. + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VatRateResponse] + def initialize(id:, created_at:, updated_at:, country:, created_by: OMIT, status: OMIT, valid_from: OMIT, valid_until: OMIT, value:, additional_properties: nil) + @id = id + @created_at = created_at + @updated_at = updated_at + @country = country + @created_by = created_by if created_by != OMIT + @status = status if status != OMIT + @valid_from = valid_from if valid_from != OMIT + @valid_until = valid_until if valid_until != OMIT + @value = value + @additional_properties = additional_properties + @_field_set = { "id": id, "created_at": created_at, "updated_at": updated_at, "country": country, "created_by": created_by, "status": status, "valid_from": valid_from, "valid_until": valid_until, "value": value }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of VatRateResponse + # + # @param json_object [String] + # @return [Monite::VatRateResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + created_at = unless parsed_json["created_at"].nil? + DateTime.parse(parsed_json["created_at"]) +else + nil +end + updated_at = unless parsed_json["updated_at"].nil? + DateTime.parse(parsed_json["updated_at"]) +else + nil +end + country = parsed_json["country"] + created_by = parsed_json["created_by"] + status = parsed_json["status"] + valid_from = parsed_json["valid_from"] + valid_until = parsed_json["valid_until"] + value = parsed_json["value"] + new( + id: id, + created_at: created_at, + updated_at: updated_at, + country: country, + created_by: created_by, + status: status, + valid_from: valid_from, + valid_until: valid_until, + value: value, + additional_properties: struct + ) + end +# Serialize an instance of VatRateResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.created_at.is_a?(DateTime) != false || raise("Passed value for field obj.created_at is not the expected type, validation failed.") + obj.updated_at.is_a?(DateTime) != false || raise("Passed value for field obj.updated_at is not the expected type, validation failed.") + obj.country.is_a?(Monite::AllowedCountries) != false || raise("Passed value for field obj.country is not the expected type, validation failed.") + obj.created_by&.is_a?(Monite::VatRateCreator) != false || raise("Passed value for field obj.created_by is not the expected type, validation failed.") + obj.status&.is_a?(Monite::VatRateStatusEnum) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.valid_from&.is_a?(String) != false || raise("Passed value for field obj.valid_from is not the expected type, validation failed.") + obj.valid_until&.is_a?(String) != false || raise("Passed value for field obj.valid_until is not the expected type, validation failed.") + obj.value.is_a?(Integer) != false || raise("Passed value for field obj.value is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/vat_rate_status_enum.rb b/lib/monite/types/vat_rate_status_enum.rb new file mode 100644 index 0000000..7856d6f --- /dev/null +++ b/lib/monite/types/vat_rate_status_enum.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class VatRateStatusEnum + + ACTIVE = "active" + INACTIVE = "inactive" + + end +end \ No newline at end of file diff --git a/lib/monite/types/verification_airwallex_plaid_request.rb b/lib/monite/types/verification_airwallex_plaid_request.rb new file mode 100644 index 0000000..4c60c94 --- /dev/null +++ b/lib/monite/types/verification_airwallex_plaid_request.rb @@ -0,0 +1,72 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class VerificationAirwallexPlaidRequest + # @return [String] The name of your application to be displayed in Plaid Modal + attr_reader :client_name + # @return [String] The name of the Link customization configured on the Plaid Dashboard. If not +# specified, the default customization will be applied + attr_reader :link_customization_name + # @return [String] URL to handle the OAuth verification flow + attr_reader :redirect_url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param client_name [String] The name of your application to be displayed in Plaid Modal + # @param link_customization_name [String] The name of the Link customization configured on the Plaid Dashboard. If not +# specified, the default customization will be applied + # @param redirect_url [String] URL to handle the OAuth verification flow + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VerificationAirwallexPlaidRequest] + def initialize(client_name:, link_customization_name: OMIT, redirect_url:, additional_properties: nil) + @client_name = client_name + @link_customization_name = link_customization_name if link_customization_name != OMIT + @redirect_url = redirect_url + @additional_properties = additional_properties + @_field_set = { "client_name": client_name, "link_customization_name": link_customization_name, "redirect_url": redirect_url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of VerificationAirwallexPlaidRequest + # + # @param json_object [String] + # @return [Monite::VerificationAirwallexPlaidRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + client_name = parsed_json["client_name"] + link_customization_name = parsed_json["link_customization_name"] + redirect_url = parsed_json["redirect_url"] + new( + client_name: client_name, + link_customization_name: link_customization_name, + redirect_url: redirect_url, + additional_properties: struct + ) + end +# Serialize an instance of VerificationAirwallexPlaidRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.client_name.is_a?(String) != false || raise("Passed value for field obj.client_name is not the expected type, validation failed.") + obj.link_customization_name&.is_a?(String) != false || raise("Passed value for field obj.link_customization_name is not the expected type, validation failed.") + obj.redirect_url.is_a?(String) != false || raise("Passed value for field obj.redirect_url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/verification_airwallex_plaid_response.rb b/lib/monite/types/verification_airwallex_plaid_response.rb new file mode 100644 index 0000000..cd9ee73 --- /dev/null +++ b/lib/monite/types/verification_airwallex_plaid_response.rb @@ -0,0 +1,89 @@ +# frozen_string_literal: true +require "date" +require "ostruct" +require "json" + +module Monite + class VerificationAirwallexPlaidResponse + # @return [String] Client name from the request + attr_reader :client_name + # @return [DateTime] + attr_reader :expires_at + # @return [String] Customization name from the request + attr_reader :link_customization_name + # @return [String] Link token that should be used to init Plaid SDK + attr_reader :link_token + # @return [String] URL from the request + attr_reader :redirect_url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param client_name [String] Client name from the request + # @param expires_at [DateTime] + # @param link_customization_name [String] Customization name from the request + # @param link_token [String] Link token that should be used to init Plaid SDK + # @param redirect_url [String] URL from the request + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VerificationAirwallexPlaidResponse] + def initialize(client_name:, expires_at:, link_customization_name: OMIT, link_token:, redirect_url:, additional_properties: nil) + @client_name = client_name + @expires_at = expires_at + @link_customization_name = link_customization_name if link_customization_name != OMIT + @link_token = link_token + @redirect_url = redirect_url + @additional_properties = additional_properties + @_field_set = { "client_name": client_name, "expires_at": expires_at, "link_customization_name": link_customization_name, "link_token": link_token, "redirect_url": redirect_url }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of VerificationAirwallexPlaidResponse + # + # @param json_object [String] + # @return [Monite::VerificationAirwallexPlaidResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + client_name = parsed_json["client_name"] + expires_at = unless parsed_json["expires_at"].nil? + DateTime.parse(parsed_json["expires_at"]) +else + nil +end + link_customization_name = parsed_json["link_customization_name"] + link_token = parsed_json["link_token"] + redirect_url = parsed_json["redirect_url"] + new( + client_name: client_name, + expires_at: expires_at, + link_customization_name: link_customization_name, + link_token: link_token, + redirect_url: redirect_url, + additional_properties: struct + ) + end +# Serialize an instance of VerificationAirwallexPlaidResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.client_name.is_a?(String) != false || raise("Passed value for field obj.client_name is not the expected type, validation failed.") + obj.expires_at.is_a?(DateTime) != false || raise("Passed value for field obj.expires_at is not the expected type, validation failed.") + obj.link_customization_name&.is_a?(String) != false || raise("Passed value for field obj.link_customization_name is not the expected type, validation failed.") + obj.link_token.is_a?(String) != false || raise("Passed value for field obj.link_token is not the expected type, validation failed.") + obj.redirect_url.is_a?(String) != false || raise("Passed value for field obj.redirect_url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/verification_error.rb b/lib/monite/types/verification_error.rb new file mode 100644 index 0000000..d635668 --- /dev/null +++ b/lib/monite/types/verification_error.rb @@ -0,0 +1,61 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class VerificationError + # @return [String] + attr_reader :code + # @return [String] + attr_reader :details + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param code [String] + # @param details [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VerificationError] + def initialize(code:, details:, additional_properties: nil) + @code = code + @details = details + @additional_properties = additional_properties + @_field_set = { "code": code, "details": details } + end +# Deserialize a JSON object to an instance of VerificationError + # + # @param json_object [String] + # @return [Monite::VerificationError] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + code = parsed_json["code"] + details = parsed_json["details"] + new( + code: code, + details: details, + additional_properties: struct + ) + end +# Serialize an instance of VerificationError to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.code.is_a?(String) != false || raise("Passed value for field obj.code is not the expected type, validation failed.") + obj.details.is_a?(String) != false || raise("Passed value for field obj.details is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/verification_request.rb b/lib/monite/types/verification_request.rb new file mode 100644 index 0000000..6555fe4 --- /dev/null +++ b/lib/monite/types/verification_request.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "verification_airwallex_plaid_request" +require_relative "bank_account_verification_type" +require "ostruct" +require "json" + +module Monite + class VerificationRequest + # @return [Monite::VerificationAirwallexPlaidRequest] + attr_reader :airwallex_plaid + # @return [Monite::BankAccountVerificationType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param airwallex_plaid [Monite::VerificationAirwallexPlaidRequest] + # @param type [Monite::BankAccountVerificationType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VerificationRequest] + def initialize(airwallex_plaid:, type:, additional_properties: nil) + @airwallex_plaid = airwallex_plaid + @type = type + @additional_properties = additional_properties + @_field_set = { "airwallex_plaid": airwallex_plaid, "type": type } + end +# Deserialize a JSON object to an instance of VerificationRequest + # + # @param json_object [String] + # @return [Monite::VerificationRequest] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["airwallex_plaid"].nil? + airwallex_plaid = parsed_json["airwallex_plaid"].to_json + airwallex_plaid = Monite::VerificationAirwallexPlaidRequest.from_json(json_object: airwallex_plaid) + else + airwallex_plaid = nil + end + type = parsed_json["type"] + new( + airwallex_plaid: airwallex_plaid, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of VerificationRequest to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::VerificationAirwallexPlaidRequest.validate_raw(obj: obj.airwallex_plaid) + obj.type.is_a?(Monite::BankAccountVerificationType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/verification_response.rb b/lib/monite/types/verification_response.rb new file mode 100644 index 0000000..1d84cd7 --- /dev/null +++ b/lib/monite/types/verification_response.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require_relative "verification_airwallex_plaid_response" +require_relative "bank_account_verification_type" +require "ostruct" +require "json" + +module Monite + class VerificationResponse + # @return [Monite::VerificationAirwallexPlaidResponse] + attr_reader :airwallex_plaid + # @return [Monite::BankAccountVerificationType] + attr_reader :type + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param airwallex_plaid [Monite::VerificationAirwallexPlaidResponse] + # @param type [Monite::BankAccountVerificationType] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VerificationResponse] + def initialize(airwallex_plaid:, type:, additional_properties: nil) + @airwallex_plaid = airwallex_plaid + @type = type + @additional_properties = additional_properties + @_field_set = { "airwallex_plaid": airwallex_plaid, "type": type } + end +# Deserialize a JSON object to an instance of VerificationResponse + # + # @param json_object [String] + # @return [Monite::VerificationResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + unless parsed_json["airwallex_plaid"].nil? + airwallex_plaid = parsed_json["airwallex_plaid"].to_json + airwallex_plaid = Monite::VerificationAirwallexPlaidResponse.from_json(json_object: airwallex_plaid) + else + airwallex_plaid = nil + end + type = parsed_json["type"] + new( + airwallex_plaid: airwallex_plaid, + type: type, + additional_properties: struct + ) + end +# Serialize an instance of VerificationResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + Monite::VerificationAirwallexPlaidResponse.validate_raw(obj: obj.airwallex_plaid) + obj.type.is_a?(Monite::BankAccountVerificationType) != false || raise("Passed value for field obj.type is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/verification_status_enum.rb b/lib/monite/types/verification_status_enum.rb new file mode 100644 index 0000000..5ba2c99 --- /dev/null +++ b/lib/monite/types/verification_status_enum.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +module Monite + class VerificationStatusEnum + + ENABLED = "enabled" + DISABLED = "disabled" + PENDING = "pending" + + end +end \ No newline at end of file diff --git a/lib/monite/types/verify_response.rb b/lib/monite/types/verify_response.rb new file mode 100644 index 0000000..c295317 --- /dev/null +++ b/lib/monite/types/verify_response.rb @@ -0,0 +1,68 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class VerifyResponse + # @return [String] Entry UUID + attr_reader :id + # @return [String] The domain name. + attr_reader :domain + # @return [String] + attr_reader :status + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] Entry UUID + # @param domain [String] The domain name. + # @param status [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::VerifyResponse] + def initialize(id:, domain:, status:, additional_properties: nil) + @id = id + @domain = domain + @status = status + @additional_properties = additional_properties + @_field_set = { "id": id, "domain": domain, "status": status } + end +# Deserialize a JSON object to an instance of VerifyResponse + # + # @param json_object [String] + # @return [Monite::VerifyResponse] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + domain = parsed_json["domain"] + status = parsed_json["status"] + new( + id: id, + domain: domain, + status: status, + additional_properties: struct + ) + end +# Serialize an instance of VerifyResponse to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.domain.is_a?(String) != false || raise("Passed value for field obj.domain is not the expected type, validation failed.") + obj.status.is_a?(String) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/wc_business_status.rb b/lib/monite/types/wc_business_status.rb new file mode 100644 index 0000000..0168c57 --- /dev/null +++ b/lib/monite/types/wc_business_status.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +module Monite +# - NEW: A business has been created within Kanmon +# - ONBOARDED: A business has completed all of the onboarding steps within Kanmon +# and is now awaiting underwriting. +# - INPUT_REQUIRED: A business will be asked to provide required data + class WcBusinessStatus + + NEW = "NEW" + INPUT_REQUIRED = "INPUT_REQUIRED" + ONBOARDED = "ONBOARDED" + + end +end \ No newline at end of file diff --git a/lib/monite/types/wc_invoice_status.rb b/lib/monite/types/wc_invoice_status.rb new file mode 100644 index 0000000..edea92d --- /dev/null +++ b/lib/monite/types/wc_invoice_status.rb @@ -0,0 +1,21 @@ +# frozen_string_literal: true + +module Monite +# - NEW: The business has submitted an invoice and it is under review. +# - FUNDED: The funds for the invoice have been disbursed. The business is now +# expected to pay back the funds. +# - PAID: A payment was made that fully paid off an outstanding invoice. +# - LATE: A payment was not made towards an outstanding invoice. +# - REJECTED: An invoice was rejected during the funding step. +# - DEFAULTED: A payment was not made towards an outstanding invoice. + class WcInvoiceStatus + + NEW = "NEW" + FUNDED = "FUNDED" + PAID = "PAID" + LATE = "LATE" + REJECTED = "REJECTED" + DEFAULTED = "DEFAULTED" + + end +end \ No newline at end of file diff --git a/lib/monite/types/wc_offer_status.rb b/lib/monite/types/wc_offer_status.rb new file mode 100644 index 0000000..d78d5cd --- /dev/null +++ b/lib/monite/types/wc_offer_status.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module Monite +# - NEW: A new offer has been extended to the business. +# - ACCEPTED: Business has accepted an offer and is waiting on the closing +# process. +# - EXPIRED: Business has not accepted the offer, and the offer has expired. +# - CURRENT: A loan has been originated and does not currently have any +# outstanding delayed payments. +# - LATE: One or more repayments on the issued product have failed. +# - CLOSED: The issued product is no longer available to the business. +# - DEFAULTED: The business has failed to meet agreed-upon terms of the loan +# agreement. + class WcOfferStatus + + NEW = "NEW" + ACCEPTED = "ACCEPTED" + EXPIRED = "EXPIRED" + CURRENT = "CURRENT" + LATE = "LATE" + CLOSED = "CLOSED" + DEFAULTED = "DEFAULTED" + + end +end \ No newline at end of file diff --git a/lib/monite/types/wc_repayment_type.rb b/lib/monite/types/wc_repayment_type.rb new file mode 100644 index 0000000..13bdf60 --- /dev/null +++ b/lib/monite/types/wc_repayment_type.rb @@ -0,0 +1,14 @@ +# frozen_string_literal: true + +module Monite +# - MULTIPLE_DURATION: The business can repay the loan over multiple durations. +# - FIXED_DURATION: The business must repay the loan over a fixed duration. +# - FIXED_DATE: The business must repay the loan on a fixed date. + class WcRepaymentType + + MULTIPLE_DURATION = "MULTIPLE_DURATION" + FIXED_DURATION = "FIXED_DURATION" + FIXED_DATE = "FIXED_DATE" + + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_delivery_cursor_fields.rb b/lib/monite/types/webhook_delivery_cursor_fields.rb new file mode 100644 index 0000000..f4c267a --- /dev/null +++ b/lib/monite/types/webhook_delivery_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class WebhookDeliveryCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_delivery_pagination_resource.rb b/lib/monite/types/webhook_delivery_pagination_resource.rb new file mode 100644 index 0000000..9a93fe4 --- /dev/null +++ b/lib/monite/types/webhook_delivery_pagination_resource.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true +require_relative "webhook_delivery_resource" +require "ostruct" +require "json" + +module Monite + class WebhookDeliveryPaginationResource + # @return [Array] A set of webhooks returned per page + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A set of webhooks returned per page + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::WebhookDeliveryPaginationResource] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of WebhookDeliveryPaginationResource + # + # @param json_object [String] + # @return [Monite::WebhookDeliveryPaginationResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::WebhookDeliveryResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of WebhookDeliveryPaginationResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_delivery_resource.rb b/lib/monite/types/webhook_delivery_resource.rb new file mode 100644 index 0000000..796234f --- /dev/null +++ b/lib/monite/types/webhook_delivery_resource.rb @@ -0,0 +1,98 @@ +# frozen_string_literal: true +require "ostruct" +require "json" + +module Monite + class WebhookDeliveryResource + # @return [String] + attr_reader :id + # @return [String] + attr_reader :event_id + # @return [Integer] + attr_reader :requests_made_count + # @return [String] + attr_reader :response + # @return [Integer] + attr_reader :response_status_code + # @return [String] + attr_reader :url + # @return [Boolean] + attr_reader :was_successful + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param event_id [String] + # @param requests_made_count [Integer] + # @param response [String] + # @param response_status_code [Integer] + # @param url [String] + # @param was_successful [Boolean] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::WebhookDeliveryResource] + def initialize(id:, event_id:, requests_made_count:, response: OMIT, response_status_code: OMIT, url:, was_successful: OMIT, additional_properties: nil) + @id = id + @event_id = event_id + @requests_made_count = requests_made_count + @response = response if response != OMIT + @response_status_code = response_status_code if response_status_code != OMIT + @url = url + @was_successful = was_successful if was_successful != OMIT + @additional_properties = additional_properties + @_field_set = { "id": id, "event_id": event_id, "requests_made_count": requests_made_count, "response": response, "response_status_code": response_status_code, "url": url, "was_successful": was_successful }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of WebhookDeliveryResource + # + # @param json_object [String] + # @return [Monite::WebhookDeliveryResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + event_id = parsed_json["event_id"] + requests_made_count = parsed_json["requests_made_count"] + response = parsed_json["response"] + response_status_code = parsed_json["response_status_code"] + url = parsed_json["url"] + was_successful = parsed_json["was_successful"] + new( + id: id, + event_id: event_id, + requests_made_count: requests_made_count, + response: response, + response_status_code: response_status_code, + url: url, + was_successful: was_successful, + additional_properties: struct + ) + end +# Serialize an instance of WebhookDeliveryResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.event_id.is_a?(String) != false || raise("Passed value for field obj.event_id is not the expected type, validation failed.") + obj.requests_made_count.is_a?(Integer) != false || raise("Passed value for field obj.requests_made_count is not the expected type, validation failed.") + obj.response&.is_a?(String) != false || raise("Passed value for field obj.response is not the expected type, validation failed.") + obj.response_status_code&.is_a?(Integer) != false || raise("Passed value for field obj.response_status_code is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + obj.was_successful&.is_a?(Boolean) != false || raise("Passed value for field obj.was_successful is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_object_type.rb b/lib/monite/types/webhook_object_type.rb new file mode 100644 index 0000000..a66dbf1 --- /dev/null +++ b/lib/monite/types/webhook_object_type.rb @@ -0,0 +1,46 @@ +# frozen_string_literal: true + +module Monite + class WebhookObjectType + + ACCOUNT = "account" + ACCOUNTING_CONNECTION = "accounting_connection" + APPROVAL = "approval" + APPROVAL_REQUEST = "approval_request" + APPROVAL_POLICY = "approval_policy" + APPROVAL_POLICY_PROCESS = "approval_policy_process" + BATCH_PAYMENT = "batch_payment" + COMMENT = "comment" + COUNTERPART = "counterpart" + COUNTERPART_ADDRESS = "counterpart_address" + COUNTERPART_BANK_ACCOUNT = "counterpart_bank_account" + COUNTERPART_CONTACT_PERSON = "counterpart_contact_person" + COUNTERPART_PARTNER_METADATA = "counterpart_partner_metadata" + COUNTERPART_TAX_ID = "counterpart_tax_id" + ENTITY = "entity" + ENTITY_BANK_ACCOUNT = "entity_bank_account" + ENTITY_SETTINGS = "entity_settings" + ENTITY_USER = "entity_user" + EXPORT = "export" + OVERDUE_REMINDER = "overdue_reminder" + PARTNER_SETTINGS = "partner_settings" + PAYABLE = "payable" + PAYABLES_CREDIT_NOTE = "payables_credit_note" + PAYABLES_PURCHASE_ORDER = "payables_purchase_order" + PAYABLE_LINE_ITEM = "payable.line_item" + PAYMENT = "payment" + PAYMENT_INTENT = "payment_intent" + PAYMENT_LINK = "payment_link" + PAYMENT_REMINDER = "payment_reminder" + PRODUCT = "product" + PROJECT = "project" + RECEIVABLE = "receivable" + RECURRENCE = "recurrence" + ROLE = "role" + TAG = "tag" + TODO_TASK = "todo_task" + WORKFLOW = "workflow" + WORKFLOW_PIPELINE = "workflow_pipeline" + + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_subscription_cursor_fields.rb b/lib/monite/types/webhook_subscription_cursor_fields.rb new file mode 100644 index 0000000..9c38cac --- /dev/null +++ b/lib/monite/types/webhook_subscription_cursor_fields.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class WebhookSubscriptionCursorFields + + CREATED_AT = "created_at" + UPDATED_AT = "updated_at" + + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_subscription_pagination_resource.rb b/lib/monite/types/webhook_subscription_pagination_resource.rb new file mode 100644 index 0000000..3b1985f --- /dev/null +++ b/lib/monite/types/webhook_subscription_pagination_resource.rb @@ -0,0 +1,83 @@ +# frozen_string_literal: true +require_relative "webhook_subscription_resource" +require "ostruct" +require "json" + +module Monite + class WebhookSubscriptionPaginationResource + # @return [Array] A set of webhook settings of different types returned per page + attr_reader :data + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + attr_reader :next_pagination_token + # @return [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + attr_reader :prev_pagination_token + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param data [Array] A set of webhook settings of different types returned per page + # @param next_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# next page of results, or `null` if there is no next page (i.e. you've reached +# the last page). + # @param prev_pagination_token [String] A token that can be sent in the `pagination_token` query parameter to get the +# previous page of results, or `null` if there is no previous page (i.e. you've +# reached the first page). + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::WebhookSubscriptionPaginationResource] + def initialize(data:, next_pagination_token: OMIT, prev_pagination_token: OMIT, additional_properties: nil) + @data = data + @next_pagination_token = next_pagination_token if next_pagination_token != OMIT + @prev_pagination_token = prev_pagination_token if prev_pagination_token != OMIT + @additional_properties = additional_properties + @_field_set = { "data": data, "next_pagination_token": next_pagination_token, "prev_pagination_token": prev_pagination_token }.reject do | _k, v | + v == OMIT +end + end +# Deserialize a JSON object to an instance of +# WebhookSubscriptionPaginationResource + # + # @param json_object [String] + # @return [Monite::WebhookSubscriptionPaginationResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + data = parsed_json["data"]&.map do | item | + item = item.to_json + Monite::WebhookSubscriptionResource.from_json(json_object: item) +end + next_pagination_token = parsed_json["next_pagination_token"] + prev_pagination_token = parsed_json["prev_pagination_token"] + new( + data: data, + next_pagination_token: next_pagination_token, + prev_pagination_token: prev_pagination_token, + additional_properties: struct + ) + end +# Serialize an instance of WebhookSubscriptionPaginationResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.data.is_a?(Array) != false || raise("Passed value for field obj.data is not the expected type, validation failed.") + obj.next_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.next_pagination_token is not the expected type, validation failed.") + obj.prev_pagination_token&.is_a?(String) != false || raise("Passed value for field obj.prev_pagination_token is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_subscription_resource.rb b/lib/monite/types/webhook_subscription_resource.rb new file mode 100644 index 0000000..2f44e36 --- /dev/null +++ b/lib/monite/types/webhook_subscription_resource.rb @@ -0,0 +1,84 @@ +# frozen_string_literal: true +require_relative "webhook_object_type" +require_relative "webhook_subscription_status" +require "ostruct" +require "json" + +module Monite + class WebhookSubscriptionResource + # @return [String] + attr_reader :id + # @return [Array] + attr_reader :event_types + # @return [Monite::WebhookObjectType] + attr_reader :object_type + # @return [Monite::WebhookSubscriptionStatus] + attr_reader :status + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param event_types [Array] + # @param object_type [Monite::WebhookObjectType] + # @param status [Monite::WebhookSubscriptionStatus] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::WebhookSubscriptionResource] + def initialize(id:, event_types:, object_type:, status:, url:, additional_properties: nil) + @id = id + @event_types = event_types + @object_type = object_type + @status = status + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "event_types": event_types, "object_type": object_type, "status": status, "url": url } + end +# Deserialize a JSON object to an instance of WebhookSubscriptionResource + # + # @param json_object [String] + # @return [Monite::WebhookSubscriptionResource] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + event_types = parsed_json["event_types"] + object_type = parsed_json["object_type"] + status = parsed_json["status"] + url = parsed_json["url"] + new( + id: id, + event_types: event_types, + object_type: object_type, + status: status, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of WebhookSubscriptionResource to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.event_types.is_a?(Array) != false || raise("Passed value for field obj.event_types is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::WebhookObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.status.is_a?(Monite::WebhookSubscriptionStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_subscription_resource_with_secret.rb b/lib/monite/types/webhook_subscription_resource_with_secret.rb new file mode 100644 index 0000000..7cb5f1b --- /dev/null +++ b/lib/monite/types/webhook_subscription_resource_with_secret.rb @@ -0,0 +1,92 @@ +# frozen_string_literal: true +require_relative "webhook_object_type" +require_relative "webhook_subscription_status" +require "ostruct" +require "json" + +module Monite + class WebhookSubscriptionResourceWithSecret + # @return [String] + attr_reader :id + # @return [Array] + attr_reader :event_types + # @return [Monite::WebhookObjectType] + attr_reader :object_type + # @return [String] + attr_reader :secret + # @return [Monite::WebhookSubscriptionStatus] + attr_reader :status + # @return [String] + attr_reader :url + # @return [OpenStruct] Additional properties unmapped to the current class definition + attr_reader :additional_properties + # @return [Object] + attr_reader :_field_set + protected :_field_set + + OMIT = Object.new + + # @param id [String] + # @param event_types [Array] + # @param object_type [Monite::WebhookObjectType] + # @param secret [String] + # @param status [Monite::WebhookSubscriptionStatus] + # @param url [String] + # @param additional_properties [OpenStruct] Additional properties unmapped to the current class definition + # @return [Monite::WebhookSubscriptionResourceWithSecret] + def initialize(id:, event_types:, object_type:, secret:, status:, url:, additional_properties: nil) + @id = id + @event_types = event_types + @object_type = object_type + @secret = secret + @status = status + @url = url + @additional_properties = additional_properties + @_field_set = { "id": id, "event_types": event_types, "object_type": object_type, "secret": secret, "status": status, "url": url } + end +# Deserialize a JSON object to an instance of +# WebhookSubscriptionResourceWithSecret + # + # @param json_object [String] + # @return [Monite::WebhookSubscriptionResourceWithSecret] + def self.from_json(json_object:) + struct = JSON.parse(json_object, object_class: OpenStruct) + parsed_json = JSON.parse(json_object) + id = parsed_json["id"] + event_types = parsed_json["event_types"] + object_type = parsed_json["object_type"] + secret = parsed_json["secret"] + status = parsed_json["status"] + url = parsed_json["url"] + new( + id: id, + event_types: event_types, + object_type: object_type, + secret: secret, + status: status, + url: url, + additional_properties: struct + ) + end +# Serialize an instance of WebhookSubscriptionResourceWithSecret to a JSON object + # + # @return [String] + def to_json + @_field_set&.to_json + end +# Leveraged for Union-type generation, validate_raw attempts to parse the given +# hash and check each fields type against the current object's property +# definitions. + # + # @param obj [Object] + # @return [Void] + def self.validate_raw(obj:) + obj.id.is_a?(String) != false || raise("Passed value for field obj.id is not the expected type, validation failed.") + obj.event_types.is_a?(Array) != false || raise("Passed value for field obj.event_types is not the expected type, validation failed.") + obj.object_type.is_a?(Monite::WebhookObjectType) != false || raise("Passed value for field obj.object_type is not the expected type, validation failed.") + obj.secret.is_a?(String) != false || raise("Passed value for field obj.secret is not the expected type, validation failed.") + obj.status.is_a?(Monite::WebhookSubscriptionStatus) != false || raise("Passed value for field obj.status is not the expected type, validation failed.") + obj.url.is_a?(String) != false || raise("Passed value for field obj.url is not the expected type, validation failed.") + end + end +end \ No newline at end of file diff --git a/lib/monite/types/webhook_subscription_status.rb b/lib/monite/types/webhook_subscription_status.rb new file mode 100644 index 0000000..21834fc --- /dev/null +++ b/lib/monite/types/webhook_subscription_status.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +module Monite + class WebhookSubscriptionStatus + + ENABLED = "enabled" + DISABLED = "disabled" + + end +end \ No newline at end of file diff --git a/lib/monite/vat_rates/client.rb b/lib/monite/vat_rates/client.rb new file mode 100644 index 0000000..fa9a77d --- /dev/null +++ b/lib/monite/vat_rates/client.rb @@ -0,0 +1,109 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/product_service_type_enum" +require_relative "../types/vat_rate_list_response" +require "async" +require_relative "../../requests" + +module Monite + class VatRatesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::VatRatesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_address_id [String] + # @param counterpart_id [String] + # @param counterpart_vat_id_id [String] + # @param entity_vat_id_id [String] + # @param product_type [Monite::ProductServiceTypeEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::VatRateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.vat_rates.get + def get(counterpart_address_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, entity_vat_id_id: nil, product_type: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "counterpart_address_id": counterpart_address_id, "counterpart_id": counterpart_id, "counterpart_vat_id_id": counterpart_vat_id_id, "entity_vat_id_id": entity_vat_id_id, "product_type": product_type }.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)}/vat_rates" +end + Monite::VatRateListResponse.from_json(json_object: response.body) + end + end + class AsyncVatRatesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncVatRatesClient] + def initialize(request_client:) + @request_client = request_client + end + # @param counterpart_address_id [String] + # @param counterpart_id [String] + # @param counterpart_vat_id_id [String] + # @param entity_vat_id_id [String] + # @param product_type [Monite::ProductServiceTypeEnum] + # @param request_options [Monite::RequestOptions] + # @return [Monite::VatRateListResponse] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.vat_rates.get + def get(counterpart_address_id: nil, counterpart_id: nil, counterpart_vat_id_id: nil, entity_vat_id_id: nil, product_type: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "counterpart_address_id": counterpart_address_id, "counterpart_id": counterpart_id, "counterpart_vat_id_id": counterpart_vat_id_id, "entity_vat_id_id": entity_vat_id_id, "product_type": product_type }.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)}/vat_rates" +end + Monite::VatRateListResponse.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/webhook_deliveries/client.rb b/lib/monite/webhook_deliveries/client.rb new file mode 100644 index 0000000..68817fd --- /dev/null +++ b/lib/monite/webhook_deliveries/client.rb @@ -0,0 +1,161 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/webhook_delivery_cursor_fields" +require_relative "../types/webhook_object_type" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/webhook_delivery_pagination_resource" +require "async" +require_relative "../../requests" + +module Monite + class WebhookDeliveriesClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::WebhookDeliveriesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns an aggregated log of webhook delivery attempts. The data contains a list +# of triggered webhook events, how many times Monite tried to send each event to +# your server, the last HTTP status code returned by your webhook listener +# endpoint, and whether the final attempt to deliver that event was successful. +# We guarantee access to webhook delivery data only from the last three months. +# Earlier data may be unavailable. +# Note that if the same event type is included in multiple webhook subscriptions, +# the results will include several entries for each occurrence of this event - one +# entry per subscription. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::WebhookDeliveryCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param event_id [String] + # @param object_type [Monite::WebhookObjectType] + # @param event_action [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookDeliveryPaginationResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_deliveries.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, event_id: nil, object_type: nil, event_action: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "event_id": event_id, "object_type": object_type, "event_action": event_action, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/webhook_deliveries" +end + Monite::WebhookDeliveryPaginationResource.from_json(json_object: response.body) + end + end + class AsyncWebhookDeliveriesClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncWebhookDeliveriesClient] + def initialize(request_client:) + @request_client = request_client + end +# Returns an aggregated log of webhook delivery attempts. The data contains a list +# of triggered webhook events, how many times Monite tried to send each event to +# your server, the last HTTP status code returned by your webhook listener +# endpoint, and whether the final attempt to deliver that event was successful. +# We guarantee access to webhook delivery data only from the last three months. +# Earlier data may be unavailable. +# Note that if the same event type is included in multiple webhook subscriptions, +# the results will include several entries for each occurrence of this event - one +# entry per subscription. + # + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::WebhookDeliveryCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param event_id [String] + # @param object_type [Monite::WebhookObjectType] + # @param event_action [String] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookDeliveryPaginationResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_deliveries.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, event_id: nil, object_type: nil, event_action: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "event_id": event_id, "object_type": object_type, "event_action": event_action, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/webhook_deliveries" +end + Monite::WebhookDeliveryPaginationResource.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/monite/webhook_subscriptions/client.rb b/lib/monite/webhook_subscriptions/client.rb new file mode 100644 index 0000000..0861a6f --- /dev/null +++ b/lib/monite/webhook_subscriptions/client.rb @@ -0,0 +1,664 @@ +# frozen_string_literal: true +require_relative "../../requests" +require_relative "../types/order_enum" +require_relative "../types/webhook_subscription_cursor_fields" +require_relative "../types/webhook_object_type" +require "date" +require "date" +require "date" +require "date" +require_relative "../types/webhook_subscription_pagination_resource" +require_relative "../types/webhook_subscription_resource_with_secret" +require_relative "../types/webhook_subscription_resource" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require "async" +require_relative "../../requests" + +module Monite + class WebhookSubscriptionsClient + # @return [Monite::RequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::WebhookSubscriptionsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::WebhookSubscriptionCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param object_type [Monite::WebhookObjectType] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionPaginationResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, object_type: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_type": object_type, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/webhook_subscriptions" +end + Monite::WebhookSubscriptionPaginationResource.from_json(json_object: response.body) + end + # @param event_types [Array] + # @param object_type [Monite::WebhookObjectType] + # @param url [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResourceWithSecret] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.create(object_type: ACCOUNT, url: "url") + def create(event_types: nil, object_type:, url:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), event_types: event_types, object_type: object_type, url: url }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/webhook_subscriptions" +end + Monite::WebhookSubscriptionResourceWithSecret.from_json(json_object: response.body) + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.get_by_id(webhook_subscription_id: "webhook_subscription_id") + def get_by_id(webhook_subscription_id:, request_options: nil) + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.delete_by_id(webhook_subscription_id: "webhook_subscription_id") + def delete_by_id(webhook_subscription_id:, request_options: nil) + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}" +end + end + # @param webhook_subscription_id [String] + # @param event_types [Array] + # @param object_type [Monite::WebhookObjectType] + # @param url [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.update_by_id(webhook_subscription_id: "webhook_subscription_id") + def update_by_id(webhook_subscription_id:, event_types: nil, object_type: nil, url: nil, request_options: nil) + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), event_types: event_types, object_type: object_type, url: url }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/webhook_subscriptions/#{webhook_subscription_id}" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.disable_by_id(webhook_subscription_id: "webhook_subscription_id") + def disable_by_id(webhook_subscription_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}/disable" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.enable_by_id(webhook_subscription_id: "webhook_subscription_id") + def enable_by_id(webhook_subscription_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}/enable" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResourceWithSecret] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.regenerate_secret_by_id(webhook_subscription_id: "webhook_subscription_id") + def regenerate_secret_by_id(webhook_subscription_id:, request_options: nil) + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}/regenerate_secret" +end + Monite::WebhookSubscriptionResourceWithSecret.from_json(json_object: response.body) + end + end + class AsyncWebhookSubscriptionsClient + # @return [Monite::AsyncRequestClient] + attr_reader :request_client + + + # @param request_client [Monite::RequestClient] + # @return [Monite::AsyncWebhookSubscriptionsClient] + def initialize(request_client:) + @request_client = request_client + end + # @param order [Monite::OrderEnum] Sort order (ascending by default). Typically used together with the `sort` +# parameter. + # @param limit [Integer] The number of items (0 .. 100) to return in a single page of the response. The +# response may contain fewer items if it is the last or only page. + # @param pagination_token [String] A pagination token obtained from a previous call to this endpoint. Use it to get +# the next or previous page of results for your initial query. If +# `pagination_token` is specified, all other query parameters are ignored and +# inferred from the initial query. +# If not specified, the first page of results will be returned. + # @param sort [Monite::WebhookSubscriptionCursorFields] The field to sort the results by. Typically used together with the `order` +# parameter. + # @param object_type [Monite::WebhookObjectType] + # @param created_at_gt [DateTime] + # @param created_at_lt [DateTime] + # @param created_at_gte [DateTime] + # @param created_at_lte [DateTime] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionPaginationResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.get + def get(order: nil, limit: nil, pagination_token: nil, sort: nil, object_type: nil, created_at_gt: nil, created_at_lt: nil, created_at_gte: nil, created_at_lte: nil, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + req.headers = { **(req.headers || {}), **@request_client.get_headers, **(request_options&.additional_headers || {}) }.compact + req.params = { **(request_options&.additional_query_parameters || {}), "order": order, "limit": limit, "pagination_token": pagination_token, "sort": sort, "object_type": object_type, "created_at__gt": created_at_gt, "created_at__lt": created_at_lt, "created_at__gte": created_at_gte, "created_at__lte": created_at_lte }.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)}/webhook_subscriptions" +end + Monite::WebhookSubscriptionPaginationResource.from_json(json_object: response.body) + end + end + # @param event_types [Array] + # @param object_type [Monite::WebhookObjectType] + # @param url [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResourceWithSecret] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.create(object_type: ACCOUNT, url: "url") + def create(event_types: nil, object_type:, url:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), event_types: event_types, object_type: object_type, url: url }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/webhook_subscriptions" +end + Monite::WebhookSubscriptionResourceWithSecret.from_json(json_object: response.body) + end + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.get_by_id(webhook_subscription_id: "webhook_subscription_id") + def get_by_id(webhook_subscription_id:, request_options: nil) + Async do + response = @request_client.conn.get do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Void] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.delete_by_id(webhook_subscription_id: "webhook_subscription_id") + def delete_by_id(webhook_subscription_id:, request_options: nil) + Async do + response = @request_client.conn.delete do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}" +end + end + end + # @param webhook_subscription_id [String] + # @param event_types [Array] + # @param object_type [Monite::WebhookObjectType] + # @param url [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.update_by_id(webhook_subscription_id: "webhook_subscription_id") + def update_by_id(webhook_subscription_id:, event_types: nil, object_type: nil, url: nil, request_options: nil) + Async do + response = @request_client.conn.patch do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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 + req.body = { **(request_options&.additional_body_parameters || {}), event_types: event_types, object_type: object_type, url: url }.compact + req.url "#{@request_client.get_url(request_options: request_options)}/webhook_subscriptions/#{webhook_subscription_id}" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.disable_by_id(webhook_subscription_id: "webhook_subscription_id") + def disable_by_id(webhook_subscription_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}/disable" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResource] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.enable_by_id(webhook_subscription_id: "webhook_subscription_id") + def enable_by_id(webhook_subscription_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}/enable" +end + Monite::WebhookSubscriptionResource.from_json(json_object: response.body) + end + end + # @param webhook_subscription_id [String] + # @param request_options [Monite::RequestOptions] + # @return [Monite::WebhookSubscriptionResourceWithSecret] + # @example +# api = Monite::Client.new( +# base_url: "https://api.example.com", +# environment: Monite::Environment::SANDBOX, +# token: "YOUR_AUTH_TOKEN", +# monite_version: "MoniteVersion" +# ) +# api.webhook_subscriptions.regenerate_secret_by_id(webhook_subscription_id: "webhook_subscription_id") + def regenerate_secret_by_id(webhook_subscription_id:, request_options: nil) + Async do + response = @request_client.conn.post do | req | + unless request_options&.timeout_in_seconds.nil? + req.options.timeout = request_options.timeout_in_seconds + end + unless request_options&.token.nil? + req.headers["Authorization"] = request_options.token + end + unless request_options&.monite_version.nil? + req.headers["x-monite-version"] = request_options.monite_version + end + unless request_options&.monite_entity_id.nil? + req.headers["x-monite-entity-id"] = request_options.monite_entity_id + end + 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)}/webhook_subscriptions/#{webhook_subscription_id}/regenerate_secret" +end + Monite::WebhookSubscriptionResourceWithSecret.from_json(json_object: response.body) + end + end + end +end \ No newline at end of file diff --git a/lib/requests.rb b/lib/requests.rb new file mode 100644 index 0000000..b575c35 --- /dev/null +++ b/lib/requests.rb @@ -0,0 +1,204 @@ +# frozen_string_literal: true +require_relative "environment" +require "faraday" +require "faraday/multipart" +require "faraday/retry" +require "faraday" +require "faraday" +require "faraday/multipart" +require "async/http/faraday" +require "faraday/retry" + +module Monite + class RequestClient + # @return [Faraday] + attr_reader :conn + # @return [String] + attr_reader :base_url + # @return [String] + attr_reader :token + # @return [String] + attr_reader :default_environment + + + # @param base_url [String] + # @param environment [Monite::Environment] + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. + # @param timeout_in_seconds [Long] + # @param token [String] + # @param monite_version [String] + # @param monite_entity_id [String] The ID of the entity that owns the requested resource. + # @return [Monite::RequestClient] + def initialize(base_url: nil, environment: Monite::Environment::SANDBOX, max_retries: nil, timeout_in_seconds: nil, token:, monite_version:, monite_entity_id: nil) + @default_environment = environment + @base_url = environment || base_url + @token = "Bearer #{token}" + @headers = { } + unless monite_version.nil? + @headers["x-monite-version"] = monite_version + end + unless monite_entity_id.nil? + @headers["x-monite-entity-id"] = monite_entity_id + end + @conn = Faraday.new(headers: @headers) do | faraday | + faraday.request :multipart + faraday.request :json + faraday.response :raise_error, include_request: true + unless max_retries.nil? + faraday.request :retry , { max: max_retries } + end + unless timeout_in_seconds.nil? + faraday.options.timeout = timeout_in_seconds + end +end + end + # @param request_options [Monite::RequestOptions] + # @return [String] + def get_url(request_options: nil) + request_options&.base_url || @default_environment || @base_url + end + # @return [Hash{String => String}] + def get_headers + headers = { "X-Fern-Language": 'Ruby', "X-Fern-SDK-Name": 'monite', "X-Fern-SDK-Version": '0.1.0' } + headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil? + headers + end + end + class AsyncRequestClient + # @return [Faraday] + attr_reader :conn + # @return [String] + attr_reader :base_url + # @return [String] + attr_reader :token + # @return [String] + attr_reader :default_environment + + + # @param base_url [String] + # @param environment [Monite::Environment] + # @param max_retries [Long] The number of times to retry a failed request, defaults to 2. + # @param timeout_in_seconds [Long] + # @param token [String] + # @param monite_version [String] + # @param monite_entity_id [String] The ID of the entity that owns the requested resource. + # @return [Monite::AsyncRequestClient] + def initialize(base_url: nil, environment: Monite::Environment::SANDBOX, max_retries: nil, timeout_in_seconds: nil, token:, monite_version:, monite_entity_id: nil) + @default_environment = environment + @base_url = environment || base_url + @token = "Bearer #{token}" + @headers = { } + unless monite_version.nil? + @headers["x-monite-version"] = monite_version + end + unless monite_entity_id.nil? + @headers["x-monite-entity-id"] = monite_entity_id + end + @conn = Faraday.new(headers: @headers) do | faraday | + faraday.request :multipart + faraday.request :json + faraday.response :raise_error, include_request: true + faraday.adapter :async_http + unless max_retries.nil? + faraday.request :retry , { max: max_retries } + end + unless timeout_in_seconds.nil? + faraday.options.timeout = timeout_in_seconds + end +end + end + # @param request_options [Monite::RequestOptions] + # @return [String] + def get_url(request_options: nil) + request_options&.base_url || @default_environment || @base_url + end + # @return [Hash{String => String}] + def get_headers + headers = { "X-Fern-Language": 'Ruby', "X-Fern-SDK-Name": 'monite', "X-Fern-SDK-Version": '0.1.0' } + headers["Authorization"] = ((@token.is_a? Method) ? @token.call : @token) unless @token.nil? + headers + end + end +# Additional options for request-specific configuration when calling APIs via the +# SDK. + class RequestOptions + # @return [String] + attr_reader :base_url + # @return [String] + attr_reader :token + # @return [String] + attr_reader :monite_version + # @return [String] The ID of the entity that owns the requested resource. + attr_reader :monite_entity_id + # @return [Hash{String => Object}] + attr_reader :additional_headers + # @return [Hash{String => Object}] + attr_reader :additional_query_parameters + # @return [Hash{String => Object}] + attr_reader :additional_body_parameters + # @return [Long] + attr_reader :timeout_in_seconds + + + # @param base_url [String] + # @param token [String] + # @param monite_version [String] + # @param monite_entity_id [String] The ID of the entity that owns the requested resource. + # @param additional_headers [Hash{String => Object}] + # @param additional_query_parameters [Hash{String => Object}] + # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] + # @return [Monite::RequestOptions] + def initialize(base_url: nil, token: nil, monite_version: nil, monite_entity_id: nil, additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil) + @base_url = base_url + @token = token + @monite_version = monite_version + @monite_entity_id = monite_entity_id + @additional_headers = additional_headers + @additional_query_parameters = additional_query_parameters + @additional_body_parameters = additional_body_parameters + @timeout_in_seconds = timeout_in_seconds + end + end +# Additional options for request-specific configuration when calling APIs via the +# SDK. + class IdempotencyRequestOptions + # @return [String] + attr_reader :base_url + # @return [String] + attr_reader :token + # @return [String] + attr_reader :monite_version + # @return [String] The ID of the entity that owns the requested resource. + attr_reader :monite_entity_id + # @return [Hash{String => Object}] + attr_reader :additional_headers + # @return [Hash{String => Object}] + attr_reader :additional_query_parameters + # @return [Hash{String => Object}] + attr_reader :additional_body_parameters + # @return [Long] + attr_reader :timeout_in_seconds + + + # @param base_url [String] + # @param token [String] + # @param monite_version [String] + # @param monite_entity_id [String] The ID of the entity that owns the requested resource. + # @param additional_headers [Hash{String => Object}] + # @param additional_query_parameters [Hash{String => Object}] + # @param additional_body_parameters [Hash{String => Object}] + # @param timeout_in_seconds [Long] + # @return [Monite::IdempotencyRequestOptions] + def initialize(base_url: nil, token: nil, monite_version: nil, monite_entity_id: nil, additional_headers: nil, additional_query_parameters: nil, additional_body_parameters: nil, timeout_in_seconds: nil) + @base_url = base_url + @token = token + @monite_version = monite_version + @monite_entity_id = monite_entity_id + @additional_headers = additional_headers + @additional_query_parameters = additional_query_parameters + @additional_body_parameters = additional_body_parameters + @timeout_in_seconds = timeout_in_seconds + end + end +end \ No newline at end of file diff --git a/lib/types_export.rb b/lib/types_export.rb new file mode 100644 index 0000000..dc0fa42 --- /dev/null +++ b/lib/types_export.rb @@ -0,0 +1,566 @@ +# frozen_string_literal: true +require_relative "monite/approval_policies/types/approval_policies_get_request_status" +require_relative "monite/approval_policies/types/approval_policies_get_request_status_in_item" +require_relative "monite/approval_policies/types/approval_policy_create_script_item" +require_relative "monite/approval_policies/types/approval_policy_create_trigger" +require_relative "monite/approval_policies/types/approval_policy_update_script_item" +require_relative "monite/approval_policies/types/approval_policy_update_trigger" +require_relative "monite/receivables/types/receivables_get_request_status_in_item" +require_relative "monite/receivables/types/receivables_get_request_status" +require_relative "monite/types/api_version" +require_relative "monite/types/access_token_response" +require_relative "monite/types/account_disabled_reason" +require_relative "monite/types/accounting_connection_list" +require_relative "monite/types/accounting_connection_response" +require_relative "monite/types/accounting_customer_ref_object" +require_relative "monite/types/accounting_line_item" +require_relative "monite/types/accounting_message_response" +require_relative "monite/types/accounting_payable_due_date" +require_relative "monite/types/accounting_payable" +require_relative "monite/types/accounting_payable_list" +require_relative "monite/types/accounting_purchase_order_ref" +require_relative "monite/types/accounting_receivable_due_date" +require_relative "monite/types/accounting_receivable" +require_relative "monite/types/accounting_receivable_list" +require_relative "monite/types/accounting_ref_object" +require_relative "monite/types/accounting_settings" +require_relative "monite/types/accounting_tax_rate_list_response" +require_relative "monite/types/accounting_tax_rate_response" +require_relative "monite/types/accounting_vendor_ref_object" +require_relative "monite/types/action_enum" +require_relative "monite/types/action_schema" +require_relative "monite/types/aggregation_function_enum" +require_relative "monite/types/airwallex_mandate" +require_relative "monite/types/airwallex_mandate_type" +require_relative "monite/types/airwallex_mandate_version" +require_relative "monite/types/airwallex_plaid_account" +require_relative "monite/types/airwallex_plaid_bank_account_verification_status" +require_relative "monite/types/airwallex_plaid_institution" +require_relative "monite/types/airwallex_plaid_verification" +require_relative "monite/types/all_document_export_response_schema" +require_relative "monite/types/all_overdue_reminders_response" +require_relative "monite/types/allowed_countries" +require_relative "monite/types/allowed_einvoicing_country_codes" +require_relative "monite/types/allowed_file_types" +require_relative "monite/types/analytics_data_point" +require_relative "monite/types/approval_policy_cursor_fields" +require_relative "monite/types/approval_policy_resource_script_item" +require_relative "monite/types/approval_policy_resource_trigger" +require_relative "monite/types/approval_policy_resource_status" +require_relative "monite/types/approval_policy_resource" +require_relative "monite/types/approval_policy_resource_list" +require_relative "monite/types/approval_policy_status" +require_relative "monite/types/approval_process_resource_list" +require_relative "monite/types/approval_process_step_resource" +require_relative "monite/types/approval_process_step_resource_list" +require_relative "monite/types/approval_process_step_status" +require_relative "monite/types/approval_request_create_by_role_request" +require_relative "monite/types/approval_request_create_by_user_request" +require_relative "monite/types/approval_request_create_request" +require_relative "monite/types/approval_request_cursor_fields" +require_relative "monite/types/approval_request_resource_list" +require_relative "monite/types/approval_request_resource_with_metadata" +require_relative "monite/types/approval_request_status" +require_relative "monite/types/bank_account" +require_relative "monite/types/bank_account_verification_type" +require_relative "monite/types/bank_account_verifications" +require_relative "monite/types/based_on_receivable_created_event_data" +require_relative "monite/types/based_on_transition_type" +require_relative "monite/types/biz_objects_schema_input" +require_relative "monite/types/biz_objects_schema_output" +require_relative "monite/types/business_profile_input" +require_relative "monite/types/business_profile_output" +require_relative "monite/types/button_theme" +require_relative "monite/types/card_theme" +require_relative "monite/types/comment_cursor_fields" +require_relative "monite/types/comment_resource" +require_relative "monite/types/comment_resource_list" +require_relative "monite/types/common_schema_input" +require_relative "monite/types/common_schema_output" +require_relative "monite/types/complete_refresh_verification_request" +require_relative "monite/types/complete_refresh_verification_response" +require_relative "monite/types/complete_verification_airwallex_plaid_request" +require_relative "monite/types/complete_verification_request" +require_relative "monite/types/complete_verification_response" +require_relative "monite/types/connection_status" +require_relative "monite/types/counterpart_address" +require_relative "monite/types/counterpart_address_resource_list" +require_relative "monite/types/counterpart_address_response_with_counterpart_id" +require_relative "monite/types/counterpart_bank_account_resource_list" +require_relative "monite/types/counterpart_bank_account_response" +require_relative "monite/types/counterpart_contact_response" +require_relative "monite/types/counterpart_contacts_resource_list" +require_relative "monite/types/counterpart_create_payload" +require_relative "monite/types/counterpart_cursor_fields" +require_relative "monite/types/counterpart_individual_create_payload" +require_relative "monite/types/counterpart_individual_response" +require_relative "monite/types/counterpart_individual_root_create_payload" +require_relative "monite/types/counterpart_individual_root_response" +require_relative "monite/types/counterpart_individual_root_update_payload" +require_relative "monite/types/counterpart_individual_update_payload" +require_relative "monite/types/counterpart_organization_create_payload" +require_relative "monite/types/counterpart_organization_response" +require_relative "monite/types/counterpart_organization_root_create_payload" +require_relative "monite/types/counterpart_organization_root_response" +require_relative "monite/types/counterpart_organization_root_update_payload" +require_relative "monite/types/counterpart_organization_update_payload" +require_relative "monite/types/counterpart_pagination_response" +require_relative "monite/types/counterpart_raw_address" +require_relative "monite/types/counterpart_raw_address_update_request" +require_relative "monite/types/counterpart_raw_bank_account" +require_relative "monite/types/counterpart_raw_bank_account_update_request" +require_relative "monite/types/counterpart_raw_data" +require_relative "monite/types/counterpart_raw_data_update_request" +require_relative "monite/types/counterpart_raw_vat_id" +require_relative "monite/types/counterpart_raw_vat_id_update_request" +require_relative "monite/types/counterpart_response" +require_relative "monite/types/counterpart_tag_category" +require_relative "monite/types/counterpart_tag_schema" +require_relative "monite/types/counterpart_type" +require_relative "monite/types/counterpart_update_payload" +require_relative "monite/types/counterpart_vat_id_resource_list" +require_relative "monite/types/counterpart_vat_id_response" +require_relative "monite/types/create_export_task_response_schema" +require_relative "monite/types/create_onboarding_link_request" +require_relative "monite/types/credit_note_cursor_fields" +require_relative "monite/types/credit_note_dimension_enum" +require_relative "monite/types/credit_note_line_item_create_request" +require_relative "monite/types/credit_note_line_item_cursor_fields" +require_relative "monite/types/credit_note_line_item_pagination_response" +require_relative "monite/types/credit_note_line_item_response" +require_relative "monite/types/credit_note_metric_enum" +require_relative "monite/types/credit_note_pagination_response" +require_relative "monite/types/credit_note_response" +require_relative "monite/types/credit_note_response_payload_entity" +require_relative "monite/types/credit_note_response_payload" +require_relative "monite/types/credit_note_state_enum" +require_relative "monite/types/currency_enum" +require_relative "monite/types/currency_exchange_schema" +require_relative "monite/types/currency_exchange_schema_2" +require_relative "monite/types/currency_settings_input" +require_relative "monite/types/currency_settings_output" +require_relative "monite/types/custom_template_data_schema" +require_relative "monite/types/custom_templates_cursor_fields" +require_relative "monite/types/custom_templates_pagination_response" +require_relative "monite/types/dns_record" +require_relative "monite/types/dns_record_purpose" +require_relative "monite/types/dns_record_type" +require_relative "monite/types/dns_records" +require_relative "monite/types/data_export_cursor_fields" +require_relative "monite/types/date_dimension_breakdown_enum" +require_relative "monite/types/day_of_month" +require_relative "monite/types/default_ledger_account_i_ds" +require_relative "monite/types/discount" +require_relative "monite/types/discount_type" +require_relative "monite/types/document_export_response_schema" +require_relative "monite/types/document_id_separators" +require_relative "monite/types/document_i_ds_settings" +require_relative "monite/types/document_i_ds_settings_next_number" +require_relative "monite/types/document_i_ds_settings_request" +require_relative "monite/types/document_object_type_request_enum" +require_relative "monite/types/document_type_enum" +require_relative "monite/types/document_type_prefix" +require_relative "monite/types/domain_list_response" +require_relative "monite/types/domain_response_dns_records" +require_relative "monite/types/domain_response" +require_relative "monite/types/e_invoicing_retrieve_list_data" +require_relative "monite/types/einvoice_schema_type_enum" +require_relative "monite/types/einvoicing_address" +require_relative "monite/types/einvoicing_connection_response" +require_relative "monite/types/einvoicing_network_credentials_response" +require_relative "monite/types/entity_address_response_schema" +require_relative "monite/types/entity_address_schema" +require_relative "monite/types/entity_bank_account_pagination_response" +require_relative "monite/types/entity_bank_account_response" +require_relative "monite/types/entity_business_structure" +require_relative "monite/types/entity_cursor_fields" +require_relative "monite/types/entity_individual_response" +require_relative "monite/types/entity_onboarding_data_response" +require_relative "monite/types/entity_onboarding_documents" +require_relative "monite/types/entity_organization_response" +require_relative "monite/types/entity_pagination_response" +require_relative "monite/types/entity_response" +require_relative "monite/types/entity_status_enum" +require_relative "monite/types/entity_type_enum" +require_relative "monite/types/entity_user_cursor_fields" +require_relative "monite/types/entity_user_pagination_response" +require_relative "monite/types/entity_user_response" +require_relative "monite/types/entity_vat_id_resource_list" +require_relative "monite/types/entity_vat_id_response" +require_relative "monite/types/error_schema" +require_relative "monite/types/error_schema_2" +require_relative "monite/types/error_schema_response" +require_relative "monite/types/error_schema_response_2" +require_relative "monite/types/estimated_monthly_revenue" +require_relative "monite/types/event_cursor_fields" +require_relative "monite/types/event_pagination_resource" +require_relative "monite/types/event_resource" +require_relative "monite/types/event_resource_for_webhook_client" +require_relative "monite/types/exchange_rate" +require_relative "monite/types/export_format" +require_relative "monite/types/export_object_schema" +require_relative "monite/types/export_payable_schema" +require_relative "monite/types/export_receivable_schema" +require_relative "monite/types/export_setting_cursor_fields" +require_relative "monite/types/extra_data_resource" +require_relative "monite/types/extra_data_resource_list" +require_relative "monite/types/file_response" +require_relative "monite/types/file_schema" +require_relative "monite/types/file_schema_2" +require_relative "monite/types/file_schema_3" +require_relative "monite/types/file_schema_4" +require_relative "monite/types/files_response" +require_relative "monite/types/financing_invoice" +require_relative "monite/types/financing_invoice_cursor_fields" +require_relative "monite/types/financing_invoice_list_response" +require_relative "monite/types/financing_invoice_type" +require_relative "monite/types/financing_offer" +require_relative "monite/types/financing_offers_response" +require_relative "monite/types/financing_push_invoices_request_invoice" +require_relative "monite/types/financing_push_invoices_response" +require_relative "monite/types/financing_token_response" +require_relative "monite/types/get_all_payment_reminders" +require_relative "monite/types/get_all_recurrences" +require_relative "monite/types/get_onboarding_requirements_response" +require_relative "monite/types/grant_type" +require_relative "monite/types/http_validation_error" +require_relative "monite/types/individual_response_schema" +require_relative "monite/types/individual_schema" +require_relative "monite/types/invoice" +require_relative "monite/types/invoice_file" +require_relative "monite/types/invoice_response_payload_entity" +require_relative "monite/types/invoice_response_payload" +require_relative "monite/types/item" +require_relative "monite/types/iteration_status" +require_relative "monite/types/label_n_value" +require_relative "monite/types/language_code_enum" +require_relative "monite/types/ledger_account_cursor_fields" +require_relative "monite/types/ledger_account_list_response" +require_relative "monite/types/ledger_account_response" +require_relative "monite/types/line_item" +require_relative "monite/types/line_item_cursor_fields" +require_relative "monite/types/line_item_internal_request" +require_relative "monite/types/line_item_pagination_response" +require_relative "monite/types/line_item_product" +require_relative "monite/types/line_item_product_create" +require_relative "monite/types/line_item_product_measure_unit" +require_relative "monite/types/line_item_product_vat_rate" +require_relative "monite/types/line_item_request" +require_relative "monite/types/line_item_response" +require_relative "monite/types/line_item_update" +require_relative "monite/types/line_items_replace_response" +require_relative "monite/types/line_items_response" +require_relative "monite/types/mail_sent_event_data" +require_relative "monite/types/mail_settings" +require_relative "monite/types/mailbox_data_response" +require_relative "monite/types/mailbox_object_type_enum" +require_relative "monite/types/mailbox_response" +require_relative "monite/types/message_response" +require_relative "monite/types/missing_fields" +require_relative "monite/types/missing_line_item_fields" +require_relative "monite/types/monite_all_payment_methods" +require_relative "monite/types/monite_all_payment_methods_types" +require_relative "monite/types/ocr_address" +require_relative "monite/types/ocr_response_invoice_receipt_data" +require_relative "monite/types/ocr_response_invoice_receipt_line_item" +require_relative "monite/types/ocr_response_invoice_receipt_line_item_raw" +require_relative "monite/types/object_match_types" +require_relative "monite/types/object_type" +require_relative "monite/types/object_type_available_comment" +require_relative "monite/types/object_type_enum" +require_relative "monite/types/ocr_auto_tagging_settings_request" +require_relative "monite/types/ocr_recognition_response" +require_relative "monite/types/ocr_status_enum" +require_relative "monite/types/onboarding_link_public_response" +require_relative "monite/types/onboarding_link_request" +require_relative "monite/types/onboarding_link_response" +require_relative "monite/types/onboarding_payment_methods_response" +require_relative "monite/types/onboarding_requirements_error" +require_relative "monite/types/onboarding_requirements_response" +require_relative "monite/types/onboarding_verification_error" +require_relative "monite/types/onboarding_verification_status_enum" +require_relative "monite/types/optional_individual_schema" +require_relative "monite/types/optional_organization_schema" +require_relative "monite/types/optional_person_address_request" +require_relative "monite/types/optional_person_relationship" +require_relative "monite/types/order_enum" +require_relative "monite/types/organization_response_schema" +require_relative "monite/types/organization_schema" +require_relative "monite/types/overdue_reminder_response" +require_relative "monite/types/overdue_reminder_term" +require_relative "monite/types/ownership_declaration_input" +require_relative "monite/types/ownership_declaration_output" +require_relative "monite/types/page_schema" +require_relative "monite/types/page_schema_2" +require_relative "monite/types/page_schema_3" +require_relative "monite/types/partner_metadata" +require_relative "monite/types/partner_metadata_response" +require_relative "monite/types/partner_project_settings_payload_output" +require_relative "monite/types/payable_action_enum" +require_relative "monite/types/payable_action_schema" +require_relative "monite/types/payable_aggregated_data_response" +require_relative "monite/types/payable_aggregated_item" +require_relative "monite/types/payable_analytics_response" +require_relative "monite/types/payable_credit_note_data" +require_relative "monite/types/payable_cursor_fields" +require_relative "monite/types/payable_dimension_enum" +require_relative "monite/types/payable_entity_address_schema" +require_relative "monite/types/payable_entity_individual_response" +require_relative "monite/types/payable_entity_organization_response" +require_relative "monite/types/payable_individual_schema" +require_relative "monite/types/payable_metric_enum" +require_relative "monite/types/payable_organization_schema" +require_relative "monite/types/payable_origin_enum" +require_relative "monite/types/payable_pagination_response" +require_relative "monite/types/payable_payment_term_discount" +require_relative "monite/types/payable_payment_term_final" +require_relative "monite/types/payable_payment_terms_create_payload" +require_relative "monite/types/payable_response_schema_other_extracted_data" +require_relative "monite/types/payable_response_schema" +require_relative "monite/types/payable_schema_input" +require_relative "monite/types/payable_schema_output" +require_relative "monite/types/payable_settings" +require_relative "monite/types/payable_state_enum" +require_relative "monite/types/payable_templates_variable" +require_relative "monite/types/payable_templates_variables_object" +require_relative "monite/types/payable_templates_variables_object_list" +require_relative "monite/types/payable_validation_response" +require_relative "monite/types/payable_validations_resource" +require_relative "monite/types/payables_fields_allowed_for_validate" +require_relative "monite/types/payables_variable_type" +require_relative "monite/types/payer_account_response" +require_relative "monite/types/payment_account_object" +require_relative "monite/types/payment_account_type" +require_relative "monite/types/payment_intent" +require_relative "monite/types/payment_intent_cursor_fields" +require_relative "monite/types/payment_intent_history" +require_relative "monite/types/payment_intent_history_response" +require_relative "monite/types/payment_intent_payout_method" +require_relative "monite/types/payment_intent_response" +require_relative "monite/types/payment_intents_list_response" +require_relative "monite/types/payment_intents_recipient" +require_relative "monite/types/payment_method" +require_relative "monite/types/payment_method_direction" +require_relative "monite/types/payment_method_requirements" +require_relative "monite/types/payment_method_status" +require_relative "monite/types/payment_object" +require_relative "monite/types/payment_object_payable" +require_relative "monite/types/payment_object_type" +require_relative "monite/types/payment_page_theme" +require_relative "monite/types/payment_priority_enum" +require_relative "monite/types/payment_received_event_data" +require_relative "monite/types/payment_record_cursor_fields" +require_relative "monite/types/payment_record_object_request" +require_relative "monite/types/payment_record_object_response" +require_relative "monite/types/payment_record_response" +require_relative "monite/types/payment_record_response_list" +require_relative "monite/types/payment_reminder_response" +require_relative "monite/types/payment_requirements" +require_relative "monite/types/payment_term" +require_relative "monite/types/payment_term_discount" +require_relative "monite/types/payment_term_discount_with_date" +require_relative "monite/types/payment_terms" +require_relative "monite/types/payment_terms_list_response" +require_relative "monite/types/payment_terms_response" +require_relative "monite/types/payments_batch_payment_request" +require_relative "monite/types/payments_batch_payment_response" +require_relative "monite/types/payments_batch_payment_status" +require_relative "monite/types/payments_settings_input" +require_relative "monite/types/payments_settings_output" +require_relative "monite/types/permission_enum" +require_relative "monite/types/person_address_request" +require_relative "monite/types/person_address_response" +require_relative "monite/types/person_onboarding_documents" +require_relative "monite/types/person_relationship_request" +require_relative "monite/types/person_relationship_response" +require_relative "monite/types/person_response" +require_relative "monite/types/persons_response" +require_relative "monite/types/platform" +require_relative "monite/types/preview_schema" +require_relative "monite/types/preview_schema_2" +require_relative "monite/types/preview_schema_3" +require_relative "monite/types/preview_template_response" +require_relative "monite/types/price" +require_relative "monite/types/pricing_plan" +require_relative "monite/types/process_resource_script_snapshot" +require_relative "monite/types/process_resource" +require_relative "monite/types/process_status_enum" +require_relative "monite/types/product_cursor_fields" +require_relative "monite/types/product_service_pagination_response" +require_relative "monite/types/product_service_response" +require_relative "monite/types/product_service_type_enum" +require_relative "monite/types/project_cursor_fields" +require_relative "monite/types/project_pagination_response" +require_relative "monite/types/project_resource" +require_relative "monite/types/public_payment_link_response" +require_relative "monite/types/purchase_order_counterpart_address_schema" +require_relative "monite/types/purchase_order_counterpart_individual_response" +require_relative "monite/types/purchase_order_counterpart_individual_root_response" +require_relative "monite/types/purchase_order_counterpart_organization_response" +require_relative "monite/types/purchase_order_counterpart_organization_root_response" +require_relative "monite/types/purchase_order_counterpart_schema" +require_relative "monite/types/purchase_order_cursor_fields" +require_relative "monite/types/purchase_order_email_preview_response" +require_relative "monite/types/purchase_order_email_sent_response" +require_relative "monite/types/purchase_order_item" +require_relative "monite/types/purchase_order_pagination_response" +require_relative "monite/types/purchase_order_response_schema_entity" +require_relative "monite/types/purchase_order_response_schema" +require_relative "monite/types/purchase_order_status_enum" +require_relative "monite/types/purchase_order_vat_id" +require_relative "monite/types/quote_response_payload_entity" +require_relative "monite/types/quote_response_payload" +require_relative "monite/types/quote_state_enum" +require_relative "monite/types/receivable_counterpart_contact" +require_relative "monite/types/receivable_counterpart_type" +require_relative "monite/types/receivable_counterpart_vat_id_response" +require_relative "monite/types/receivable_create_based_on_payload" +require_relative "monite/types/receivable_created_event_data" +require_relative "monite/types/receivable_cursor_fields" +require_relative "monite/types/receivable_edit_flow" +require_relative "monite/types/receivable_entity_address_schema" +require_relative "monite/types/receivable_entity_base" +require_relative "monite/types/receivable_entity_individual" +require_relative "monite/types/receivable_entity_individual_request" +require_relative "monite/types/receivable_entity_organization" +require_relative "monite/types/receivable_entity_organization_request" +require_relative "monite/types/receivable_entity_vat_id_response" +require_relative "monite/types/receivable_facade_create_invoice_payload" +require_relative "monite/types/receivable_facade_create_quote_payload" +require_relative "monite/types/receivable_facade_create_payload" +require_relative "monite/types/receivable_file_url" +require_relative "monite/types/receivable_history_cursor_fields" +require_relative "monite/types/receivable_history_event_type_enum" +require_relative "monite/types/receivable_history_pagination_response" +require_relative "monite/types/status_changed_event_data" +require_relative "monite/types/receivable_updated_event_data" +require_relative "monite/types/reminder_mail_sent_event_data" +require_relative "monite/types/receivable_history_response_event_data" +require_relative "monite/types/receivable_history_response" +require_relative "monite/types/receivable_mail_cursor_fields" +require_relative "monite/types/receivable_mail_pagination_response" +require_relative "monite/types/receivable_mail_recipient_state" +require_relative "monite/types/receivable_mail_recipients" +require_relative "monite/types/receivable_mail_response" +require_relative "monite/types/receivable_mail_status_enum" +require_relative "monite/types/receivable_pagination_response" +require_relative "monite/types/receivable_preview_response" +require_relative "monite/types/receivable_response" +require_relative "monite/types/receivable_send_response" +require_relative "monite/types/receivable_settings" +require_relative "monite/types/receivable_templates_variable" +require_relative "monite/types/receivable_templates_variables_object" +require_relative "monite/types/receivable_templates_variables_object_list" +require_relative "monite/types/receivable_type" +require_relative "monite/types/update_quote_payload" +require_relative "monite/types/update_invoice_payload" +require_relative "monite/types/update_credit_note_payload" +require_relative "monite/types/update_issued_invoice_payload" +require_relative "monite/types/receivable_update_payload" +require_relative "monite/types/receivables_preview_type_enum" +require_relative "monite/types/receivables_reminders_warning_message" +require_relative "monite/types/receivables_representation_of_counterpart_address" +require_relative "monite/types/receivables_representation_of_entity_bank_account" +require_relative "monite/types/receivables_send_response" +require_relative "monite/types/receivables_status_enum" +require_relative "monite/types/receivables_verify_response" +require_relative "monite/types/recipient" +require_relative "monite/types/recipient_account_response" +require_relative "monite/types/recipient_type" +require_relative "monite/types/recipients" +require_relative "monite/types/recurrence" +require_relative "monite/types/recurrence_iteration" +require_relative "monite/types/recurrence_status" +require_relative "monite/types/related_documents" +require_relative "monite/types/reminder" +require_relative "monite/types/reminder_type_enum" +require_relative "monite/types/reminders_settings" +require_relative "monite/types/repayment_schedule" +require_relative "monite/types/requirements_error" +require_relative "monite/types/response_item" +require_relative "monite/types/role_cursor_fields" +require_relative "monite/types/role_pagination_response" +require_relative "monite/types/role_response" +require_relative "monite/types/root_schema_input" +require_relative "monite/types/root_schema_output" +require_relative "monite/types/service_providers_enum" +require_relative "monite/types/settings_response" +require_relative "monite/types/signature" +require_relative "monite/types/single_onboarding_requirements_response" +require_relative "monite/types/single_payment_intent" +require_relative "monite/types/single_payment_intent_response" +require_relative "monite/types/source_of_payable_data_enum" +require_relative "monite/types/status_enum" +require_relative "monite/types/success_result" +require_relative "monite/types/suggested_payment_term" +require_relative "monite/types/supported_field_names" +require_relative "monite/types/supported_format_schema_object_type" +require_relative "monite/types/supported_format_schema" +require_relative "monite/types/sync_record_cursor_fields" +require_relative "monite/types/sync_record_resource" +require_relative "monite/types/sync_record_resource_list" +require_relative "monite/types/sync_status" +require_relative "monite/types/system_template_data_schema" +require_relative "monite/types/system_templates" +require_relative "monite/types/tag_category" +require_relative "monite/types/tag_cursor_fields" +require_relative "monite/types/tag_read_schema" +require_relative "monite/types/tags_pagination_response" +require_relative "monite/types/tax_component_response" +require_relative "monite/types/tax_rate_account_cursor_fields" +require_relative "monite/types/template_data_schema" +require_relative "monite/types/template_list_response" +require_relative "monite/types/template_receivable_response" +require_relative "monite/types/template_type_enum" +require_relative "monite/types/term_final_with_date" +require_relative "monite/types/terms_of_service_acceptance_input" +require_relative "monite/types/terms_of_service_acceptance_output" +require_relative "monite/types/text_template_response" +require_relative "monite/types/text_template_response_list" +require_relative "monite/types/text_template_type" +require_relative "monite/types/total_vat_amount_item" +require_relative "monite/types/unit" +require_relative "monite/types/unit_list_response" +require_relative "monite/types/unit_request" +require_relative "monite/types/unit_response" +require_relative "monite/types/update_credit_note" +require_relative "monite/types/update_entity_address_schema" +require_relative "monite/types/update_entity_request" +require_relative "monite/types/update_invoice" +require_relative "monite/types/update_issued_invoice_entity" +require_relative "monite/types/update_issued_invoice" +require_relative "monite/types/update_product_for_credit_note" +require_relative "monite/types/update_line_item_for_credit_note" +require_relative "monite/types/update_quote" +require_relative "monite/types/validation_error_loc_item" +require_relative "monite/types/validation_error" +require_relative "monite/types/variable" +require_relative "monite/types/variables_object" +require_relative "monite/types/variables_object_list" +require_relative "monite/types/variables_type" +require_relative "monite/types/vat_id_type_enum" +require_relative "monite/types/vat_mode_enum" +require_relative "monite/types/vat_rate_creator" +require_relative "monite/types/vat_rate_list_response" +require_relative "monite/types/vat_rate_response" +require_relative "monite/types/vat_rate_status_enum" +require_relative "monite/types/verification_airwallex_plaid_request" +require_relative "monite/types/verification_airwallex_plaid_response" +require_relative "monite/types/verification_error" +require_relative "monite/types/verification_request" +require_relative "monite/types/verification_response" +require_relative "monite/types/verification_status_enum" +require_relative "monite/types/verify_response" +require_relative "monite/types/wc_business_status" +require_relative "monite/types/wc_invoice_status" +require_relative "monite/types/wc_offer_status" +require_relative "monite/types/wc_repayment_type" +require_relative "monite/types/webhook_delivery_cursor_fields" +require_relative "monite/types/webhook_delivery_pagination_resource" +require_relative "monite/types/webhook_delivery_resource" +require_relative "monite/types/webhook_object_type" +require_relative "monite/types/webhook_subscription_cursor_fields" +require_relative "monite/types/webhook_subscription_pagination_resource" +require_relative "monite/types/webhook_subscription_resource" +require_relative "monite/types/webhook_subscription_resource_with_secret" +require_relative "monite/types/webhook_subscription_status" diff --git a/monite.gemspec b/monite.gemspec new file mode 100644 index 0000000..0633ec3 --- /dev/null +++ b/monite.gemspec @@ -0,0 +1,34 @@ +# frozen_string_literal: true +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" +require_relative "lib/gemconfig" + +Gem::Specification.new do | spec | + spec.name = "monite" + spec.version = "0.1.0" + spec.authors = Monite::Gemconfig::AUTHORS + spec.email = Monite::Gemconfig::EMAIL + spec.summary = Monite::Gemconfig::SUMMARY + spec.description = Monite::Gemconfig::DESCRIPTION + spec.homepage = Monite::Gemconfig::HOMEPAGE + spec.required_ruby_version = ">= 2.7.0" + spec.metadata["homepage_uri"] = spec.homepage + spec.metadata["source_code_uri"] = Monite::Gemconfig::SOURCE_CODE_URI + spec.metadata["changelog_uri"] = Monite::Gemconfig::CHANGELOG_URI + spec.files = Dir.glob("lib/**/*") + spec.bindir = "exe" + spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } + spec.require_paths = ["lib"] + spec.add_dependency "faraday", ">= 1.10", "< 3.0" + spec.add_dependency "faraday-net_http", ">= 1.0", "< 4.0" + spec.add_dependency "faraday-retry", ">= 1.0", "< 3.0" + spec.add_dependency "async-http-faraday", ">= 0.0", "< 1.0" + spec.add_dependency "mini_mime" + spec.add_dependency "faraday-multipart", ">= 0.0", "< 2.0" +end \ No newline at end of file diff --git a/test/test_helper.rb b/test/test_helper.rb new file mode 100644 index 0000000..f17b9af --- /dev/null +++ b/test/test_helper.rb @@ -0,0 +1,6 @@ +# frozen_string_literal: true + +$LOAD_PATH.unshift File.expand_path("../lib", __dir__) + +require "minitest/autorun" +require "monite" diff --git a/test/test_monite.rb b/test/test_monite.rb new file mode 100644 index 0000000..ac725de --- /dev/null +++ b/test/test_monite.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true +require_relative "test_helper" +require "monite" + +# Basic Monite tests +class TestMonite < Minitest::Test + def test_function + # Monite::Client.new + end +end \ No newline at end of file