qube_sync 0.3.0 → 0.5.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.
Files changed (268) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +84 -0
  3. data/README.md +291 -75
  4. data/Rakefile +12 -0
  5. data/exe/qube_sync +11 -0
  6. data/lib/qube_sync/client.rb +614 -0
  7. data/lib/qube_sync/operations/account.rb +338 -0
  8. data/lib/qube_sync/operations/account_tax_line_info.rb +30 -0
  9. data/lib/qube_sync/operations/aging_report.rb +160 -0
  10. data/lib/qube_sync/operations/alert.rb +91 -0
  11. data/lib/qube_sync/operations/ar_refund_credit_card.rb +402 -0
  12. data/lib/qube_sync/operations/bar_code.rb +37 -0
  13. data/lib/qube_sync/operations/bill.rb +1117 -0
  14. data/lib/qube_sync/operations/bill_payment_check.rb +420 -0
  15. data/lib/qube_sync/operations/bill_payment_credit_card.rb +320 -0
  16. data/lib/qube_sync/operations/bill_to_pay.rb +67 -0
  17. data/lib/qube_sync/operations/billing_rate.rb +173 -0
  18. data/lib/qube_sync/operations/budget_summary_report.rb +80 -0
  19. data/lib/qube_sync/operations/build_assembly.rb +319 -0
  20. data/lib/qube_sync/operations/charge.rb +454 -0
  21. data/lib/qube_sync/operations/check.rb +1099 -0
  22. data/lib/qube_sync/operations/class.rb +176 -0
  23. data/lib/qube_sync/operations/cleared_status.rb +39 -0
  24. data/lib/qube_sync/operations/company.rb +39 -0
  25. data/lib/qube_sync/operations/company_activity.rb +31 -0
  26. data/lib/qube_sync/operations/credit_card_charge.rb +1044 -0
  27. data/lib/qube_sync/operations/credit_card_credit.rb +1044 -0
  28. data/lib/qube_sync/operations/credit_memo.rb +1277 -0
  29. data/lib/qube_sync/operations/currency.rb +195 -0
  30. data/lib/qube_sync/operations/custom_detail_report.rb +176 -0
  31. data/lib/qube_sync/operations/custom_summary_report.rb +180 -0
  32. data/lib/qube_sync/operations/customer.rb +745 -0
  33. data/lib/qube_sync/operations/customer_msg.rb +117 -0
  34. data/lib/qube_sync/operations/customer_type.rb +133 -0
  35. data/lib/qube_sync/operations/data_event_recovery_info.rb +54 -0
  36. data/lib/qube_sync/operations/data_ext.rb +202 -0
  37. data/lib/qube_sync/operations/data_ext_def.rb +179 -0
  38. data/lib/qube_sync/operations/date_driven_terms.rb +131 -0
  39. data/lib/qube_sync/operations/deposit.rb +570 -0
  40. data/lib/qube_sync/operations/employee.rb +581 -0
  41. data/lib/qube_sync/operations/employee_default.rb +100 -0
  42. data/lib/qube_sync/operations/entity.rb +118 -0
  43. data/lib/qube_sync/operations/estimate.rb +1084 -0
  44. data/lib/qube_sync/operations/fields.rb +4058 -0
  45. data/lib/qube_sync/operations/form1099_category_account_mapping.rb +91 -0
  46. data/lib/qube_sync/operations/general_detail_report.rb +185 -0
  47. data/lib/qube_sync/operations/general_summary_report.rb +180 -0
  48. data/lib/qube_sync/operations/host.rb +36 -0
  49. data/lib/qube_sync/operations/inventory_adjustment.rb +491 -0
  50. data/lib/qube_sync/operations/inventory_site.rb +214 -0
  51. data/lib/qube_sync/operations/invoice.rb +1242 -0
  52. data/lib/qube_sync/operations/item.rb +115 -0
  53. data/lib/qube_sync/operations/item_assemblies_can_build.rb +44 -0
  54. data/lib/qube_sync/operations/item_discount.rb +320 -0
  55. data/lib/qube_sync/operations/item_fixed_asset.rb +318 -0
  56. data/lib/qube_sync/operations/item_group.rb +255 -0
  57. data/lib/qube_sync/operations/item_inventory.rb +447 -0
  58. data/lib/qube_sync/operations/item_inventory_assembly.rb +486 -0
  59. data/lib/qube_sync/operations/item_non_inventory.rb +472 -0
  60. data/lib/qube_sync/operations/item_other_charge.rb +445 -0
  61. data/lib/qube_sync/operations/item_payment.rb +269 -0
  62. data/lib/qube_sync/operations/item_receipt.rb +1055 -0
  63. data/lib/qube_sync/operations/item_sales_tax.rb +271 -0
  64. data/lib/qube_sync/operations/item_sales_tax_group.rb +200 -0
  65. data/lib/qube_sync/operations/item_service.rb +466 -0
  66. data/lib/qube_sync/operations/item_sites.rb +98 -0
  67. data/lib/qube_sync/operations/item_subtotal.rb +182 -0
  68. data/lib/qube_sync/operations/job_report.rb +156 -0
  69. data/lib/qube_sync/operations/job_type.rb +131 -0
  70. data/lib/qube_sync/operations/journal_entry.rb +533 -0
  71. data/lib/qube_sync/operations/lead.rb +216 -0
  72. data/lib/qube_sync/operations/list.rb +42 -0
  73. data/lib/qube_sync/operations/list_deleted.rb +57 -0
  74. data/lib/qube_sync/operations/list_display.rb +59 -0
  75. data/lib/qube_sync/operations/list_merge.rb +57 -0
  76. data/lib/qube_sync/operations/other_name.rb +245 -0
  77. data/lib/qube_sync/operations/paycheck.rb +139 -0
  78. data/lib/qube_sync/operations/payment_method.rb +129 -0
  79. data/lib/qube_sync/operations/payroll_detail_report.rb +161 -0
  80. data/lib/qube_sync/operations/payroll_item.rb +75 -0
  81. data/lib/qube_sync/operations/payroll_item_addition.rb +98 -0
  82. data/lib/qube_sync/operations/payroll_item_company_contribution.rb +134 -0
  83. data/lib/qube_sync/operations/payroll_item_deduction.rb +124 -0
  84. data/lib/qube_sync/operations/payroll_item_direct_deposit.rb +70 -0
  85. data/lib/qube_sync/operations/payroll_item_non_wage.rb +93 -0
  86. data/lib/qube_sync/operations/payroll_item_tax.rb +123 -0
  87. data/lib/qube_sync/operations/payroll_item_wage.rb +168 -0
  88. data/lib/qube_sync/operations/payroll_item_workers_compensation.rb +108 -0
  89. data/lib/qube_sync/operations/payroll_last_period.rb +30 -0
  90. data/lib/qube_sync/operations/payroll_liability_adjustment.rb +204 -0
  91. data/lib/qube_sync/operations/payroll_liability_check.rb +137 -0
  92. data/lib/qube_sync/operations/payroll_prior_payment.rb +178 -0
  93. data/lib/qube_sync/operations/payroll_summary_report.rb +157 -0
  94. data/lib/qube_sync/operations/payroll_year_to_date_adjustment.rb +211 -0
  95. data/lib/qube_sync/operations/preferences.rb +61 -0
  96. data/lib/qube_sync/operations/price_level.rb +309 -0
  97. data/lib/qube_sync/operations/purchase_order.rb +1065 -0
  98. data/lib/qube_sync/operations/qb_command_exec.rb +37 -0
  99. data/lib/qube_sync/operations/receive_payment.rb +634 -0
  100. data/lib/qube_sync/operations/receive_payment_to_deposit.rb +38 -0
  101. data/lib/qube_sync/operations/sales_order.rb +1072 -0
  102. data/lib/qube_sync/operations/sales_receipt.rb +1371 -0
  103. data/lib/qube_sync/operations/sales_rep.rb +172 -0
  104. data/lib/qube_sync/operations/sales_tax_code.rb +205 -0
  105. data/lib/qube_sync/operations/sales_tax_payable.rb +37 -0
  106. data/lib/qube_sync/operations/sales_tax_payment_check.rb +379 -0
  107. data/lib/qube_sync/operations/sales_tax_return.rb +35 -0
  108. data/lib/qube_sync/operations/sales_tax_return_line.rb +43 -0
  109. data/lib/qube_sync/operations/ship_method.rb +116 -0
  110. data/lib/qube_sync/operations/special_account.rb +55 -0
  111. data/lib/qube_sync/operations/special_item.rb +44 -0
  112. data/lib/qube_sync/operations/standard_terms.rb +125 -0
  113. data/lib/qube_sync/operations/template.rb +36 -0
  114. data/lib/qube_sync/operations/terms.rb +91 -0
  115. data/lib/qube_sync/operations/time_report.rb +127 -0
  116. data/lib/qube_sync/operations/time_tracking.rb +304 -0
  117. data/lib/qube_sync/operations/to_do.rb +260 -0
  118. data/lib/qube_sync/operations/transaction.rb +361 -0
  119. data/lib/qube_sync/operations/transfer.rb +213 -0
  120. data/lib/qube_sync/operations/transfer_inventory.rb +393 -0
  121. data/lib/qube_sync/operations/txn.rb +38 -0
  122. data/lib/qube_sync/operations/txn_deleted.rb +54 -0
  123. data/lib/qube_sync/operations/txn_display.rb +76 -0
  124. data/lib/qube_sync/operations/txn_void.rb +36 -0
  125. data/lib/qube_sync/operations/unit_of_measure_set.rb +149 -0
  126. data/lib/qube_sync/operations/vehicle.rb +152 -0
  127. data/lib/qube_sync/operations/vehicle_mileage.rb +191 -0
  128. data/lib/qube_sync/operations/vendor.rb +663 -0
  129. data/lib/qube_sync/operations/vendor_credit.rb +1052 -0
  130. data/lib/qube_sync/operations/vendor_type.rb +131 -0
  131. data/lib/qube_sync/operations/workers_comp_code.rb +184 -0
  132. data/lib/qube_sync/operations.rb +1169 -0
  133. data/lib/qube_sync/version.rb +1 -1
  134. data/lib/qube_sync/workflow_types/cli.rb +120 -0
  135. data/lib/qube_sync/workflow_types/rbs_renderer.rb +290 -0
  136. data/lib/qube_sync/workflow_types/ruby_renderer.rb +391 -0
  137. data/lib/qube_sync/workflow_types/workflow.rb +153 -0
  138. data/lib/qube_sync/workflow_types.rb +219 -0
  139. data/lib/qube_sync.rb +1 -0
  140. data/sig/qube_sync/client.rbs +85 -0
  141. data/sig/qube_sync/operations/account.rbs +65 -0
  142. data/sig/qube_sync/operations/account_tax_line_info.rbs +13 -0
  143. data/sig/qube_sync/operations/aging_report.rbs +29 -0
  144. data/sig/qube_sync/operations/alert.rbs +53 -0
  145. data/sig/qube_sync/operations/ar_refund_credit_card.rbs +53 -0
  146. data/sig/qube_sync/operations/bar_code.rbs +16 -0
  147. data/sig/qube_sync/operations/bill.rbs +78 -0
  148. data/sig/qube_sync/operations/bill_payment_check.rbs +62 -0
  149. data/sig/qube_sync/operations/bill_payment_credit_card.rbs +45 -0
  150. data/sig/qube_sync/operations/bill_to_pay.rbs +19 -0
  151. data/sig/qube_sync/operations/billing_rate.rbs +40 -0
  152. data/sig/qube_sync/operations/budget_summary_report.rbs +22 -0
  153. data/sig/qube_sync/operations/build_assembly.rbs +64 -0
  154. data/sig/qube_sync/operations/charge.rbs +80 -0
  155. data/sig/qube_sync/operations/check.rbs +81 -0
  156. data/sig/qube_sync/operations/class.rbs +43 -0
  157. data/sig/qube_sync/operations/cleared_status.rbs +16 -0
  158. data/sig/qube_sync/operations/company.rbs +15 -0
  159. data/sig/qube_sync/operations/company_activity.rbs +14 -0
  160. data/sig/qube_sync/operations/credit_card_charge.rbs +69 -0
  161. data/sig/qube_sync/operations/credit_card_credit.rbs +69 -0
  162. data/sig/qube_sync/operations/credit_memo.rbs +162 -0
  163. data/sig/qube_sync/operations/currency.rbs +52 -0
  164. data/sig/qube_sync/operations/custom_detail_report.rbs +31 -0
  165. data/sig/qube_sync/operations/custom_summary_report.rbs +33 -0
  166. data/sig/qube_sync/operations/customer.rbs +174 -0
  167. data/sig/qube_sync/operations/customer_msg.rbs +31 -0
  168. data/sig/qube_sync/operations/customer_type.rbs +32 -0
  169. data/sig/qube_sync/operations/data_event_recovery_info.rbs +20 -0
  170. data/sig/qube_sync/operations/data_ext.rbs +53 -0
  171. data/sig/qube_sync/operations/data_ext_def.rbs +51 -0
  172. data/sig/qube_sync/operations/date_driven_terms.rbs +35 -0
  173. data/sig/qube_sync/operations/deposit.rbs +100 -0
  174. data/sig/qube_sync/operations/employee.rbs +173 -0
  175. data/sig/qube_sync/operations/employee_default.rbs +68 -0
  176. data/sig/qube_sync/operations/entity.rbs +24 -0
  177. data/sig/qube_sync/operations/estimate.rbs +148 -0
  178. data/sig/qube_sync/operations/form1099_category_account_mapping.rbs +33 -0
  179. data/sig/qube_sync/operations/general_detail_report.rbs +31 -0
  180. data/sig/qube_sync/operations/general_summary_report.rbs +32 -0
  181. data/sig/qube_sync/operations/host.rbs +19 -0
  182. data/sig/qube_sync/operations/inventory_adjustment.rbs +105 -0
  183. data/sig/qube_sync/operations/inventory_site.rbs +66 -0
  184. data/sig/qube_sync/operations/invoice.rbs +144 -0
  185. data/sig/qube_sync/operations/item.rbs +25 -0
  186. data/sig/qube_sync/operations/item_assemblies_can_build.rbs +15 -0
  187. data/sig/qube_sync/operations/item_discount.rbs +62 -0
  188. data/sig/qube_sync/operations/item_fixed_asset.rbs +97 -0
  189. data/sig/qube_sync/operations/item_group.rbs +62 -0
  190. data/sig/qube_sync/operations/item_inventory.rbs +87 -0
  191. data/sig/qube_sync/operations/item_inventory_assembly.rbs +94 -0
  192. data/sig/qube_sync/operations/item_non_inventory.rbs +64 -0
  193. data/sig/qube_sync/operations/item_other_charge.rbs +59 -0
  194. data/sig/qube_sync/operations/item_payment.rbs +55 -0
  195. data/sig/qube_sync/operations/item_receipt.rbs +71 -0
  196. data/sig/qube_sync/operations/item_sales_tax.rbs +57 -0
  197. data/sig/qube_sync/operations/item_sales_tax_group.rbs +50 -0
  198. data/sig/qube_sync/operations/item_service.rbs +62 -0
  199. data/sig/qube_sync/operations/item_sites.rbs +26 -0
  200. data/sig/qube_sync/operations/item_subtotal.rbs +48 -0
  201. data/sig/qube_sync/operations/job_report.rbs +28 -0
  202. data/sig/qube_sync/operations/job_type.rbs +32 -0
  203. data/sig/qube_sync/operations/journal_entry.rbs +88 -0
  204. data/sig/qube_sync/operations/lead.rbs +91 -0
  205. data/sig/qube_sync/operations/list.rbs +15 -0
  206. data/sig/qube_sync/operations/list_deleted.rbs +17 -0
  207. data/sig/qube_sync/operations/list_display.rbs +21 -0
  208. data/sig/qube_sync/operations/list_merge.rbs +22 -0
  209. data/sig/qube_sync/operations/other_name.rbs +71 -0
  210. data/sig/qube_sync/operations/paycheck.rbs +27 -0
  211. data/sig/qube_sync/operations/payment_method.rbs +33 -0
  212. data/sig/qube_sync/operations/payroll_detail_report.rbs +29 -0
  213. data/sig/qube_sync/operations/payroll_item.rbs +23 -0
  214. data/sig/qube_sync/operations/payroll_item_addition.rbs +48 -0
  215. data/sig/qube_sync/operations/payroll_item_company_contribution.rbs +58 -0
  216. data/sig/qube_sync/operations/payroll_item_deduction.rbs +54 -0
  217. data/sig/qube_sync/operations/payroll_item_direct_deposit.rbs +30 -0
  218. data/sig/qube_sync/operations/payroll_item_non_wage.rbs +23 -0
  219. data/sig/qube_sync/operations/payroll_item_tax.rbs +58 -0
  220. data/sig/qube_sync/operations/payroll_item_wage.rbs +48 -0
  221. data/sig/qube_sync/operations/payroll_item_workers_compensation.rbs +42 -0
  222. data/sig/qube_sync/operations/payroll_last_period.rbs +13 -0
  223. data/sig/qube_sync/operations/payroll_liability_adjustment.rbs +59 -0
  224. data/sig/qube_sync/operations/payroll_liability_check.rbs +27 -0
  225. data/sig/qube_sync/operations/payroll_prior_payment.rbs +48 -0
  226. data/sig/qube_sync/operations/payroll_summary_report.rbs +30 -0
  227. data/sig/qube_sync/operations/payroll_year_to_date_adjustment.rbs +66 -0
  228. data/sig/qube_sync/operations/preferences.rbs +26 -0
  229. data/sig/qube_sync/operations/price_level.rbs +57 -0
  230. data/sig/qube_sync/operations/purchase_order.rbs +159 -0
  231. data/sig/qube_sync/operations/qb_command_exec.rbs +22 -0
  232. data/sig/qube_sync/operations/receive_payment.rbs +102 -0
  233. data/sig/qube_sync/operations/receive_payment_to_deposit.rbs +15 -0
  234. data/sig/qube_sync/operations/sales_order.rbs +153 -0
  235. data/sig/qube_sync/operations/sales_receipt.rbs +139 -0
  236. data/sig/qube_sync/operations/sales_rep.rbs +43 -0
  237. data/sig/qube_sync/operations/sales_tax_code.rbs +49 -0
  238. data/sig/qube_sync/operations/sales_tax_payable.rbs +16 -0
  239. data/sig/qube_sync/operations/sales_tax_payment_check.rbs +64 -0
  240. data/sig/qube_sync/operations/sales_tax_return.rbs +14 -0
  241. data/sig/qube_sync/operations/sales_tax_return_line.rbs +15 -0
  242. data/sig/qube_sync/operations/ship_method.rbs +31 -0
  243. data/sig/qube_sync/operations/special_account.rbs +16 -0
  244. data/sig/qube_sync/operations/special_item.rbs +17 -0
  245. data/sig/qube_sync/operations/standard_terms.rbs +34 -0
  246. data/sig/qube_sync/operations/template.rbs +15 -0
  247. data/sig/qube_sync/operations/terms.rbs +23 -0
  248. data/sig/qube_sync/operations/time_report.rbs +26 -0
  249. data/sig/qube_sync/operations/time_tracking.rbs +57 -0
  250. data/sig/qube_sync/operations/to_do.rbs +59 -0
  251. data/sig/qube_sync/operations/transaction.rbs +39 -0
  252. data/sig/qube_sync/operations/transfer.rbs +47 -0
  253. data/sig/qube_sync/operations/transfer_inventory.rbs +76 -0
  254. data/sig/qube_sync/operations/txn.rbs +15 -0
  255. data/sig/qube_sync/operations/txn_deleted.rbs +17 -0
  256. data/sig/qube_sync/operations/txn_display.rbs +22 -0
  257. data/sig/qube_sync/operations/txn_void.rbs +15 -0
  258. data/sig/qube_sync/operations/types.rbs +434 -0
  259. data/sig/qube_sync/operations/unit_of_measure_set.rbs +51 -0
  260. data/sig/qube_sync/operations/vehicle.rbs +43 -0
  261. data/sig/qube_sync/operations/vehicle_mileage.rbs +38 -0
  262. data/sig/qube_sync/operations/vendor.rbs +142 -0
  263. data/sig/qube_sync/operations/vendor_credit.rbs +70 -0
  264. data/sig/qube_sync/operations/vendor_type.rbs +32 -0
  265. data/sig/qube_sync/operations/workers_comp_code.rbs +52 -0
  266. data/sig/qube_sync/operations.rbs +148 -0
  267. data/sig/qube_sync/workflow_types.rbs +59 -0
  268. metadata +265 -3
@@ -0,0 +1,219 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require_relative "client"
5
+ require_relative "workflow_types/workflow"
6
+ require_relative "workflow_types/ruby_renderer"
7
+ require_relative "workflow_types/rbs_renderer"
8
+ require_relative "workflow_types/cli"
9
+
10
+ module QubeSync
11
+ # Turns an app's workflow input types (Client#workflow_types, GET /api/v2/workflows/types) into
12
+ # a typed Ruby file and its RBS: a QubeWorkflows module with one module per workflow, and a
13
+ # start method per branch of a workflow's input, whose operation bodies are typed as the
14
+ # operation's own params (QubeSync::Operations::<Entity>::<action>_params).
15
+ #
16
+ # files = QubeSync::WorkflowTypes.render(client.workflow_types, source: "https://qubesync.com/api/v2/workflows/types")
17
+ # File.write("lib/qube_workflows.rb", files.ruby)
18
+ # File.write("sig/qube_workflows.rbs", files.rbs)
19
+ #
20
+ # `qube_sync workflows` (exe/qube_sync, WorkflowTypes::CLI) does this, and `--check` compares a
21
+ # written file with what QuBe Sync serves; qube_rails' `bin/rails g qube_rails:workflows` does
22
+ # the same in a Rails app. The same document gives byte-identical files.
23
+ module WorkflowTypes
24
+ # A document this version can't render: not a workflow types document, or a name that isn't
25
+ # one QuBe Sync allows.
26
+ class Error < QubeSync::Error; end
27
+
28
+ COMMAND = "qube_sync workflows"
29
+ WIDTH = 100
30
+ # What a start method's client defaults to when none is given: set once, at boot.
31
+ DEFAULT_CLIENT = "::QubeWorkflows.client"
32
+
33
+ # The rendered files; digest and drafts are what their header records.
34
+ Files = Struct.new(:ruby, :rbs, :digest, :drafts, :warnings, keyword_init: true)
35
+
36
+ # What a generated file's header records: the document's digest, and whether it was made
37
+ # with drafts.
38
+ Header = Struct.new(:digest, :drafts, keyword_init: true)
39
+
40
+ # What a --check found. status is :current, :stale (changes lists the workflows, as
41
+ # "add_transaction (changed)", "resolve (new)", "upsert (removed)"), :unreachable (QuBe Sync
42
+ # didn't answer, or answered 5xx: nothing was checked) or :error (a 401, another 4xx, a file
43
+ # without a header). message is one line.
44
+ Check = Struct.new(:status, :message, :changes, :warnings, keyword_init: true) do
45
+ # 0 when the file is current, and when QuBe Sync couldn't be reached (CI warns, and the
46
+ # file keeps working); 1 otherwise.
47
+ def exit_status
48
+ (status == :current || status == :unreachable) ? 0 : 1
49
+ end
50
+ end
51
+
52
+ module_function
53
+
54
+ # Renders a document's workflows: each published one at its published version, or with
55
+ # `drafts: true` each workflow's draft where it has one. `source` is the URL the header
56
+ # names, `command` the command it says to run again, and `client` the Ruby expression a
57
+ # start method's client defaults to (DEFAULT_CLIENT, with a QubeWorkflows.client= setter; any
58
+ # other has none).
59
+ def render(document, source:, drafts: false, command: COMMAND, client: DEFAULT_CLIENT)
60
+ document = validate(document)
61
+ workflows = select(document, drafts).map { |key, entry| Workflow.new(key, entry) }
62
+ consts = workflows.group_by(&:const).select { |_const, same| same.size > 1 }
63
+ unless consts.empty?
64
+ raise Error, "workflows #{consts.values.flatten.map(&:key).join(", ")} would share a module name"
65
+ end
66
+
67
+ header = header_lines(source, drafts ? "#{command} --drafts" : command, document["digest"], drafts)
68
+ Files.new(
69
+ ruby: RubyRenderer.new(workflows, header: header, client: client).render,
70
+ rbs: RBSRenderer.new(workflows, header: header, client: client).render,
71
+ digest: document["digest"],
72
+ drafts: drafts,
73
+ warnings: warnings(document)
74
+ )
75
+ end
76
+
77
+ # The workflows a render types, by key, sorted: the published ones, each replaced by its
78
+ # draft when drafts is true, and the drafts of workflows never published.
79
+ def select(document, drafts)
80
+ chosen = (document["workflows"] || {}).dup
81
+ (document["drafts"] || {}).each { |key, entry| chosen[key] = entry } if drafts
82
+ chosen.sort.to_h
83
+ end
84
+
85
+ # The digest and drafts a generated file's header records, or nil when it has none.
86
+ def header(source)
87
+ lines = source.to_s.each_line.first(10)
88
+ digest = lines.filter_map { |line| line[/\A# digest: (\S+)\s*\z/, 1] }.first
89
+ drafts = lines.filter_map { |line| line[/\A# drafts: (true|false)\s*\z/, 1] }.first
90
+ return nil unless digest && drafts
91
+
92
+ Header.new(digest: digest, drafts: drafts == "true")
93
+ end
94
+
95
+ # The workflows whose generated module differs between two renders, by key, sorted.
96
+ def changes(before, after)
97
+ old = workflow_blocks(before)
98
+ new = workflow_blocks(after)
99
+ (old.keys | new.keys).sort.filter_map do |key|
100
+ if !old.key?(key)
101
+ "#{key} (new)"
102
+ elsif !new.key?(key)
103
+ "#{key} (removed)"
104
+ elsif old[key] != new[key]
105
+ "#{key} (changed)"
106
+ end
107
+ end
108
+ end
109
+
110
+ # Compares a generated file (its Ruby source) with what QuBe Sync serves now, fetched with the
111
+ # drafts flag the file records. client is a QubeSync::Client, or anything answering
112
+ # workflow_types as it does; path names the file in messages. Takes render's options, so the
113
+ # changes it lists are the ones running `command` again would make.
114
+ def check(existing, client:, source:, path:, command: COMMAND, client_expression: DEFAULT_CLIENT)
115
+ recorded = header(existing)
116
+ unless recorded
117
+ return Check.new(status: :error, changes: [], warnings: [],
118
+ message: "#{path} has no digest header: run `#{command}` to write it")
119
+ end
120
+
121
+ again = recorded.drafts ? "#{command} --drafts" : command
122
+ document =
123
+ begin
124
+ client.workflow_types(include_drafts: recorded.drafts, etag: recorded.digest)
125
+ rescue APIError => e
126
+ return unreachable("QuBe Sync answered #{e.status}") if e.status >= 500
127
+
128
+ return Check.new(status: :error, changes: [], warnings: [], message: e.message)
129
+ rescue *Client::NETWORK_ERRORS, SystemCallError => e
130
+ return unreachable("#{e.class}: #{e.message}")
131
+ end
132
+ return current(path, []) if document == :not_modified
133
+
134
+ files = render(document, source: source, drafts: recorded.drafts, command: command, client: client_expression)
135
+ return current(path, files.warnings) if files.digest == recorded.digest
136
+
137
+ changed = changes(existing, files.ruby)
138
+ what = changed.empty? ? "the served types changed" : changed.join(", ")
139
+ Check.new(status: :stale, changes: changed, warnings: files.warnings,
140
+ message: "#{path} is out of date (#{what}): run `#{again}` and commit the result")
141
+ end
142
+
143
+ def current(path, warnings)
144
+ Check.new(status: :current, changes: [], warnings: warnings, message: "#{path} is up to date")
145
+ end
146
+
147
+ def unreachable(why)
148
+ Check.new(status: :unreachable, changes: [], warnings: [],
149
+ message: "couldn't reach QuBe Sync (#{why}), so the workflow types weren't checked")
150
+ end
151
+
152
+ # A served operations_digest other than this gem's: the document's $operation ids may name
153
+ # operations this version doesn't type.
154
+ def warnings(document)
155
+ served = document["operations_digest"]
156
+ return [] if served.nil? || served == Operations::DIGEST
157
+
158
+ ["QuBe Sync's operations (#{served}) aren't the ones qube_sync #{VERSION} was generated from " \
159
+ "(#{Operations::DIGEST}): an operation it doesn't know is typed as a plain Hash. Update qube_sync to type it."]
160
+ end
161
+
162
+ def validate(document)
163
+ unless document.is_a?(Hash) && document["digest"].is_a?(String) && document["workflows"].is_a?(Hash)
164
+ raise Error, "not a workflow types document (expected digest and workflows)"
165
+ end
166
+ unless document["digest"].match?(/\A[\w:.\-]+\z/)
167
+ raise Error, "not a workflow types document: digest #{document["digest"].inspect}"
168
+ end
169
+
170
+ document
171
+ end
172
+
173
+ # Word-wraps text to WIDTH, as bin/generate-operations does: the first line starts with
174
+ # `first`, the others with `rest`. Splitting on whitespace keeps a newline in a description
175
+ # from ending a comment.
176
+ def wrap(text, first, rest)
177
+ lines = []
178
+ line = first.dup
179
+ fresh = true
180
+ text.to_s.split.each do |word|
181
+ if !fresh && line.length + 1 + word.length > WIDTH
182
+ lines << line
183
+ line = rest + word
184
+ else
185
+ line << (fresh ? "" : " ") << word
186
+ end
187
+ fresh = false
188
+ end
189
+ lines << line
190
+ lines.map(&:rstrip)
191
+ end
192
+
193
+ def header_lines(source, command, digest, drafts)
194
+ [
195
+ "# Generated by `#{command}` from #{source}: don't edit.",
196
+ "# Run it again when a workflow changes; `#{command} --check` fails while this file is out of date.",
197
+ "# digest: #{digest}",
198
+ "# drafts: #{drafts}"
199
+ ]
200
+ end
201
+
202
+ # Each workflow's module in a generated Ruby file, with its comment, by its WORKFLOW key.
203
+ def workflow_blocks(source)
204
+ lines = source.to_s.lines
205
+ blocks = {}
206
+ lines.each_with_index do |line, i|
207
+ next unless line.match?(/\A module [A-Z]\w*$/)
208
+
209
+ first = i
210
+ first -= 1 while first.positive? && lines[first - 1].start_with?(" #")
211
+ last = (i...lines.size).find { |j| lines[j] == " end\n" } || (lines.size - 1)
212
+ block = lines[first..last].join
213
+ key = block[/^ WORKFLOW = "([^"]+)"$/, 1]
214
+ blocks[key] = block if key
215
+ end
216
+ blocks
217
+ end
218
+ end
219
+ end
data/lib/qube_sync.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative "qube_sync/version"
2
2
  require_relative "qube_sync/request_builder"
3
3
  require_relative "qube_sync/webhooks"
4
+ require_relative "qube_sync/client"
4
5
  require "faraday"
5
6
  require "json"
6
7
  require "openssl"
@@ -0,0 +1,85 @@
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?, ?type: 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 redeliver_run: (String connection_id, String run_id) -> data
65
+ def list_runs: (String connection_id, ?reference: String?, ?state: String?, ?outcome: String?) -> Array[data]
66
+ def cancel_run: (String cancel_url, ?reason: String?) -> data
67
+ def run_events: (String connection_id, String run_id, ?after: Integer?, ?limit: Integer?) -> data
68
+
69
+ def workflow_types: (?include_drafts: bool, ?etag: String?) -> (data | :not_modified)
70
+
71
+ def answer: (String decisions_url, choice: String, ?data: Hash[untyped, untyped]?) -> data
72
+ def search: (String search_url, field: String, q: String) -> Array[data]
73
+
74
+ 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
75
+ def queue_qbxml: (String connection_id, String request_xml, webhook_url: String, ?idempotency_key: String?) -> data
76
+ def get_request: (String connection_id, String id) -> data
77
+ def request_pages: (String connection_id, String id) -> Array[data]
78
+ 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
79
+ def each_request: (String connection_id, **untyped filters) { (data) -> void } -> nil
80
+ | (String connection_id, **untyped filters) -> Enumerator[data, nil]
81
+ def discard_request: (String connection_id, String id) -> data
82
+
83
+ def request: (Symbol | String method, String path_or_url, ?untyped body, ?query: Hash[Symbol | String, untyped], ?headers: Hash[String, String]) -> untyped
84
+ end
85
+ 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
@@ -0,0 +1,29 @@
1
+ # Generated from operations.json by bin/generate-operations: don't edit.
2
+
3
+ module QubeSync
4
+ module Operations
5
+ class AgingReport < Base
6
+ type query_params = {
7
+ aging_report_type: "APAgingDetail" | "APAgingSummary" | "ARAgingDetail" | "ARAgingSummary" | "CollectionsReport",
8
+ ?display_report: bool,
9
+ ?include_accounts: "All" | "InUse",
10
+ ?include_column: Array["Account" | "Aging" | "Amount" | "AmountDifference" | "AverageCost" | "BilledDate" | "BillingStatus" | "CalculatedAmount" | "Class" | "ClearedStatus" | "CostPrice" | "Credit" | "Currency" | "Date" | "Debit" | "DeliveryDate" | "DueDate" | "EstimateActive" | "ExchangeRate" | "FOB" | "IncomeSubjectToTax" | "Invoiced" | "Item" | "ItemDesc" | "LastModifiedBy" | "LatestOrPriorState" | "Memo" | "ModifiedTime" | "Name" | "NameAccountNumber" | "NameAddress" | "NameCity" | "NameContact" | "NameEmail" | "NameFax" | "NamePhone" | "NameState" | "NameZip" | "OpenBalance" | "OriginalAmount" | "PONumber" | "PaidAmount" | "PaidStatus" | "PaidThroughDate" | "PaymentMethod" | "PayrollItem" | "PrintStatus" | "ProgressAmount" | "ProgressPercent" | "Quantity" | "QuantityAvailable" | "QuantityOnHand" | "QuantityOnSalesOrder" | "ReceivedQuantity" | "RefNumber" | "RunningBalance" | "SSNOrTaxID" | "SalesRep" | "SalesTaxCode" | "SerialOrLotNumber" | "ShipDate" | "ShipMethod" | "SourceName" | "SplitAccount" | "TaxLine" | "TaxTableVersion" | "Terms" | "TxnID" | "TxnNumber" | "TxnType" | "UnitPrice" | "UserEdit" | "ValueOnHand" | "WageBase" | "WageBaseTips"],
11
+ ?report_account_filter: Types::account_filter,
12
+ ?report_aging_as_of: "ReportEndDate" | "Today",
13
+ ?report_class_filter: Types::entity_filter,
14
+ ?report_date_macro: "All" | "LastMonth" | "LastMonthToDate" | "LastQuarter" | "LastQuarterToDate" | "LastWeek" | "LastWeekToDate" | "LastYear" | "LastYearToDate" | "NextFourWeeks" | "NextMonth" | "NextQuarter" | "NextWeek" | "NextYear" | "ThisMonth" | "ThisMonthToDate" | "ThisQuarter" | "ThisQuarterToDate" | "ThisWeek" | "ThisWeekToDate" | "ThisYear" | "ThisYearToDate" | "Today" | "Yesterday",
15
+ ?report_detail_level_filter: "All" | "AllExceptSummary" | "SummaryOnly",
16
+ ?report_entity_filter: Types::entity_filter_aging_report,
17
+ ?report_item_filter: Types::item_filter,
18
+ ?report_modified_date_range_filter: Types::report_modified_date_range_filter,
19
+ ?report_modified_date_range_macro: "All" | "LastMonth" | "LastMonthToDate" | "LastQuarter" | "LastQuarterToDate" | "LastWeek" | "LastWeekToDate" | "LastYear" | "LastYearToDate" | "NextFourWeeks" | "NextMonth" | "NextQuarter" | "NextWeek" | "NextYear" | "ThisMonth" | "ThisMonthToDate" | "ThisQuarter" | "ThisQuarterToDate" | "ThisWeek" | "ThisWeekToDate" | "ThisYear" | "ThisYearToDate" | "Today" | "Yesterday",
20
+ ?report_period: Types::report_period,
21
+ ?report_posting_status_filter: "Either" | "NonPosting" | "Posting",
22
+ ?report_txn_type_filter: Types::type_filter,
23
+ ?request_id: String
24
+ }
25
+
26
+ def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,53 @@
1
+ # Generated from operations.json by bin/generate-operations: don't edit.
2
+
3
+ module QubeSync
4
+ module Operations
5
+ class Alert < Base
6
+ type alert_permission = {
7
+ permission_level: Array["AccountsPayable" | "AccountsReceivable" | "Banking" | "Finance" | "Inventory" | "TimeTracking"],
8
+ permission_needed: "All" | "Any"
9
+ }
10
+
11
+ type com_callback_info = {
12
+ app_name: String,
13
+ ?clsid: String,
14
+ ?prog_id: String
15
+ }
16
+
17
+ type http_callback_info = {
18
+ url: String
19
+ }
20
+
21
+ type create_params = {
22
+ ?activation_date: String,
23
+ ?alert_permission: alert_permission,
24
+ alert_tag: String,
25
+ ?com_callback_info: com_callback_info,
26
+ desc: String,
27
+ ?expiration_date: String,
28
+ help_text: String,
29
+ ?http_callback_info: http_callback_info,
30
+ message_text: String,
31
+ owner_id: String,
32
+ ?request_id: String,
33
+ ?ui_context: Array["AlertsManager" | "CompanyNavigator"]
34
+ }
35
+
36
+ type delete_params = {
37
+ alert_tag: String,
38
+ owner_id: String,
39
+ ?request_id: String
40
+ }
41
+
42
+ type query_params = {
43
+ ?meta_data: "MetaDataAndResponseData" | "MetaDataOnly" | "NoMetaData",
44
+ owner_id: Array[String],
45
+ ?request_id: String
46
+ }
47
+
48
+ def create: (String connection_id, ?create_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
49
+ def delete: (String connection_id, ?delete_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
50
+ def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,53 @@
1
+ # Generated from operations.json by bin/generate-operations: don't edit.
2
+
3
+ module QubeSync
4
+ module Operations
5
+ class ArRefundCreditCard < Base
6
+ type refund_applied_to_txn_add = {
7
+ refund_amount: Numeric,
8
+ txn_id: String
9
+ }
10
+
11
+ type create_params = {
12
+ ?address: Types::address,
13
+ ?ar_account_ref: Types::ref,
14
+ ?credit_card_txn_info: Types::credit_card_txn_info,
15
+ customer_ref: Types::ref,
16
+ ?def_macro: String,
17
+ ?exchange_rate: Numeric,
18
+ ?external_guid: String,
19
+ ?include_ret_element: Array["ARAccountRef" | "Address" | "AddressBlock" | "CreditCardTxnInfo" | "CurrencyRef" | "CustomerRef" | "DataExtRet" | "EditSequence" | "ExchangeRate" | "ExternalGUID" | "ListID" | "Memo" | "OwnerID" | "PaymentMethodRef" | "RefNumber" | "RefundAppliedToTxnRet" | "RefundFromAccountRef" | "TimeCreated" | "TimeModified" | "TotalAmount" | "TotalAmountInHomeCurrency" | "TxnDate" | "TxnID" | "TxnNumber"],
20
+ ?memo: String,
21
+ ?payment_method_ref: Types::ref,
22
+ ?ref_number: String,
23
+ refund_applied_to_txn_add: Array[refund_applied_to_txn_add],
24
+ ?refund_from_account_ref: Types::ref,
25
+ ?request_id: String,
26
+ ?txn_date: String
27
+ }
28
+
29
+ type query_params = {
30
+ ?account_filter: Types::entity_filter,
31
+ ?currency_filter: Types::currency_filter,
32
+ ?entity_filter: Types::entity_filter,
33
+ ?include_line_items: bool,
34
+ ?include_ret_element: Array["ARAccountRef" | "Address" | "AddressBlock" | "CreditCardTxnInfo" | "CurrencyRef" | "CustomerRef" | "DataExtRet" | "EditSequence" | "ExchangeRate" | "ExternalGUID" | "Memo" | "PaymentMethodRef" | "RefNumber" | "RefundAppliedToTxnRet" | "RefundFromAccountRef" | "TimeCreated" | "TimeModified" | "TotalAmount" | "TotalAmountInHomeCurrency" | "TxnDate" | "TxnID" | "TxnNumber"],
35
+ ?iterator: bool,
36
+ ?max_returned: Integer,
37
+ ?meta_data: "MetaDataAndResponseData" | "MetaDataOnly" | "NoMetaData",
38
+ ?modified_date_range_filter: Types::modified_date_range_filter,
39
+ ?owner_id: Array[String],
40
+ ?ref_number: Array[String],
41
+ ?ref_number_case_sensitive: Array[String],
42
+ ?ref_number_filter: Types::ref_number_filter,
43
+ ?ref_number_range_filter: Types::ref_number_range_filter,
44
+ ?request_id: String,
45
+ ?txn_date_range_filter: Types::date_range_filter,
46
+ ?txn_id: Array[String]
47
+ }
48
+
49
+ def create: (String connection_id, ?create_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
50
+ def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,16 @@
1
+ # Generated from operations.json by bin/generate-operations: don't edit.
2
+
3
+ module QubeSync
4
+ module Operations
5
+ class BarCode < Base
6
+ type query_params = {
7
+ ?bar_code_value: Array[String],
8
+ ?iterator: bool,
9
+ ?meta_data: "MetaDataAndResponseData" | "MetaDataOnly" | "NoMetaData",
10
+ ?request_id: String
11
+ }
12
+
13
+ def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,78 @@
1
+ # Generated from operations.json by bin/generate-operations: don't edit.
2
+
3
+ module QubeSync
4
+ module Operations
5
+ class Bill < Base
6
+ type create_params = {
7
+ ?ap_account_ref: Types::ref,
8
+ ?def_macro: String,
9
+ ?due_date: String,
10
+ ?exchange_rate: Numeric,
11
+ ?expense_line_add: Array[Types::expense_line_add],
12
+ ?external_guid: String,
13
+ ?include_ret_element: Array["APAccountRef" | "AmountDue" | "AmountDueInHomeCurrency" | "ClassRef" | "CurrencyRef" | "DataExtRet" | "DueDate" | "EditSequence" | "ExchangeRate" | "ExpenseLineRet" | "ExternalGUID" | "IsPaid" | "IsPending" | "IsTaxIncluded" | "ItemGroupLineRet" | "ItemLineRet" | "LinkedTxn" | "ListID" | "Memo" | "OpenAmount" | "OwnerID" | "RefNumber" | "SalesTaxCodeRef" | "TermsRef" | "TimeCreated" | "TimeModified" | "TxnDate" | "TxnID" | "TxnNumber" | "VendorAddress" | "VendorRef"],
14
+ ?is_tax_included: bool,
15
+ ?item_group_line_add: Array[Types::item_group_line_add],
16
+ ?item_line_add: Array[Types::item_line_add],
17
+ ?link_to_txn_id: Array[String],
18
+ ?memo: String,
19
+ ?ref_number: String,
20
+ ?request_id: String,
21
+ ?sales_tax_code_ref: Types::ref,
22
+ ?terms_ref: Types::ref,
23
+ ?txn_date: String,
24
+ ?vendor_address: Types::address,
25
+ vendor_ref: Types::ref
26
+ }
27
+
28
+ type query_params = {
29
+ ?account_filter: Types::entity_filter,
30
+ ?currency_filter: Types::currency_filter,
31
+ ?entity_filter: Types::entity_filter,
32
+ ?include_line_items: bool,
33
+ ?include_linked_txns: bool,
34
+ ?include_ret_element: Array["APAccountRef" | "AmountDue" | "AmountDueInHomeCurrency" | "ClassRef" | "CurrencyRef" | "DataExtRet" | "DueDate" | "EditSequence" | "ExchangeRate" | "ExpenseLineRet" | "ExternalGUID" | "IsPaid" | "IsPending" | "IsTaxIncluded" | "ItemGroupLineRet" | "ItemLineRet" | "LinkedTxn" | "Memo" | "OpenAmount" | "RefNumber" | "SalesTaxCodeRef" | "TermsRef" | "TimeCreated" | "TimeModified" | "TxnDate" | "TxnID" | "TxnNumber" | "VendorAddress" | "VendorRef"],
35
+ ?iterator: bool,
36
+ ?max_returned: Integer,
37
+ ?meta_data: "MetaDataAndResponseData" | "MetaDataOnly" | "NoMetaData",
38
+ ?modified_date_range_filter: Types::modified_date_range_filter,
39
+ ?owner_id: Array[String],
40
+ ?paid_status: "All" | "NotPaidOnly" | "PaidOnly",
41
+ ?ref_number: Array[String],
42
+ ?ref_number_case_sensitive: Array[String],
43
+ ?ref_number_filter: Types::ref_number_filter,
44
+ ?ref_number_range_filter: Types::ref_number_range_filter,
45
+ ?request_id: String,
46
+ ?txn_date_range_filter: Types::date_range_filter,
47
+ ?txn_id: Array[String]
48
+ }
49
+
50
+ type update_params = {
51
+ ?ap_account_ref: Types::ref,
52
+ ?clear_expense_lines: bool,
53
+ ?clear_item_lines: bool,
54
+ ?due_date: String,
55
+ edit_sequence: String,
56
+ ?exchange_rate: Numeric,
57
+ ?expense_line_mod: Array[Types::expense_line_mod],
58
+ ?include_ret_element: Array["APAccountRef" | "AmountDue" | "AmountDueInHomeCurrency" | "ClassRef" | "CurrencyRef" | "DataExtRet" | "DueDate" | "EditSequence" | "ExchangeRate" | "ExpenseLineRet" | "ExternalGUID" | "IsPaid" | "IsPending" | "IsTaxIncluded" | "ItemGroupLineRet" | "ItemLineRet" | "LinkedTxn" | "ListID" | "Memo" | "OpenAmount" | "OwnerID" | "RefNumber" | "SalesTaxCodeRef" | "TermsRef" | "TimeCreated" | "TimeModified" | "TxnDate" | "TxnID" | "TxnNumber" | "VendorAddress" | "VendorRef"],
59
+ ?is_tax_included: bool,
60
+ ?item_group_line_mod: Array[Types::item_group_line_mod],
61
+ ?item_line_mod: Array[Types::item_line_mod],
62
+ ?memo: String,
63
+ ?ref_number: String,
64
+ ?request_id: String,
65
+ ?sales_tax_code_ref: Types::ref,
66
+ ?terms_ref: Types::ref,
67
+ ?txn_date: String,
68
+ txn_id: String,
69
+ ?vendor_address: Types::address,
70
+ ?vendor_ref: Types::ref
71
+ }
72
+
73
+ def create: (String connection_id, ?create_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
74
+ def query: (String connection_id, ?query_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
75
+ def update: (String connection_id, ?update_params params, webhook_url: String, ?idempotency_key: String?) -> Hash[String, untyped]
76
+ end
77
+ end
78
+ end