qube_sync 0.2.3 → 0.4.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 +4 -4
- data/CHANGELOG.md +93 -0
- data/README.md +244 -6
- data/Rakefile +12 -0
- data/lib/qube_sync/client.rb +579 -0
- data/lib/qube_sync/operations/account.rb +337 -0
- data/lib/qube_sync/operations/account_tax_line_info.rb +30 -0
- data/lib/qube_sync/operations/aging_report.rb +160 -0
- data/lib/qube_sync/operations/alert.rb +91 -0
- data/lib/qube_sync/operations/ar_refund_credit_card.rb +399 -0
- data/lib/qube_sync/operations/bar_code.rb +37 -0
- data/lib/qube_sync/operations/bill.rb +1073 -0
- data/lib/qube_sync/operations/bill_payment_check.rb +413 -0
- data/lib/qube_sync/operations/bill_payment_credit_card.rb +315 -0
- data/lib/qube_sync/operations/bill_to_pay.rb +66 -0
- data/lib/qube_sync/operations/billing_rate.rb +172 -0
- data/lib/qube_sync/operations/budget_summary_report.rb +80 -0
- data/lib/qube_sync/operations/build_assembly.rb +318 -0
- data/lib/qube_sync/operations/charge.rb +452 -0
- data/lib/qube_sync/operations/check.rb +1055 -0
- data/lib/qube_sync/operations/class.rb +176 -0
- data/lib/qube_sync/operations/cleared_status.rb +39 -0
- data/lib/qube_sync/operations/company.rb +39 -0
- data/lib/qube_sync/operations/company_activity.rb +31 -0
- data/lib/qube_sync/operations/credit_card_charge.rb +1000 -0
- data/lib/qube_sync/operations/credit_card_credit.rb +1000 -0
- data/lib/qube_sync/operations/credit_memo.rb +1243 -0
- data/lib/qube_sync/operations/currency.rb +195 -0
- data/lib/qube_sync/operations/custom_detail_report.rb +176 -0
- data/lib/qube_sync/operations/custom_summary_report.rb +180 -0
- data/lib/qube_sync/operations/customer.rb +744 -0
- data/lib/qube_sync/operations/customer_msg.rb +117 -0
- data/lib/qube_sync/operations/customer_type.rb +133 -0
- data/lib/qube_sync/operations/data_event_recovery_info.rb +54 -0
- data/lib/qube_sync/operations/data_ext.rb +201 -0
- data/lib/qube_sync/operations/data_ext_def.rb +179 -0
- data/lib/qube_sync/operations/date_driven_terms.rb +131 -0
- data/lib/qube_sync/operations/deposit.rb +555 -0
- data/lib/qube_sync/operations/employee.rb +577 -0
- data/lib/qube_sync/operations/employee_default.rb +100 -0
- data/lib/qube_sync/operations/entity.rb +118 -0
- data/lib/qube_sync/operations/estimate.rb +1055 -0
- data/lib/qube_sync/operations/form1099_category_account_mapping.rb +90 -0
- data/lib/qube_sync/operations/general_detail_report.rb +185 -0
- data/lib/qube_sync/operations/general_summary_report.rb +180 -0
- data/lib/qube_sync/operations/host.rb +36 -0
- data/lib/qube_sync/operations/inventory_adjustment.rb +482 -0
- data/lib/qube_sync/operations/inventory_site.rb +214 -0
- data/lib/qube_sync/operations/invoice.rb +1208 -0
- data/lib/qube_sync/operations/item.rb +115 -0
- data/lib/qube_sync/operations/item_assemblies_can_build.rb +44 -0
- data/lib/qube_sync/operations/item_discount.rb +319 -0
- data/lib/qube_sync/operations/item_fixed_asset.rb +317 -0
- data/lib/qube_sync/operations/item_group.rb +253 -0
- data/lib/qube_sync/operations/item_inventory.rb +446 -0
- data/lib/qube_sync/operations/item_inventory_assembly.rb +483 -0
- data/lib/qube_sync/operations/item_non_inventory.rb +461 -0
- data/lib/qube_sync/operations/item_other_charge.rb +434 -0
- data/lib/qube_sync/operations/item_payment.rb +268 -0
- data/lib/qube_sync/operations/item_receipt.rb +1011 -0
- data/lib/qube_sync/operations/item_sales_tax.rb +270 -0
- data/lib/qube_sync/operations/item_sales_tax_group.rb +200 -0
- data/lib/qube_sync/operations/item_service.rb +455 -0
- data/lib/qube_sync/operations/item_sites.rb +96 -0
- data/lib/qube_sync/operations/item_subtotal.rb +182 -0
- data/lib/qube_sync/operations/job_report.rb +156 -0
- data/lib/qube_sync/operations/job_type.rb +131 -0
- data/lib/qube_sync/operations/journal_entry.rb +518 -0
- data/lib/qube_sync/operations/lead.rb +216 -0
- data/lib/qube_sync/operations/list.rb +42 -0
- data/lib/qube_sync/operations/list_deleted.rb +57 -0
- data/lib/qube_sync/operations/list_display.rb +59 -0
- data/lib/qube_sync/operations/list_merge.rb +55 -0
- data/lib/qube_sync/operations/other_name.rb +245 -0
- data/lib/qube_sync/operations/paycheck.rb +139 -0
- data/lib/qube_sync/operations/payment_method.rb +128 -0
- data/lib/qube_sync/operations/payroll_detail_report.rb +161 -0
- data/lib/qube_sync/operations/payroll_item.rb +75 -0
- data/lib/qube_sync/operations/payroll_item_addition.rb +98 -0
- data/lib/qube_sync/operations/payroll_item_company_contribution.rb +134 -0
- data/lib/qube_sync/operations/payroll_item_deduction.rb +124 -0
- data/lib/qube_sync/operations/payroll_item_direct_deposit.rb +70 -0
- data/lib/qube_sync/operations/payroll_item_non_wage.rb +93 -0
- data/lib/qube_sync/operations/payroll_item_tax.rb +123 -0
- data/lib/qube_sync/operations/payroll_item_wage.rb +168 -0
- data/lib/qube_sync/operations/payroll_item_workers_compensation.rb +108 -0
- data/lib/qube_sync/operations/payroll_last_period.rb +30 -0
- data/lib/qube_sync/operations/payroll_liability_adjustment.rb +204 -0
- data/lib/qube_sync/operations/payroll_liability_check.rb +137 -0
- data/lib/qube_sync/operations/payroll_prior_payment.rb +178 -0
- data/lib/qube_sync/operations/payroll_summary_report.rb +157 -0
- data/lib/qube_sync/operations/payroll_year_to_date_adjustment.rb +211 -0
- data/lib/qube_sync/operations/preferences.rb +61 -0
- data/lib/qube_sync/operations/price_level.rb +305 -0
- data/lib/qube_sync/operations/purchase_order.rb +1038 -0
- data/lib/qube_sync/operations/qb_command_exec.rb +37 -0
- data/lib/qube_sync/operations/receive_payment.rb +627 -0
- data/lib/qube_sync/operations/receive_payment_to_deposit.rb +38 -0
- data/lib/qube_sync/operations/sales_order.rb +1045 -0
- data/lib/qube_sync/operations/sales_receipt.rb +1337 -0
- data/lib/qube_sync/operations/sales_rep.rb +172 -0
- data/lib/qube_sync/operations/sales_tax_code.rb +205 -0
- data/lib/qube_sync/operations/sales_tax_payable.rb +37 -0
- data/lib/qube_sync/operations/sales_tax_payment_check.rb +375 -0
- data/lib/qube_sync/operations/sales_tax_return.rb +35 -0
- data/lib/qube_sync/operations/sales_tax_return_line.rb +43 -0
- data/lib/qube_sync/operations/ship_method.rb +116 -0
- data/lib/qube_sync/operations/special_account.rb +55 -0
- data/lib/qube_sync/operations/special_item.rb +44 -0
- data/lib/qube_sync/operations/standard_terms.rb +125 -0
- data/lib/qube_sync/operations/template.rb +36 -0
- data/lib/qube_sync/operations/terms.rb +91 -0
- data/lib/qube_sync/operations/time_report.rb +127 -0
- data/lib/qube_sync/operations/time_tracking.rb +303 -0
- data/lib/qube_sync/operations/to_do.rb +260 -0
- data/lib/qube_sync/operations/transaction.rb +356 -0
- data/lib/qube_sync/operations/transfer.rb +213 -0
- data/lib/qube_sync/operations/transfer_inventory.rb +384 -0
- data/lib/qube_sync/operations/txn.rb +38 -0
- data/lib/qube_sync/operations/txn_deleted.rb +54 -0
- data/lib/qube_sync/operations/txn_display.rb +76 -0
- data/lib/qube_sync/operations/txn_void.rb +36 -0
- data/lib/qube_sync/operations/unit_of_measure_set.rb +149 -0
- data/lib/qube_sync/operations/vehicle.rb +152 -0
- data/lib/qube_sync/operations/vehicle_mileage.rb +191 -0
- data/lib/qube_sync/operations/vendor.rb +661 -0
- data/lib/qube_sync/operations/vendor_credit.rb +1008 -0
- data/lib/qube_sync/operations/vendor_type.rb +131 -0
- data/lib/qube_sync/operations/workers_comp_code.rb +184 -0
- data/lib/qube_sync/operations.rb +1165 -0
- data/lib/qube_sync/request_builder.rb +2 -0
- data/lib/qube_sync/version.rb +1 -1
- data/lib/qube_sync/webhooks/event.rb +228 -0
- data/lib/qube_sync/webhooks.rb +171 -0
- data/lib/qube_sync.rb +41 -11
- data/qube_sync.gemspec +2 -2
- data/sig/qube_sync/client.rbs +82 -0
- data/sig/qube_sync/operations/account.rbs +65 -0
- data/sig/qube_sync/operations/account_tax_line_info.rbs +13 -0
- data/sig/qube_sync/operations/aging_report.rbs +29 -0
- data/sig/qube_sync/operations/alert.rbs +53 -0
- data/sig/qube_sync/operations/ar_refund_credit_card.rbs +53 -0
- data/sig/qube_sync/operations/bar_code.rbs +16 -0
- data/sig/qube_sync/operations/bill.rbs +78 -0
- data/sig/qube_sync/operations/bill_payment_check.rbs +62 -0
- data/sig/qube_sync/operations/bill_payment_credit_card.rbs +45 -0
- data/sig/qube_sync/operations/bill_to_pay.rbs +19 -0
- data/sig/qube_sync/operations/billing_rate.rbs +40 -0
- data/sig/qube_sync/operations/budget_summary_report.rbs +22 -0
- data/sig/qube_sync/operations/build_assembly.rbs +64 -0
- data/sig/qube_sync/operations/charge.rbs +80 -0
- data/sig/qube_sync/operations/check.rbs +81 -0
- data/sig/qube_sync/operations/class.rbs +43 -0
- data/sig/qube_sync/operations/cleared_status.rbs +16 -0
- data/sig/qube_sync/operations/company.rbs +15 -0
- data/sig/qube_sync/operations/company_activity.rbs +14 -0
- data/sig/qube_sync/operations/credit_card_charge.rbs +69 -0
- data/sig/qube_sync/operations/credit_card_credit.rbs +69 -0
- data/sig/qube_sync/operations/credit_memo.rbs +162 -0
- data/sig/qube_sync/operations/currency.rbs +52 -0
- data/sig/qube_sync/operations/custom_detail_report.rbs +31 -0
- data/sig/qube_sync/operations/custom_summary_report.rbs +33 -0
- data/sig/qube_sync/operations/customer.rbs +174 -0
- data/sig/qube_sync/operations/customer_msg.rbs +31 -0
- data/sig/qube_sync/operations/customer_type.rbs +32 -0
- data/sig/qube_sync/operations/data_event_recovery_info.rbs +20 -0
- data/sig/qube_sync/operations/data_ext.rbs +53 -0
- data/sig/qube_sync/operations/data_ext_def.rbs +51 -0
- data/sig/qube_sync/operations/date_driven_terms.rbs +35 -0
- data/sig/qube_sync/operations/deposit.rbs +100 -0
- data/sig/qube_sync/operations/employee.rbs +173 -0
- data/sig/qube_sync/operations/employee_default.rbs +68 -0
- data/sig/qube_sync/operations/entity.rbs +24 -0
- data/sig/qube_sync/operations/estimate.rbs +148 -0
- data/sig/qube_sync/operations/form1099_category_account_mapping.rbs +33 -0
- data/sig/qube_sync/operations/general_detail_report.rbs +31 -0
- data/sig/qube_sync/operations/general_summary_report.rbs +32 -0
- data/sig/qube_sync/operations/host.rbs +19 -0
- data/sig/qube_sync/operations/inventory_adjustment.rbs +105 -0
- data/sig/qube_sync/operations/inventory_site.rbs +66 -0
- data/sig/qube_sync/operations/invoice.rbs +144 -0
- data/sig/qube_sync/operations/item.rbs +25 -0
- data/sig/qube_sync/operations/item_assemblies_can_build.rbs +15 -0
- data/sig/qube_sync/operations/item_discount.rbs +62 -0
- data/sig/qube_sync/operations/item_fixed_asset.rbs +97 -0
- data/sig/qube_sync/operations/item_group.rbs +62 -0
- data/sig/qube_sync/operations/item_inventory.rbs +87 -0
- data/sig/qube_sync/operations/item_inventory_assembly.rbs +94 -0
- data/sig/qube_sync/operations/item_non_inventory.rbs +64 -0
- data/sig/qube_sync/operations/item_other_charge.rbs +59 -0
- data/sig/qube_sync/operations/item_payment.rbs +55 -0
- data/sig/qube_sync/operations/item_receipt.rbs +71 -0
- data/sig/qube_sync/operations/item_sales_tax.rbs +57 -0
- data/sig/qube_sync/operations/item_sales_tax_group.rbs +50 -0
- data/sig/qube_sync/operations/item_service.rbs +62 -0
- data/sig/qube_sync/operations/item_sites.rbs +26 -0
- data/sig/qube_sync/operations/item_subtotal.rbs +48 -0
- data/sig/qube_sync/operations/job_report.rbs +28 -0
- data/sig/qube_sync/operations/job_type.rbs +32 -0
- data/sig/qube_sync/operations/journal_entry.rbs +88 -0
- data/sig/qube_sync/operations/lead.rbs +91 -0
- data/sig/qube_sync/operations/list.rbs +15 -0
- data/sig/qube_sync/operations/list_deleted.rbs +17 -0
- data/sig/qube_sync/operations/list_display.rbs +21 -0
- data/sig/qube_sync/operations/list_merge.rbs +22 -0
- data/sig/qube_sync/operations/other_name.rbs +71 -0
- data/sig/qube_sync/operations/paycheck.rbs +27 -0
- data/sig/qube_sync/operations/payment_method.rbs +33 -0
- data/sig/qube_sync/operations/payroll_detail_report.rbs +29 -0
- data/sig/qube_sync/operations/payroll_item.rbs +23 -0
- data/sig/qube_sync/operations/payroll_item_addition.rbs +48 -0
- data/sig/qube_sync/operations/payroll_item_company_contribution.rbs +58 -0
- data/sig/qube_sync/operations/payroll_item_deduction.rbs +54 -0
- data/sig/qube_sync/operations/payroll_item_direct_deposit.rbs +30 -0
- data/sig/qube_sync/operations/payroll_item_non_wage.rbs +23 -0
- data/sig/qube_sync/operations/payroll_item_tax.rbs +58 -0
- data/sig/qube_sync/operations/payroll_item_wage.rbs +48 -0
- data/sig/qube_sync/operations/payroll_item_workers_compensation.rbs +42 -0
- data/sig/qube_sync/operations/payroll_last_period.rbs +13 -0
- data/sig/qube_sync/operations/payroll_liability_adjustment.rbs +59 -0
- data/sig/qube_sync/operations/payroll_liability_check.rbs +27 -0
- data/sig/qube_sync/operations/payroll_prior_payment.rbs +48 -0
- data/sig/qube_sync/operations/payroll_summary_report.rbs +30 -0
- data/sig/qube_sync/operations/payroll_year_to_date_adjustment.rbs +66 -0
- data/sig/qube_sync/operations/preferences.rbs +26 -0
- data/sig/qube_sync/operations/price_level.rbs +57 -0
- data/sig/qube_sync/operations/purchase_order.rbs +159 -0
- data/sig/qube_sync/operations/qb_command_exec.rbs +22 -0
- data/sig/qube_sync/operations/receive_payment.rbs +102 -0
- data/sig/qube_sync/operations/receive_payment_to_deposit.rbs +15 -0
- data/sig/qube_sync/operations/sales_order.rbs +153 -0
- data/sig/qube_sync/operations/sales_receipt.rbs +139 -0
- data/sig/qube_sync/operations/sales_rep.rbs +43 -0
- data/sig/qube_sync/operations/sales_tax_code.rbs +49 -0
- data/sig/qube_sync/operations/sales_tax_payable.rbs +16 -0
- data/sig/qube_sync/operations/sales_tax_payment_check.rbs +64 -0
- data/sig/qube_sync/operations/sales_tax_return.rbs +14 -0
- data/sig/qube_sync/operations/sales_tax_return_line.rbs +15 -0
- data/sig/qube_sync/operations/ship_method.rbs +31 -0
- data/sig/qube_sync/operations/special_account.rbs +16 -0
- data/sig/qube_sync/operations/special_item.rbs +17 -0
- data/sig/qube_sync/operations/standard_terms.rbs +34 -0
- data/sig/qube_sync/operations/template.rbs +15 -0
- data/sig/qube_sync/operations/terms.rbs +23 -0
- data/sig/qube_sync/operations/time_report.rbs +26 -0
- data/sig/qube_sync/operations/time_tracking.rbs +57 -0
- data/sig/qube_sync/operations/to_do.rbs +59 -0
- data/sig/qube_sync/operations/transaction.rbs +39 -0
- data/sig/qube_sync/operations/transfer.rbs +47 -0
- data/sig/qube_sync/operations/transfer_inventory.rbs +76 -0
- data/sig/qube_sync/operations/txn.rbs +15 -0
- data/sig/qube_sync/operations/txn_deleted.rbs +17 -0
- data/sig/qube_sync/operations/txn_display.rbs +22 -0
- data/sig/qube_sync/operations/txn_void.rbs +15 -0
- data/sig/qube_sync/operations/types.rbs +434 -0
- data/sig/qube_sync/operations/unit_of_measure_set.rbs +51 -0
- data/sig/qube_sync/operations/vehicle.rbs +43 -0
- data/sig/qube_sync/operations/vehicle_mileage.rbs +38 -0
- data/sig/qube_sync/operations/vendor.rbs +142 -0
- data/sig/qube_sync/operations/vendor_credit.rbs +70 -0
- data/sig/qube_sync/operations/vendor_type.rbs +32 -0
- data/sig/qube_sync/operations/workers_comp_code.rbs +52 -0
- data/sig/qube_sync/operations.rbs +147 -0
- metadata +270 -6
|
@@ -16,6 +16,8 @@ module QubeSync
|
|
|
16
16
|
"name" => tag_name.to_s,
|
|
17
17
|
}
|
|
18
18
|
element["attributes"] = attributes unless attributes.empty?
|
|
19
|
+
# qbXML's booleans are the words true and false.
|
|
20
|
+
text = text.to_s if text == true || text == false
|
|
19
21
|
element["text"] = text if text.is_a?(String) || text.is_a?(Numeric)
|
|
20
22
|
|
|
21
23
|
if block_given?
|
data/lib/qube_sync/version.rb
CHANGED
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module QubeSync
|
|
4
|
+
module Webhooks
|
|
5
|
+
# A parsed delivery. `QubeSync::Webhooks.parse` and `.verify` return one of the subclasses
|
|
6
|
+
# below, picked by the body: RequestEvent, WorkflowRunEvent, NotificationEvent,
|
|
7
|
+
# ConnectionEvent, NameIndexEvent, or UnknownEvent for anything else. Every accessor reads
|
|
8
|
+
# the body and returns nil for a missing key; `[]` reads any other key.
|
|
9
|
+
class Event
|
|
10
|
+
WORKFLOW_RUN_EVENTS = %w[
|
|
11
|
+
workflow_run.awaiting_input
|
|
12
|
+
workflow_run.completed
|
|
13
|
+
workflow_run.failed
|
|
14
|
+
workflow_run.cancelled
|
|
15
|
+
].freeze
|
|
16
|
+
NOTIFICATION_EVENT = "workflow_run.notification"
|
|
17
|
+
|
|
18
|
+
# Picks the event class for a parsed body (a Hash with string keys).
|
|
19
|
+
def self.build(body)
|
|
20
|
+
event = body["event"]
|
|
21
|
+
|
|
22
|
+
klass =
|
|
23
|
+
if event.nil?
|
|
24
|
+
body["page_request_id"].nil? ? UnknownEvent : RequestEvent
|
|
25
|
+
elsif !event.is_a?(String)
|
|
26
|
+
UnknownEvent
|
|
27
|
+
elsif WORKFLOW_RUN_EVENTS.include?(event)
|
|
28
|
+
WorkflowRunEvent
|
|
29
|
+
elsif event == NOTIFICATION_EVENT
|
|
30
|
+
NotificationEvent
|
|
31
|
+
elsif event.start_with?("connection.")
|
|
32
|
+
ConnectionEvent
|
|
33
|
+
elsif event.start_with?("name_index.")
|
|
34
|
+
NameIndexEvent
|
|
35
|
+
else
|
|
36
|
+
UnknownEvent
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
klass.new(body)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Parses a raw JSON body without verifying it. Same as `QubeSync::Webhooks.parse`.
|
|
43
|
+
def self.from_json(raw_body)
|
|
44
|
+
Webhooks.parse(raw_body)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.fields(*names)
|
|
48
|
+
names.each do |name|
|
|
49
|
+
key = name.to_s
|
|
50
|
+
define_method(name) { @body[key] }
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
private_class_method :fields
|
|
54
|
+
|
|
55
|
+
def initialize(body)
|
|
56
|
+
@body = body
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
fields :event, :timestamp, :app_id, :sandbox
|
|
60
|
+
|
|
61
|
+
# "request", "workflow_run", "notification", "connection", "name_index" or "unknown".
|
|
62
|
+
def type
|
|
63
|
+
self.class::TYPE
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# The key to deduplicate deliveries on, or nil when this type has none.
|
|
67
|
+
def dedupe_key
|
|
68
|
+
nil
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def reference
|
|
72
|
+
nil
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def revision
|
|
76
|
+
nil
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Any key of the body, nil when it's missing.
|
|
80
|
+
def [](key)
|
|
81
|
+
@body[key.to_s]
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def dig(*keys)
|
|
85
|
+
@body.dig(*keys.map { |key| key.is_a?(Symbol) ? key.to_s : key })
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# The whole parsed body.
|
|
89
|
+
def to_h
|
|
90
|
+
@body
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def ==(other)
|
|
94
|
+
other.instance_of?(self.class) && other.to_h == @body
|
|
95
|
+
end
|
|
96
|
+
alias eql? ==
|
|
97
|
+
|
|
98
|
+
def hash
|
|
99
|
+
[self.class, @body].hash
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
def inspect
|
|
103
|
+
"#<#{self.class.name} type=#{type.inspect} event=#{event.inspect}>"
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Shared by the types that carry a revision to compare against the stored one.
|
|
107
|
+
module Revisioned
|
|
108
|
+
def revision
|
|
109
|
+
@body["revision"]
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# True when this delivery is newer than the revision stored for its subject (or nothing is
|
|
113
|
+
# stored yet). Skip the delivery when false: an older one arrived late.
|
|
114
|
+
def newer_than?(stored_revision)
|
|
115
|
+
return true if stored_revision.nil?
|
|
116
|
+
return false if revision.nil?
|
|
117
|
+
|
|
118
|
+
revision > stored_revision
|
|
119
|
+
end
|
|
120
|
+
end
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# A queued request's answer (or error). Deduplicate on `dedupe_key`, page_request_id + state.
|
|
124
|
+
class RequestEvent < Event
|
|
125
|
+
TYPE = "request"
|
|
126
|
+
|
|
127
|
+
fields :id, :page_request_id, :state, :page, :iteration_state, :response_json, :error
|
|
128
|
+
|
|
129
|
+
def dedupe_key
|
|
130
|
+
"#{page_request_id}:#{state}"
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
# A workflow run that is waiting for an answer, or has ended. Store by `reference` and skip
|
|
135
|
+
# it unless `newer_than?` the revision you stored.
|
|
136
|
+
class WorkflowRunEvent < Event
|
|
137
|
+
include Event::Revisioned
|
|
138
|
+
|
|
139
|
+
TYPE = "workflow_run"
|
|
140
|
+
|
|
141
|
+
fields :run_id, :reference, :run_state, :workflow, :connection_id, :prompt, :outcome, :output,
|
|
142
|
+
:error, :summary, :cancel_reason, :links
|
|
143
|
+
|
|
144
|
+
def awaiting_input?
|
|
145
|
+
event == "workflow_run.awaiting_input"
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
def completed?
|
|
149
|
+
event == "workflow_run.completed"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def failed?
|
|
153
|
+
event == "workflow_run.failed"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def cancelled?
|
|
157
|
+
event == "workflow_run.cancelled"
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# Data a running workflow sent along. Deduplicate on `delivery_id`; never skip one by revision.
|
|
162
|
+
class NotificationEvent < Event
|
|
163
|
+
TYPE = "notification"
|
|
164
|
+
|
|
165
|
+
fields :run_id, :reference, :revision, :delivery_id, :seq, :name, :state, :from, :data
|
|
166
|
+
|
|
167
|
+
def dedupe_key
|
|
168
|
+
delivery_id
|
|
169
|
+
end
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
# A connection was set up, cancelled, stalled or resumed. Deduplicate on `delivery_id`, and
|
|
173
|
+
# skip it unless `newer_than?` the connection's stored revision.
|
|
174
|
+
class ConnectionEvent < Event
|
|
175
|
+
include Event::Revisioned
|
|
176
|
+
|
|
177
|
+
TYPE = "connection"
|
|
178
|
+
|
|
179
|
+
fields :delivery_id, :connection
|
|
180
|
+
|
|
181
|
+
def connection_id
|
|
182
|
+
connection_hash["id"]
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
def stall_reason
|
|
186
|
+
connection_hash["stall_reason"]
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
def dedupe_key
|
|
190
|
+
delivery_id
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def connected?
|
|
194
|
+
event == "connection.connected"
|
|
195
|
+
end
|
|
196
|
+
|
|
197
|
+
def setup_cancelled?
|
|
198
|
+
event == "connection.setup_cancelled"
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
def stalled?
|
|
202
|
+
event == "connection.stalled"
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
def resumed?
|
|
206
|
+
event == "connection.resumed"
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
private
|
|
210
|
+
|
|
211
|
+
def connection_hash
|
|
212
|
+
connection.is_a?(Hash) ? connection : {}
|
|
213
|
+
end
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# A connection's name index finished building, or failed.
|
|
217
|
+
class NameIndexEvent < Event
|
|
218
|
+
TYPE = "name_index"
|
|
219
|
+
|
|
220
|
+
fields :connection_id, :name_index
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# Anything this version of the library doesn't know. Never refused: acknowledge it (or log it).
|
|
224
|
+
class UnknownEvent < Event
|
|
225
|
+
TYPE = "unknown"
|
|
226
|
+
end
|
|
227
|
+
end
|
|
228
|
+
end
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "json"
|
|
4
|
+
require "openssl"
|
|
5
|
+
|
|
6
|
+
module QubeSync
|
|
7
|
+
class Error < StandardError; end
|
|
8
|
+
|
|
9
|
+
# Verifies QuBe Sync webhook deliveries and parses them into typed events.
|
|
10
|
+
#
|
|
11
|
+
# event = QubeSync::Webhooks.verify(raw_body, header, secrets: ENV.fetch("QUBE_WEBHOOK_SECRET"))
|
|
12
|
+
#
|
|
13
|
+
# Framework-free: it never reads the environment or a request object. Pass the raw request body
|
|
14
|
+
# as received and the value of the `X-QUBE-Signature` header.
|
|
15
|
+
module Webhooks
|
|
16
|
+
# The header that carries the signature, and its name in a Rack env.
|
|
17
|
+
HEADER = "X-QUBE-Signature"
|
|
18
|
+
RACK_HEADER = "HTTP_X_QUBE_SIGNATURE"
|
|
19
|
+
|
|
20
|
+
# Seconds a delivery's timestamp may be from now, either way.
|
|
21
|
+
DEFAULT_TOLERANCE = 300
|
|
22
|
+
|
|
23
|
+
REASONS = %i[missing malformed stale mismatch].freeze
|
|
24
|
+
|
|
25
|
+
# A delivery that failed verification. Answer it with 401. `reason` is one of
|
|
26
|
+
# `:missing`, `:malformed`, `:stale`, `:mismatch`. The message is safe to log: it never holds
|
|
27
|
+
# a secret, a signature or the body.
|
|
28
|
+
class SignatureError < QubeSync::Error
|
|
29
|
+
attr_reader :reason
|
|
30
|
+
|
|
31
|
+
def initialize(reason, message = nil)
|
|
32
|
+
@reason = reason
|
|
33
|
+
super(message || default_message(reason))
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
private
|
|
37
|
+
|
|
38
|
+
def default_message(reason)
|
|
39
|
+
case reason
|
|
40
|
+
when :missing then "No #{HEADER} header"
|
|
41
|
+
when :malformed then "Malformed #{HEADER} header: expected t=<unix seconds>,v1=<hex>"
|
|
42
|
+
when :stale then "Webhook timestamp is outside the tolerance"
|
|
43
|
+
when :mismatch then "Webhook signature doesn't match any of the given secrets"
|
|
44
|
+
else "Webhook signature is invalid (#{reason})"
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# A body that verified (or was handed to `parse`) but isn't a JSON object.
|
|
50
|
+
class ParseError < QubeSync::Error; end
|
|
51
|
+
|
|
52
|
+
module_function
|
|
53
|
+
|
|
54
|
+
# Verifies a delivery and returns its typed event (see `parse`). Raises SignatureError when
|
|
55
|
+
# the header is missing, malformed, stale or matches none of `secrets`.
|
|
56
|
+
#
|
|
57
|
+
# - `raw_body`: the request body as received (a String), before anything parses it.
|
|
58
|
+
# - `header`: the `X-QUBE-Signature` value (nil when absent).
|
|
59
|
+
# - `secrets:`: the app's webhook secret, or a list of them while one rotates.
|
|
60
|
+
# - `tolerance:`: seconds the timestamp may be from `now`, either way.
|
|
61
|
+
# - `now:`: unix seconds, or a Time.
|
|
62
|
+
def verify(raw_body, header, secrets:, tolerance: DEFAULT_TOLERANCE, now: Time.now)
|
|
63
|
+
raw_body = raw_body!(raw_body)
|
|
64
|
+
secrets = secrets!(secrets)
|
|
65
|
+
now = unix_seconds!(now)
|
|
66
|
+
|
|
67
|
+
header = header.to_s.b.strip
|
|
68
|
+
raise SignatureError.new(:missing) if header.empty?
|
|
69
|
+
|
|
70
|
+
timestamp, signatures = parse_header(header)
|
|
71
|
+
|
|
72
|
+
age = now - timestamp.to_i
|
|
73
|
+
if age.abs > tolerance
|
|
74
|
+
when_sent = age.positive? ? "#{age} seconds old" : "#{-age} seconds in the future"
|
|
75
|
+
raise SignatureError.new(
|
|
76
|
+
:stale,
|
|
77
|
+
"Webhook timestamp is #{when_sent}; it must be within #{tolerance} seconds of now. Check this server's clock."
|
|
78
|
+
)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
signed = "#{timestamp}.".b + raw_body.b
|
|
82
|
+
expected = secrets.map { |secret| OpenSSL::HMAC.hexdigest("sha256", secret, signed) }
|
|
83
|
+
matched = expected.product(signatures).any? { |exp, sig| secure_compare(exp, sig) }
|
|
84
|
+
raise SignatureError.new(:mismatch) unless matched
|
|
85
|
+
|
|
86
|
+
parse(raw_body)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Builds the typed event from a raw body without verifying it: for tests, and for code that
|
|
90
|
+
# verified the delivery elsewhere.
|
|
91
|
+
def parse(raw_body)
|
|
92
|
+
raw_body = raw_body!(raw_body)
|
|
93
|
+
text = raw_body.encoding == Encoding::UTF_8 ? raw_body : raw_body.dup.force_encoding(Encoding::UTF_8)
|
|
94
|
+
|
|
95
|
+
body =
|
|
96
|
+
begin
|
|
97
|
+
JSON.parse(text)
|
|
98
|
+
rescue JSON::ParserError, EncodingError
|
|
99
|
+
raise ParseError, "Webhook body isn't valid JSON"
|
|
100
|
+
end
|
|
101
|
+
raise ParseError, "Webhook body isn't a JSON object" unless body.is_a?(Hash)
|
|
102
|
+
|
|
103
|
+
Event.build(body)
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Splits the header into its `t` and its non-empty `v1`s, or raises :malformed.
|
|
107
|
+
def parse_header(header)
|
|
108
|
+
timestamp = nil
|
|
109
|
+
signatures = []
|
|
110
|
+
|
|
111
|
+
header.split(",").each do |part|
|
|
112
|
+
key, value = part.strip.split("=", 2)
|
|
113
|
+
next if value.nil?
|
|
114
|
+
|
|
115
|
+
case key
|
|
116
|
+
when "t" then timestamp ||= value
|
|
117
|
+
when "v1" then signatures << value unless value.empty?
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
unless timestamp&.match?(/\A[0-9]+\z/) && !signatures.empty?
|
|
122
|
+
raise SignatureError.new(:malformed)
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
[timestamp, signatures]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Constant-time comparison of two byte strings; different lengths are simply false.
|
|
129
|
+
def secure_compare(a, b)
|
|
130
|
+
a = a.b
|
|
131
|
+
b = b.b
|
|
132
|
+
return false unless a.bytesize == b.bytesize
|
|
133
|
+
|
|
134
|
+
OpenSSL.fixed_length_secure_compare(a, b)
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def raw_body!(raw_body)
|
|
138
|
+
return raw_body if raw_body.is_a?(String)
|
|
139
|
+
|
|
140
|
+
raise TypeError,
|
|
141
|
+
"Pass the raw request body as a String (in Rails, request.raw_post), not a #{raw_body.class}: " \
|
|
142
|
+
"the signature covers the exact bytes QuBe Sync sent"
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def secrets!(secrets)
|
|
146
|
+
list = secrets.is_a?(String) ? [secrets] : Array(secrets)
|
|
147
|
+
raise ArgumentError, "secrets is empty: pass the app's webhook secret" if list.empty?
|
|
148
|
+
unless list.all? { |secret| secret.is_a?(String) && !secret.empty? }
|
|
149
|
+
raise ArgumentError, "each secret must be a non-empty String"
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
list
|
|
153
|
+
end
|
|
154
|
+
|
|
155
|
+
def unix_seconds!(now)
|
|
156
|
+
case now
|
|
157
|
+
when Integer then now
|
|
158
|
+
when Time then now.to_i
|
|
159
|
+
when Numeric then now.floor
|
|
160
|
+
else
|
|
161
|
+
return now.to_time.to_i if now.respond_to?(:to_time)
|
|
162
|
+
|
|
163
|
+
raise ArgumentError, "now must be unix seconds or a Time, not a #{now.class}"
|
|
164
|
+
end
|
|
165
|
+
end
|
|
166
|
+
|
|
167
|
+
private_class_method :parse_header, :secure_compare, :raw_body!, :secrets!, :unix_seconds!
|
|
168
|
+
end
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
require_relative "webhooks/event"
|
data/lib/qube_sync.rb
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
require_relative "qube_sync/version"
|
|
2
2
|
require_relative "qube_sync/request_builder"
|
|
3
|
+
require_relative "qube_sync/webhooks"
|
|
4
|
+
require_relative "qube_sync/client"
|
|
3
5
|
require "faraday"
|
|
6
|
+
require "json"
|
|
7
|
+
require "openssl"
|
|
4
8
|
|
|
5
9
|
module QubeSync
|
|
6
10
|
class Error < StandardError; end
|
|
@@ -128,12 +132,26 @@ module QubeSync
|
|
|
128
132
|
end
|
|
129
133
|
|
|
130
134
|
|
|
135
|
+
# Parses an `X-QUBE-Signature` header, `t=<unix seconds>,v1=<hex>[,v1=<hex>]`,
|
|
136
|
+
# by key. There is one `v1` per active webhook secret while a secret rotates.
|
|
131
137
|
def extract_signature_meta(header)
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
timestamp = nil
|
|
139
|
+
signatures = []
|
|
140
|
+
|
|
141
|
+
header.to_s.split(",").each do |part|
|
|
142
|
+
key, value = part.strip.split("=", 2)
|
|
143
|
+
case key
|
|
144
|
+
when "t" then timestamp = value
|
|
145
|
+
when "v1" then signatures << value if value && !value.empty?
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
unless timestamp && timestamp.match?(/\A\d+\z/)
|
|
150
|
+
raise InvalidWebhookSignatureError.new("Invalid X-QUBE-Signature header: no t=<unix seconds>")
|
|
151
|
+
end
|
|
152
|
+
|
|
135
153
|
{
|
|
136
|
-
timestamp:
|
|
154
|
+
timestamp: timestamp.to_i,
|
|
137
155
|
signatures: signatures
|
|
138
156
|
}
|
|
139
157
|
end
|
|
@@ -162,18 +180,30 @@ module QubeSync
|
|
|
162
180
|
OpenSSL::HMAC.hexdigest('sha256', api_secret, payload)
|
|
163
181
|
end
|
|
164
182
|
|
|
165
|
-
|
|
183
|
+
# Verifies a webhook against its `X-QUBE-Signature` header and returns the
|
|
184
|
+
# parsed body. `body` must be the raw request body, unparsed. The timestamp
|
|
185
|
+
# must be within `max_age` seconds of now, either way.
|
|
186
|
+
def verify_and_build_webhook!(body, signature, max_age: 300)
|
|
166
187
|
meta = extract_signature_meta(signature)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
188
|
+
|
|
189
|
+
age = Time.now.to_i - meta[:timestamp]
|
|
190
|
+
if age.abs > max_age
|
|
191
|
+
when_sent = age.positive? ? "#{age} seconds old" : "#{-age} seconds in the future"
|
|
192
|
+
raise StaleWebhookError.new("Webhook timestamp is #{when_sent}; it must be within #{max_age} seconds of now. Check this server's clock.")
|
|
170
193
|
end
|
|
171
|
-
|
|
172
|
-
|
|
194
|
+
|
|
195
|
+
expected = sign_payload("#{meta[:timestamp]}.#{body}")
|
|
196
|
+
if meta[:signatures].any? { |sig| secure_compare(expected, sig) }
|
|
173
197
|
JSON.parse(body)
|
|
174
198
|
else
|
|
175
199
|
raise InvalidWebhookSignatureError.new("Webhook signature mismatch")
|
|
176
200
|
end
|
|
177
|
-
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# Constant-time string comparison, so a mismatch takes as long wherever it is.
|
|
204
|
+
def secure_compare(a, b)
|
|
205
|
+
return false unless a.bytesize == b.bytesize
|
|
206
|
+
|
|
207
|
+
OpenSSL.fixed_length_secure_compare(a, b)
|
|
178
208
|
end
|
|
179
209
|
end
|
data/qube_sync.gemspec
CHANGED
|
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
Manage connections, queued requests, and more with the QUBE Sync API.
|
|
16
16
|
"""
|
|
17
17
|
spec.homepage = "https://github.com/qubeintegrations/qube_sync_rb"
|
|
18
|
-
spec.required_ruby_version = ">=
|
|
18
|
+
spec.required_ruby_version = ">= 3.3.0"
|
|
19
19
|
|
|
20
20
|
# spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
|
|
21
21
|
|
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |spec|
|
|
|
36
36
|
spec.require_paths = ["lib"]
|
|
37
37
|
|
|
38
38
|
# Uncomment to register a new dependency of your gem
|
|
39
|
-
spec.add_dependency "faraday", "~> 2.
|
|
39
|
+
spec.add_dependency "faraday", "~> 2.14", ">= 2.14.3"
|
|
40
40
|
|
|
41
41
|
|
|
42
42
|
# For more information and examples about making a new gem, check out our
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
module QubeSync
|
|
2
|
+
class Error < StandardError
|
|
3
|
+
end
|
|
4
|
+
|
|
5
|
+
class APIError < Error
|
|
6
|
+
MAX_RAW: Integer
|
|
7
|
+
|
|
8
|
+
attr_reader status: Integer
|
|
9
|
+
attr_reader errors: untyped
|
|
10
|
+
attr_reader code: String?
|
|
11
|
+
attr_reader body: String
|
|
12
|
+
attr_reader request_id: String?
|
|
13
|
+
|
|
14
|
+
def initialize: (status: Integer, ?body: String?, ?request_id: String?) -> void
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
class Client
|
|
18
|
+
type data = Hash[String, untyped]
|
|
19
|
+
type retry_info = {
|
|
20
|
+
attempt: Integer,
|
|
21
|
+
max_retries: Integer,
|
|
22
|
+
delay: Float,
|
|
23
|
+
elapsed: Float,
|
|
24
|
+
method: String,
|
|
25
|
+
url: String,
|
|
26
|
+
status: Integer?,
|
|
27
|
+
error: Exception?
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
DEFAULT_BASE_URL: String
|
|
31
|
+
|
|
32
|
+
attr_reader base_url: String
|
|
33
|
+
attr_reader open_timeout: Numeric
|
|
34
|
+
attr_reader read_timeout: Numeric
|
|
35
|
+
attr_reader max_retries: Integer
|
|
36
|
+
attr_reader total_timeout: Numeric
|
|
37
|
+
|
|
38
|
+
def initialize: (
|
|
39
|
+
api_key: String,
|
|
40
|
+
?base_url: String,
|
|
41
|
+
?open_timeout: Numeric,
|
|
42
|
+
?read_timeout: Numeric,
|
|
43
|
+
?max_retries: Integer,
|
|
44
|
+
?total_timeout: Numeric,
|
|
45
|
+
?on_retry: (^(retry_info) -> void)?,
|
|
46
|
+
?sleep: (^(Numeric) -> void)?,
|
|
47
|
+
?clock: (^() -> Numeric)?
|
|
48
|
+
) -> void
|
|
49
|
+
|
|
50
|
+
def inspect: () -> String
|
|
51
|
+
def to_s: () -> String
|
|
52
|
+
|
|
53
|
+
def create_connection: (webhook_url: String, ?name: String?) -> data
|
|
54
|
+
def get_connection: (String id) -> data
|
|
55
|
+
def list_connections: () -> Array[data]
|
|
56
|
+
def update_connection: (String id, ?webhook_url: String?, ?name: String?) -> data
|
|
57
|
+
def delete_connection: (String id) -> nil
|
|
58
|
+
def regenerate_onboarding: (String id) -> data
|
|
59
|
+
def set_password: (String id, ?password: String?) -> data
|
|
60
|
+
def get_qwc: (String id) -> String?
|
|
61
|
+
|
|
62
|
+
def start_run: (String connection_id, String workflow, Hash[untyped, untyped]? input, reference: String, webhook_url: String, ?version: Integer?) -> data
|
|
63
|
+
def get_run: (String run_url_or_connection_id, ?String? run_id) -> data
|
|
64
|
+
def list_runs: (String connection_id, ?reference: String?, ?state: String?, ?outcome: String?) -> Array[data]
|
|
65
|
+
def cancel_run: (String cancel_url, ?reason: String?) -> data
|
|
66
|
+
def run_events: (String connection_id, String run_id, ?after: Integer?, ?limit: Integer?) -> data
|
|
67
|
+
|
|
68
|
+
def answer: (String decisions_url, choice: String, ?data: Hash[untyped, untyped]?) -> data
|
|
69
|
+
def search: (String search_url, field: String, q: String) -> Array[data]
|
|
70
|
+
|
|
71
|
+
def queue: (String operation_id, String connection_id, ?Hash[Symbol | String, untyped]? params, webhook_url: String, ?idempotency_key: String?, ?method: (Symbol | String)?, ?path: String?) -> data
|
|
72
|
+
def queue_qbxml: (String connection_id, String request_xml, webhook_url: String, ?idempotency_key: String?) -> data
|
|
73
|
+
def get_request: (String connection_id, String id) -> data
|
|
74
|
+
def request_pages: (String connection_id, String id) -> Array[data]
|
|
75
|
+
def list_requests: (String connection_id, ?page: Integer?, ?page_size: Integer?, ?state: String?, ?webhook_state: String?, ?sort: String?, ?sort_direction: String?, ?search_phrase: String?) -> data
|
|
76
|
+
def each_request: (String connection_id, **untyped filters) { (data) -> void } -> nil
|
|
77
|
+
| (String connection_id, **untyped filters) -> Enumerator[data, nil]
|
|
78
|
+
def discard_request: (String connection_id, String id) -> data
|
|
79
|
+
|
|
80
|
+
def request: (Symbol | String method, String path_or_url, ?untyped body, ?query: Hash[Symbol | String, untyped], ?headers: Hash[String, String]) -> untyped
|
|
81
|
+
end
|
|
82
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Generated from operations.json by bin/generate-operations: don't edit.
|
|
2
|
+
|
|
3
|
+
module QubeSync
|
|
4
|
+
module Operations
|
|
5
|
+
class Account < Base
|
|
6
|
+
type create_params = {
|
|
7
|
+
?account_number: String,
|
|
8
|
+
account_type: "AccountsPayable" | "AccountsReceivable" | "Bank" | "CostOfGoodsSold" | "CreditCard" | "Equity" | "Expense" | "FixedAsset" | "Income" | "LongTermLiability" | "NonPosting" | "OtherAsset" | "OtherCurrentAsset" | "OtherCurrentLiability" | "OtherExpense" | "OtherIncome",
|
|
9
|
+
?bank_number: String,
|
|
10
|
+
?currency_ref: Types::ref,
|
|
11
|
+
?desc: String,
|
|
12
|
+
?detail_account_type: "AP" | "AR" | "AccumulatedAdjustment" | "AccumulatedAmortization" | "AccumulatedAmortizationOfOtherAssets" | "AccumulatedDepletion" | "AccumulatedDepreciation" | "AdvertisingOrPromotional" | "AllowanceForBadDebts" | "Amortization" | "Auto" | "BadDebts" | "BankCharges" | "Buildings" | "CashOnHand" | "CharitableContributions" | "Checking" | "CommonStock" | "CostOfLabor" | "CostOfLaborCOS" | "CreditCard" | "DepletableAssets" | "Depreciation" | "DevelopmentCosts" | "DiscountsOrRefundsGiven" | "DividendIncome" | "DuesAndSubscriptions" | "EmployeeCashAdvances" | "Entertainment" | "EntertainmentMeals" | "EquipmentRental" | "EquipmentRentalCOS" | "FederalIncomeTaxPayable" | "FurnitureAndFixtures" | "Goodwill" | "Insurance" | "InsurancePayable" | "IntangibleAssets" | "InterestEarned" | "InterestPaid" | "Inventory" | "InvestmentMortgageOrRealEstateLoans" | "InvestmentOther" | "InvestmentTaxExemptSecurities" | "InvestmentUSGovObligations" | "Land" | "LeaseBuyout" | "LeaseholdImprovements" | "LegalAndProfessionalFees" | "Licenses" | "LineOfCredit" | "LoanPayable" | "LoansToOfficers" | "LoansToOthers" | "LoansToStockholders" | "MachineryAndEquipment" | "MoneyMarket" | "NonProfitIncome" | "NotesPayable" | "OfficeOrGeneralAdministrativeExpenses" | "OpeningBalanceEquity" | "OrganizationalCosts" | "OtherCostsOfServiceCOS" | "OtherCurrentAssets" | "OtherCurrentLiab" | "OtherFixedAssets" | "OtherInvestmentIncome" | "OtherLongTermAssets" | "OtherLongTermLiab" | "OtherMiscExpense" | "OtherMiscIncome" | "OtherMiscServiceCost" | "OtherPrimaryIncome" | "OwnersEquity" | "PaidInCapitalOrSurplus" | "PartnerContributions" | "PartnerDistributions" | "PartnersEquity" | "PayrollClearing" | "PayrollExpenses" | "PayrollTaxPayable" | "PenaltiesAndSettlements" | "PreferredStock" | "PrepaidExpenses" | "PrepaidExpensesPayable" | "PromotionalMeals" | "RentOrLeaseOfBuildings" | "RentsHeldInTrust" | "RentsInTrustLiab" | "RepairAndMaintenance" | "Retainage" | "RetainedEarnings" | "SalesOfProductIncome" | "SalesTaxPayable" | "Savings" | "SecurityDeposits" | "ServiceOrFeeIncome" | "ShareholderNotesPayable" | "ShippingFreightAndDelivery" | "ShippingFreightAndDeliveryCOS" | "StateOrLocalIncomeTaxPayable" | "SuppliesAndMaterials" | "SuppliesAndMaterialsCOGS" | "TaxExemptInterest" | "TaxesPaid" | "Travel" | "TravelMeals" | "TreasuryStock" | "TrustAccounts" | "TrustAccountsLiab" | "UndepositedFunds" | "Utilities" | "Vehicles",
|
|
13
|
+
?include_ret_element: Array["AccountNumber" | "AccountType" | "Balance" | "BankNumber" | "CashFlowClassification" | "CurrencyRef" | "DataExtRet" | "Desc" | "DetailAccountType" | "EditSequence" | "ExternalGUID" | "FullName" | "IsActive" | "IsTaxAccount" | "LastCheckNumber" | "ListID" | "Name" | "OwnerID" | "ParentRef" | "SalesTaxCodeRef" | "SpecialAccountType" | "Sublevel" | "TaxLineInfoRet" | "TimeCreated" | "TimeModified" | "TotalBalance" | "TxnID" | "TxnNumber"],
|
|
14
|
+
?is_active: bool,
|
|
15
|
+
name: String,
|
|
16
|
+
?open_balance: Numeric,
|
|
17
|
+
?open_balance_date: String,
|
|
18
|
+
?parent_ref: Types::ref,
|
|
19
|
+
?request_id: String,
|
|
20
|
+
?sales_tax_code_ref: Types::ref,
|
|
21
|
+
?tax_line_id: Integer
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
type query_params = {
|
|
25
|
+
?account_type: Array["AccountsPayable" | "AccountsReceivable" | "Bank" | "CostOfGoodsSold" | "CreditCard" | "Equity" | "Expense" | "FixedAsset" | "Income" | "LongTermLiability" | "NonPosting" | "OtherAsset" | "OtherCurrentAsset" | "OtherCurrentLiability" | "OtherExpense" | "OtherIncome"],
|
|
26
|
+
?active_status: "ActiveOnly" | "All" | "InactiveOnly",
|
|
27
|
+
?currency_filter: Types::currency_filter,
|
|
28
|
+
?from_modified_date: String,
|
|
29
|
+
?full_name: Array[String],
|
|
30
|
+
?include_ret_element: Array["AccountNumber" | "AccountType" | "Balance" | "BankNumber" | "CashFlowClassification" | "CurrencyRef" | "DataExtRet" | "Desc" | "DetailAccountType" | "EditSequence" | "FullName" | "IsActive" | "IsTaxAccount" | "LastCheckNumber" | "ListID" | "Name" | "ParentRef" | "SalesTaxCodeRef" | "SpecialAccountType" | "Sublevel" | "TaxLineInfoRet" | "TimeCreated" | "TimeModified" | "TotalBalance"],
|
|
31
|
+
?list_id: Array[String],
|
|
32
|
+
?max_returned: Integer,
|
|
33
|
+
?meta_data: "MetaDataAndResponseData" | "MetaDataOnly" | "NoMetaData",
|
|
34
|
+
?name_filter: Types::name_filter,
|
|
35
|
+
?name_range_filter: Types::name_range_filter,
|
|
36
|
+
?owner_id: Array[String],
|
|
37
|
+
?request_id: String,
|
|
38
|
+
?to_modified_date: String
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
type update_params = {
|
|
42
|
+
?account_number: String,
|
|
43
|
+
?account_type: "AccountsPayable" | "AccountsReceivable" | "Bank" | "CostOfGoodsSold" | "CreditCard" | "Equity" | "Expense" | "FixedAsset" | "Income" | "LongTermLiability" | "NonPosting" | "OtherAsset" | "OtherCurrentAsset" | "OtherCurrentLiability" | "OtherExpense" | "OtherIncome",
|
|
44
|
+
?bank_number: String,
|
|
45
|
+
?currency_ref: Types::ref,
|
|
46
|
+
?desc: String,
|
|
47
|
+
edit_sequence: String,
|
|
48
|
+
?include_ret_element: Array["AccountNumber" | "AccountType" | "Balance" | "BankNumber" | "CashFlowClassification" | "CurrencyRef" | "DataExtRet" | "Desc" | "DetailAccountType" | "EditSequence" | "ExternalGUID" | "FullName" | "IsActive" | "IsTaxAccount" | "LastCheckNumber" | "ListID" | "Name" | "OwnerID" | "ParentRef" | "SalesTaxCodeRef" | "SpecialAccountType" | "Sublevel" | "TaxLineInfoRet" | "TimeCreated" | "TimeModified" | "TotalBalance" | "TxnID" | "TxnNumber"],
|
|
49
|
+
?is_active: bool,
|
|
50
|
+
list_id: String,
|
|
51
|
+
?name: String,
|
|
52
|
+
?open_balance: Numeric,
|
|
53
|
+
?open_balance_date: String,
|
|
54
|
+
?parent_ref: Types::ref,
|
|
55
|
+
?request_id: String,
|
|
56
|
+
?sales_tax_code_ref: Types::ref,
|
|
57
|
+
?tax_line_id: Integer
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
def create: (String connection_id, ?create_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
|
|
61
|
+
def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
|
|
62
|
+
def update: (String connection_id, ?update_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Generated from operations.json by bin/generate-operations: don't edit.
|
|
2
|
+
|
|
3
|
+
module QubeSync
|
|
4
|
+
module Operations
|
|
5
|
+
class AccountTaxLineInfo < Base
|
|
6
|
+
type query_params = {
|
|
7
|
+
?request_id: String
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|