smartbill-sdk 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/AGENTS.md +211 -0
- data/CHANGELOG.md +18 -0
- data/LICENSE.txt +21 -0
- data/README.md +265 -0
- data/Rakefile +22 -0
- data/Steepfile +6 -0
- data/docs/openapi.json +9741 -0
- data/examples/create_estimate_sync.rb +53 -0
- data/examples/create_invoice_eur_product_in_ron.rb +100 -0
- data/examples/create_invoice_sync.rb +57 -0
- data/examples/create_payment_sync.rb +36 -0
- data/examples/fiscal_receipt_sync.rb +50 -0
- data/examples/invoice_lifecycle_sync.rb +43 -0
- data/examples/list_series_sync.rb +27 -0
- data/examples/send_email_sync.rb +40 -0
- data/examples/taxes_and_stocks_sync.rb +48 -0
- data/lib/smartbill/sdk/api_error.rb +27 -0
- data/lib/smartbill/sdk/auth_error.rb +8 -0
- data/lib/smartbill/sdk/client.rb +68 -0
- data/lib/smartbill/sdk/contracts/base.rb +33 -0
- data/lib/smartbill/sdk/contracts/email_contract.rb +29 -0
- data/lib/smartbill/sdk/contracts/estimate_contract.rb +18 -0
- data/lib/smartbill/sdk/contracts/invoice_contract.rb +29 -0
- data/lib/smartbill/sdk/contracts/invoice_payment_contract.rb +18 -0
- data/lib/smartbill/sdk/contracts/invoice_ref_contract.rb +19 -0
- data/lib/smartbill/sdk/contracts/payment_contract.rb +37 -0
- data/lib/smartbill/sdk/contracts/storno_contract.rb +17 -0
- data/lib/smartbill/sdk/contracts.rb +19 -0
- data/lib/smartbill/sdk/error.rb +8 -0
- data/lib/smartbill/sdk/models/base_response.rb +16 -0
- data/lib/smartbill/sdk/models/client.rb +26 -0
- data/lib/smartbill/sdk/models/discount_type.rb +13 -0
- data/lib/smartbill/sdk/models/document_type.rb +13 -0
- data/lib/smartbill/sdk/models/email_document.rb +23 -0
- data/lib/smartbill/sdk/models/email_response.rb +12 -0
- data/lib/smartbill/sdk/models/email_status.rb +13 -0
- data/lib/smartbill/sdk/models/estimate.rb +32 -0
- data/lib/smartbill/sdk/models/fiscal_receipt_response.rb +16 -0
- data/lib/smartbill/sdk/models/invoice.rb +44 -0
- data/lib/smartbill/sdk/models/invoice_create_response.rb +10 -0
- data/lib/smartbill/sdk/models/invoice_payment.rb +15 -0
- data/lib/smartbill/sdk/models/invoice_ref.rb +24 -0
- data/lib/smartbill/sdk/models/payment.rb +49 -0
- data/lib/smartbill/sdk/models/payment_status_response.rb +19 -0
- data/lib/smartbill/sdk/models/payment_type.rb +22 -0
- data/lib/smartbill/sdk/models/product.rb +38 -0
- data/lib/smartbill/sdk/models/proforma_invoices_response.rb +13 -0
- data/lib/smartbill/sdk/models/series.rb +14 -0
- data/lib/smartbill/sdk/models/series_list_response.rb +14 -0
- data/lib/smartbill/sdk/models/stock_list.rb +13 -0
- data/lib/smartbill/sdk/models/stock_product.rb +15 -0
- data/lib/smartbill/sdk/models/stock_warehouse.rb +13 -0
- data/lib/smartbill/sdk/models/stocks_response.rb +14 -0
- data/lib/smartbill/sdk/models/storno_request.rb +17 -0
- data/lib/smartbill/sdk/models/storno_response.rb +14 -0
- data/lib/smartbill/sdk/models/struct.rb +102 -0
- data/lib/smartbill/sdk/models/tax.rb +14 -0
- data/lib/smartbill/sdk/models/taxes_response.rb +14 -0
- data/lib/smartbill/sdk/models.rb +17 -0
- data/lib/smartbill/sdk/net_http_adapter.rb +62 -0
- data/lib/smartbill/sdk/rate_limit_error.rb +9 -0
- data/lib/smartbill/sdk/response.rb +12 -0
- data/lib/smartbill/sdk/services/base_service.rb +39 -0
- data/lib/smartbill/sdk/services/configuration_service.rb +29 -0
- data/lib/smartbill/sdk/services/email_service.rb +18 -0
- data/lib/smartbill/sdk/services/estimates_service.rb +60 -0
- data/lib/smartbill/sdk/services/invoices_service.rb +69 -0
- data/lib/smartbill/sdk/services/payments_service.rb +50 -0
- data/lib/smartbill/sdk/services/stocks_service.rb +21 -0
- data/lib/smartbill/sdk/services.rb +30 -0
- data/lib/smartbill/sdk/transport/rate_limiter.rb +49 -0
- data/lib/smartbill/sdk/transport/request.rb +17 -0
- data/lib/smartbill/sdk/transport.rb +162 -0
- data/lib/smartbill/sdk/transport_error.rb +8 -0
- data/lib/smartbill/sdk/types.rb +22 -0
- data/lib/smartbill/sdk/validation_error.rb +8 -0
- data/lib/smartbill/sdk/version.rb +7 -0
- data/lib/smartbill/sdk.rb +31 -0
- data/sig/smartbill/sdk.rbs +661 -0
- data/skills/README.md +35 -0
- data/skills/smartbill-email/SKILL.md +120 -0
- data/skills/smartbill-invoices/SKILL.md +178 -0
- data/skills/smartbill-payments/SKILL.md +194 -0
- metadata +214 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Contracts
|
|
6
|
+
# Validation contract for {Models::InvoicePayment} (payment at
|
|
7
|
+
# issuance, embedded in an {Models::Invoice}).
|
|
8
|
+
class InvoicePaymentContract < Base
|
|
9
|
+
params do
|
|
10
|
+
required(:value).filled(:float, gt?: 0)
|
|
11
|
+
optional(:payment_series).maybe(:string)
|
|
12
|
+
required(:type).filled(:string)
|
|
13
|
+
optional(:is_cash).maybe(:bool)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Contracts
|
|
6
|
+
# Validation contract for {Models::InvoiceRef}.
|
|
7
|
+
#
|
|
8
|
+
# Ensures the document reference has non-blank +series_name+ and
|
|
9
|
+
# +number+ (the struct already enforces presence; this adds the
|
|
10
|
+
# "filled" semantic check).
|
|
11
|
+
class InvoiceRefContract < Base
|
|
12
|
+
params do
|
|
13
|
+
required(:series_name).filled(:string)
|
|
14
|
+
required(:number).filled(:string)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Contracts
|
|
6
|
+
# Validation contract for {Models::Payment}.
|
|
7
|
+
#
|
|
8
|
+
# Validates +type+ against the SmartBill payment-type set, +value+
|
|
9
|
+
# (positive when present), date format, and +precision+.
|
|
10
|
+
class PaymentContract < Base
|
|
11
|
+
# Allowed +type+ values (mirrors {Models::PaymentType}).
|
|
12
|
+
PAYMENT_TYPES = [
|
|
13
|
+
"Chitanta",
|
|
14
|
+
"Bon",
|
|
15
|
+
"Card",
|
|
16
|
+
"Card online",
|
|
17
|
+
"CEC",
|
|
18
|
+
"Bilet ordin",
|
|
19
|
+
"Ordin plata",
|
|
20
|
+
"Mandat postal",
|
|
21
|
+
"Extras de cont",
|
|
22
|
+
"Ramburs",
|
|
23
|
+
"Alta incasare"
|
|
24
|
+
].freeze
|
|
25
|
+
|
|
26
|
+
params do
|
|
27
|
+
required(:company_vat_code).filled(:string)
|
|
28
|
+
optional(:issue_date).maybe(:string, format?: DATE_REGEX)
|
|
29
|
+
optional(:value).maybe(:float, gt?: 0)
|
|
30
|
+
optional(:type).maybe(:string, included_in?: PAYMENT_TYPES)
|
|
31
|
+
optional(:precision).maybe(:integer, gteq?: 0)
|
|
32
|
+
optional(:exchange_rate).maybe(:float, gt?: 0)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Contracts
|
|
6
|
+
# Validation contract for {Models::StornoRequest} (+POST /invoice/reverse+).
|
|
7
|
+
class StornoContract < Base
|
|
8
|
+
params do
|
|
9
|
+
required(:company_vat_code).filled(:string)
|
|
10
|
+
required(:series_name).filled(:string)
|
|
11
|
+
required(:number).filled(:string)
|
|
12
|
+
optional(:issue_date).maybe(:string, format?: DATE_REGEX)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "dry-validation"
|
|
4
|
+
|
|
5
|
+
module Smartbill
|
|
6
|
+
module Sdk
|
|
7
|
+
# dry-validation contracts for SmartBill request models.
|
|
8
|
+
#
|
|
9
|
+
# Each request model has a {Models::Struct} (shape + coercion + required
|
|
10
|
+
# presence) and a {Contracts::Contract} (semantic rules: date formats,
|
|
11
|
+
# enum membership, numeric ranges). Services validate a struct against
|
|
12
|
+
# its contract before sending and raise {ValidationError} on failure.
|
|
13
|
+
#
|
|
14
|
+
# Each contract lives in its own file (e.g. `contracts/invoice_contract.rb`
|
|
15
|
+
# defines `InvoiceContract`) and is autoloaded by Zeitwerk.
|
|
16
|
+
module Contracts
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Common envelope: +errorText+/+message+/+number+/+series+/+url+.
|
|
7
|
+
class BaseResponse < Struct
|
|
8
|
+
attribute :error_text, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :message, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :number, Types::Strict::String.optional.default(nil)
|
|
11
|
+
attribute :series, Types::Strict::String.optional.default(nil)
|
|
12
|
+
attribute :url, Types::Strict::String.optional.default(nil)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Client data (+client+ / +clientMin+).
|
|
7
|
+
class Client < Struct
|
|
8
|
+
attribute :name, Types::Strict::String
|
|
9
|
+
attribute :vat_code, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :code, Types::Strict::String.optional.default(nil)
|
|
11
|
+
attribute :address, Types::Strict::String.optional.default(nil)
|
|
12
|
+
attribute :reg_com, Types::Strict::String.optional.default(nil)
|
|
13
|
+
attribute :is_tax_payer, Types::Strict::Bool.optional.default(nil)
|
|
14
|
+
attribute :contact, Types::Strict::String.optional.default(nil)
|
|
15
|
+
attribute :phone, Types::Strict::String.optional.default(nil)
|
|
16
|
+
attribute :city, Types::Strict::String.optional.default(nil)
|
|
17
|
+
attribute :county, Types::Strict::String.optional.default(nil)
|
|
18
|
+
attribute :country, Types::Strict::String.optional.default(nil)
|
|
19
|
+
attribute :email, Types::Strict::String.optional.default(nil)
|
|
20
|
+
attribute :bank, Types::Strict::String.optional.default(nil)
|
|
21
|
+
attribute :iban, Types::Strict::String.optional.default(nil)
|
|
22
|
+
attribute :save_to_db, Types::Strict::Bool.optional.default(nil)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Request body for +POST /document/send+.
|
|
7
|
+
#
|
|
8
|
+
# +subject+ and +body_text+ should be Base64-encoded by the caller
|
|
9
|
+
# (as required by the SmartBill API).
|
|
10
|
+
class EmailDocument < Struct
|
|
11
|
+
attribute :company_vat_code, Types::Strict::String
|
|
12
|
+
attribute :series_name, Types::Strict::String
|
|
13
|
+
attribute :number, Types::Strict::String
|
|
14
|
+
attribute :type, Types::Strict::String.optional.default(nil)
|
|
15
|
+
attribute :subject, Types::Strict::String.optional.default(nil)
|
|
16
|
+
attribute :to, Types::Strict::String.optional.default(nil)
|
|
17
|
+
attribute :cc, Types::Strict::String.optional.default(nil)
|
|
18
|
+
attribute :bcc, Types::Strict::String.optional.default(nil)
|
|
19
|
+
attribute :body_text, Types::Strict::String.optional.default(nil)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# The +status+ block of an {EmailResponse}.
|
|
7
|
+
class EmailStatus < Struct
|
|
8
|
+
attribute :code, Types::StrOrInt.optional.default(nil)
|
|
9
|
+
attribute :message, Types::Strict::String.optional.default(nil)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Request body for +POST /estimate+ (emitere proforma).
|
|
7
|
+
class Estimate < Struct
|
|
8
|
+
attribute :company_vat_code, Types::Strict::String
|
|
9
|
+
attribute :client, Client.optional.default(nil)
|
|
10
|
+
attribute :is_draft, Types::Strict::Bool.optional.default(nil)
|
|
11
|
+
attribute :issue_date, Types::Strict::String.optional.default(nil)
|
|
12
|
+
attribute :series_name, Types::Strict::String.optional.default(nil)
|
|
13
|
+
attribute :currency, Types::Strict::String.optional.default(nil)
|
|
14
|
+
attribute :exchange_rate, Types::Coercible::Float.optional.default(nil)
|
|
15
|
+
attribute :language, Types::Strict::String.optional.default(nil)
|
|
16
|
+
attribute :precision, Types::Coercible::Integer.optional.default(nil)
|
|
17
|
+
attribute :issuer_cnp, Types::Strict::String.optional.default(nil)
|
|
18
|
+
attribute :issuer_name, Types::Strict::String.optional.default(nil)
|
|
19
|
+
attribute :aviz, Types::Strict::String.optional.default(nil)
|
|
20
|
+
attribute :due_date, Types::Strict::String.optional.default(nil)
|
|
21
|
+
attribute :mentions, Types::Strict::String.optional.default(nil)
|
|
22
|
+
attribute :observations, Types::Strict::String.optional.default(nil)
|
|
23
|
+
attribute :delegate_name, Types::Strict::String.optional.default(nil)
|
|
24
|
+
attribute :delegate_identity_card, Types::Strict::String.optional.default(nil)
|
|
25
|
+
attribute :delegate_auto, Types::Strict::String.optional.default(nil)
|
|
26
|
+
attribute :payment_url, Types::Strict::String.optional.default(nil)
|
|
27
|
+
attribute :use_stock, Types::Strict::Bool.optional.default(nil)
|
|
28
|
+
attribute :products, Types::Array.of(Product).default([].freeze)
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Response for bon-fiscal endpoints.
|
|
7
|
+
#
|
|
8
|
+
# Used by +POST /payment+ when +type='Bon'+ (the response includes the
|
|
9
|
+
# generated receipt id) and by +GET /payment/text+ (which returns the
|
|
10
|
+
# base64-encoded fiscal-printer text in +message+).
|
|
11
|
+
class FiscalReceiptResponse < BaseResponse
|
|
12
|
+
attribute :id, Types::StrOrInt.optional.default(nil)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Request body for +POST /invoice+ (emitere factura).
|
|
7
|
+
#
|
|
8
|
+
# The JSON is sent as a bare object (the SmartBill +invoice+ envelope
|
|
9
|
+
# key is handled by the API itself for this endpoint).
|
|
10
|
+
class Invoice < Struct
|
|
11
|
+
attribute :company_vat_code, Types::Strict::String
|
|
12
|
+
attribute :client, Client.optional.default(nil)
|
|
13
|
+
attribute :is_draft, Types::Strict::Bool.optional.default(nil)
|
|
14
|
+
attribute :issue_date, Types::Strict::String.optional.default(nil)
|
|
15
|
+
attribute :series_name, Types::Strict::String.optional.default(nil)
|
|
16
|
+
attribute :currency, Types::Strict::String.optional.default(nil)
|
|
17
|
+
attribute :exchange_rate, Types::Coercible::Float.optional.default(nil)
|
|
18
|
+
attribute :language, Types::Strict::String.optional.default(nil)
|
|
19
|
+
attribute :precision, Types::Coercible::Integer.optional.default(nil)
|
|
20
|
+
attribute :issuer_cnp, Types::Strict::String.optional.default(nil)
|
|
21
|
+
attribute :issuer_name, Types::Strict::String.optional.default(nil)
|
|
22
|
+
attribute :aviz, Types::Strict::String.optional.default(nil)
|
|
23
|
+
attribute :due_date, Types::Strict::String.optional.default(nil)
|
|
24
|
+
attribute :mentions, Types::Strict::String.optional.default(nil)
|
|
25
|
+
attribute :observations, Types::Strict::String.optional.default(nil)
|
|
26
|
+
attribute :delegate_auto, Types::Strict::String.optional.default(nil)
|
|
27
|
+
attribute :delegate_identity_card, Types::Strict::String.optional.default(nil)
|
|
28
|
+
attribute :delegate_name, Types::Strict::String.optional.default(nil)
|
|
29
|
+
attribute :delivery_date, Types::Strict::String.optional.default(nil)
|
|
30
|
+
attribute :payment_date, Types::Strict::String.optional.default(nil)
|
|
31
|
+
attribute :use_stock, Types::Strict::Bool.optional.default(nil)
|
|
32
|
+
attribute :use_estimate_details, Types::Strict::Bool.optional.default(nil)
|
|
33
|
+
attribute :use_payment_tax, Types::Strict::Bool.optional.default(nil)
|
|
34
|
+
attribute :payment_base, Types::Coercible::Float.optional.default(nil)
|
|
35
|
+
attribute :colected_tax, Types::Coercible::Float.optional.default(nil)
|
|
36
|
+
attribute :payment_total, Types::Coercible::Float.optional.default(nil)
|
|
37
|
+
attribute :payment_url, Types::Strict::String.optional.default(nil)
|
|
38
|
+
attribute :estimate, InvoiceRef.optional.default(nil)
|
|
39
|
+
attribute :products, Types::Array.of(Product).default([].freeze)
|
|
40
|
+
attribute :payment, InvoicePayment.optional.default(nil)
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Payment-at-issuance block embedded in an {Invoice}.
|
|
7
|
+
class InvoicePayment < Struct
|
|
8
|
+
attribute :value, Types::Coercible::Float
|
|
9
|
+
attribute :payment_series, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :type, Types::Strict::String
|
|
11
|
+
attribute :is_cash, Types::Strict::Bool.optional.default(nil)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Reference to an existing document (series + number).
|
|
7
|
+
#
|
|
8
|
+
# Requests use +seriesName+, but the +GET /estimate/invoices+
|
|
9
|
+
# response returns +series+. Both names are accepted on input;
|
|
10
|
+
# serialization always emits +seriesName+.
|
|
11
|
+
class InvoiceRef < Struct
|
|
12
|
+
# Map the API's bare "series" response key onto +series_name+
|
|
13
|
+
# in addition to the inherited snake_case/camelCase transform.
|
|
14
|
+
transform_keys do |key|
|
|
15
|
+
name = INFLECTOR.underscore(key.to_s).to_sym
|
|
16
|
+
name == :series ? :series_name : name
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
attribute :series_name, Types::Strict::String
|
|
20
|
+
attribute :number, Types::Strict::String
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Request body for +POST /payment+.
|
|
7
|
+
#
|
|
8
|
+
# Covers general incasari, chitanta, and bon fiscal. Fields unused for
|
|
9
|
+
# a given +type+ are simply left as nil. Bon-fiscal +received_*+ fields
|
|
10
|
+
# are all optional and default to 0 on the server side.
|
|
11
|
+
class Payment < Struct
|
|
12
|
+
attribute :company_vat_code, Types::Strict::String
|
|
13
|
+
attribute :client, Client.optional.default(nil)
|
|
14
|
+
attribute :issue_date, Types::Strict::String.optional.default(nil)
|
|
15
|
+
attribute :currency, Types::Strict::String.optional.default(nil)
|
|
16
|
+
attribute :language, Types::Strict::String.optional.default(nil)
|
|
17
|
+
attribute :exchange_rate, Types::Coercible::Float.optional.default(nil)
|
|
18
|
+
attribute :precision, Types::Coercible::Integer.optional.default(nil)
|
|
19
|
+
attribute :issuer_cnp, Types::Strict::String.optional.default(nil)
|
|
20
|
+
attribute :series_name, Types::Strict::String.optional.default(nil)
|
|
21
|
+
attribute :number, Types::Strict::String.optional.default(nil)
|
|
22
|
+
attribute :value, Types::Coercible::Float.optional.default(nil)
|
|
23
|
+
attribute :text, Types::Strict::String.optional.default(nil)
|
|
24
|
+
attribute :translated_text, Types::Strict::String.optional.default(nil)
|
|
25
|
+
attribute :is_draft, Types::Strict::Bool.optional.default(nil)
|
|
26
|
+
attribute :type, Types::Strict::String.optional.default(nil)
|
|
27
|
+
attribute :is_cash, Types::Strict::Bool.optional.default(nil)
|
|
28
|
+
attribute :observation, Types::Strict::String.optional.default(nil)
|
|
29
|
+
attribute :use_invoice_details, Types::Strict::Bool.optional.default(nil)
|
|
30
|
+
attribute :invoices_list, Types::Array.of(InvoiceRef).optional.default(nil)
|
|
31
|
+
# Bon fiscal
|
|
32
|
+
attribute :return_fiscal_printer_text, Types::Strict::Bool.optional.default(nil)
|
|
33
|
+
attribute :use_stock, Types::Strict::Bool.optional.default(nil)
|
|
34
|
+
attribute :products, Types::Array.of(Product).optional.default(nil)
|
|
35
|
+
attribute :received_cash, Types::Coercible::Float.optional.default(nil)
|
|
36
|
+
attribute :received_card, Types::Coercible::Float.optional.default(nil)
|
|
37
|
+
attribute :received_tichete_masa, Types::Coercible::Float.optional.default(nil)
|
|
38
|
+
attribute :received_tichete_cadou, Types::Coercible::Float.optional.default(nil)
|
|
39
|
+
attribute :received_ordin_de_plata, Types::Coercible::Float.optional.default(nil)
|
|
40
|
+
attribute :received_cec, Types::Coercible::Float.optional.default(nil)
|
|
41
|
+
attribute :received_credit, Types::Coercible::Float.optional.default(nil)
|
|
42
|
+
attribute :received_cupon, Types::Coercible::Float.optional.default(nil)
|
|
43
|
+
attribute :received_puncte_de_fidelitate, Types::Coercible::Float.optional.default(nil)
|
|
44
|
+
attribute :received_bonuri_valoare_fixa, Types::Coercible::Float.optional.default(nil)
|
|
45
|
+
attribute :received_moneda_alternativa, Types::Coercible::Float.optional.default(nil)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Response for +GET /invoice/paymentstatus+.
|
|
7
|
+
class PaymentStatusResponse < Struct
|
|
8
|
+
attribute :error_text, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :message, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :number, Types::Strict::String.optional.default(nil)
|
|
11
|
+
attribute :series, Types::Strict::String.optional.default(nil)
|
|
12
|
+
attribute :invoice_total_amount, Types::Coercible::Float.optional.default(nil)
|
|
13
|
+
attribute :paid_amount, Types::Coercible::Float.optional.default(nil)
|
|
14
|
+
attribute :unpaid_amount, Types::Coercible::Float.optional.default(nil)
|
|
15
|
+
attribute :paid, Types::Strict::Bool.optional.default(nil)
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Possible values for +type+ on payments / incasari.
|
|
7
|
+
module PaymentType
|
|
8
|
+
CHITANTA = "Chitanta"
|
|
9
|
+
BON = "Bon"
|
|
10
|
+
CARD = "Card"
|
|
11
|
+
CARD_ONLINE = "Card online"
|
|
12
|
+
CEC = "CEC"
|
|
13
|
+
BILET_ORDIN = "Bilet ordin"
|
|
14
|
+
ORDIN_PLATA = "Ordin plata"
|
|
15
|
+
MANDAT_POSTAL = "Mandat postal"
|
|
16
|
+
EXTRAS_DE_CONT = "Extras de cont"
|
|
17
|
+
RAMBURS = "Ramburs"
|
|
18
|
+
ALTA_INCASARE = "Alta incasare"
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# A product or discount line on an invoice / proforma / bon fiscal.
|
|
7
|
+
#
|
|
8
|
+
# Discount-specific fields (+number_of_items+, +discount_type+,
|
|
9
|
+
# +discount_percentage+, +discount_value+, +discount_tax_value+) are
|
|
10
|
+
# only relevant when +is_discount+ is true.
|
|
11
|
+
class Product < Struct
|
|
12
|
+
attribute :name, Types::Strict::String
|
|
13
|
+
attribute :code, Types::Strict::String.optional.default(nil)
|
|
14
|
+
attribute :product_description, Types::Strict::String.optional.default(nil)
|
|
15
|
+
attribute :translated_name, Types::Strict::String.optional.default(nil)
|
|
16
|
+
attribute :translated_measuring_unit, Types::Strict::String.optional.default(nil)
|
|
17
|
+
attribute :is_discount, Types::Strict::Bool.optional.default(nil)
|
|
18
|
+
attribute :number_of_items, Types::Coercible::Integer.optional.default(nil)
|
|
19
|
+
attribute :measuring_unit_name, Types::Strict::String.optional.default(nil)
|
|
20
|
+
attribute :currency, Types::Strict::String.optional.default(nil)
|
|
21
|
+
attribute :quantity, Types::Coercible::Float.optional.default(nil)
|
|
22
|
+
attribute :price, Types::Coercible::Float.optional.default(nil)
|
|
23
|
+
attribute :is_tax_included, Types::Strict::Bool.optional.default(nil)
|
|
24
|
+
attribute :tax_name, Types::Strict::String.optional.default(nil)
|
|
25
|
+
attribute :tax_percentage, Types::Coercible::Float.optional.default(nil)
|
|
26
|
+
attribute :exchange_rate, Types::Coercible::Float.optional.default(nil)
|
|
27
|
+
attribute :save_to_db, Types::Strict::Bool.optional.default(nil)
|
|
28
|
+
attribute :warehouse_name, Types::Strict::String.optional.default(nil)
|
|
29
|
+
attribute :is_service, Types::Strict::Bool.optional.default(nil)
|
|
30
|
+
# Discount fields
|
|
31
|
+
attribute :discount_type, Types::Coercible::Integer.optional.default(nil)
|
|
32
|
+
attribute :discount_percentage, Types::Coercible::Float.optional.default(nil)
|
|
33
|
+
attribute :discount_value, Types::Coercible::Float.optional.default(nil)
|
|
34
|
+
attribute :discount_tax_value, Types::Coercible::Float.optional.default(nil)
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Response for +GET /estimate/invoices+.
|
|
7
|
+
class ProformaInvoicesResponse < BaseResponse
|
|
8
|
+
attribute :are_invoices_created, Types::Strict::Bool.optional.default(nil)
|
|
9
|
+
attribute :invoices, Types::Array.of(InvoiceRef).default([].freeze)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# A document series entry from +GET /series+.
|
|
7
|
+
class Series < Struct
|
|
8
|
+
attribute :name, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :next_number, Types::StrOrInt.optional.default(nil)
|
|
10
|
+
attribute :type, Types::Strict::String.optional.default(nil)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Parsed response of +GET /series+.
|
|
7
|
+
class SeriesListResponse < Struct
|
|
8
|
+
attribute :error_text, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :message, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :list, Types::Array.of(Series).default([].freeze)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# A +list+ entry under the stocks response — products + warehouse.
|
|
7
|
+
class StockList < Struct
|
|
8
|
+
attribute :products, Types::Array.of(StockProduct).default([].freeze)
|
|
9
|
+
attribute :warehouse, StockWarehouse.optional.default(nil)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# A product entry within a stock list.
|
|
7
|
+
class StockProduct < Struct
|
|
8
|
+
attribute :measuring_unit, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :product_code, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :product_name, Types::Strict::String.optional.default(nil)
|
|
11
|
+
attribute :quantity, Types::Coercible::Float.optional.default(nil)
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Warehouse details attached to a stock list entry.
|
|
7
|
+
class StockWarehouse < Struct
|
|
8
|
+
attribute :warehouse_name, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :warehouse_type, Types::Strict::String.optional.default(nil)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Parsed response of +GET /stocks+.
|
|
7
|
+
class StocksResponse < Struct
|
|
8
|
+
attribute :error_text, Types::Strict::String.optional.default(nil)
|
|
9
|
+
attribute :message, Types::Strict::String.optional.default(nil)
|
|
10
|
+
attribute :list, Types::Array.of(StockList).default([].freeze)
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Smartbill
|
|
4
|
+
module Sdk
|
|
5
|
+
module Models
|
|
6
|
+
# Request body for +POST /invoice/reverse+ (stornare factura).
|
|
7
|
+
#
|
|
8
|
+
# Sent as a bare object (no envelope).
|
|
9
|
+
class StornoRequest < Struct
|
|
10
|
+
attribute :company_vat_code, Types::Strict::String
|
|
11
|
+
attribute :series_name, Types::Strict::String
|
|
12
|
+
attribute :number, Types::Strict::String
|
|
13
|
+
attribute :issue_date, Types::Strict::String.optional.default(nil)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|