sageone_sdk 0.0.1

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 (198) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +15 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +15 -0
  5. data/Fudgefile +27 -0
  6. data/Gemfile +12 -0
  7. data/Guardfile +33 -0
  8. data/LICENSE +22 -0
  9. data/README.md +57 -0
  10. data/Rakefile +10 -0
  11. data/fudge_settings.yml +5 -0
  12. data/lib/sageone_sdk.rb +16 -0
  13. data/lib/sageone_sdk/authentication.rb +8 -0
  14. data/lib/sageone_sdk/client.rb +117 -0
  15. data/lib/sageone_sdk/client/account_types.rb +19 -0
  16. data/lib/sageone_sdk/client/bank_accounts.rb +18 -0
  17. data/lib/sageone_sdk/client/chart_of_accounts.rb +21 -0
  18. data/lib/sageone_sdk/client/contact_types.rb +20 -0
  19. data/lib/sageone_sdk/client/contacts.rb +82 -0
  20. data/lib/sageone_sdk/client/countries.rb +18 -0
  21. data/lib/sageone_sdk/client/expenditures.rb +26 -0
  22. data/lib/sageone_sdk/client/expense_methods.rb +19 -0
  23. data/lib/sageone_sdk/client/expense_types.rb +19 -0
  24. data/lib/sageone_sdk/client/financial_settings.rb +23 -0
  25. data/lib/sageone_sdk/client/income_methods.rb +19 -0
  26. data/lib/sageone_sdk/client/income_types.rb +19 -0
  27. data/lib/sageone_sdk/client/incomes.rb +51 -0
  28. data/lib/sageone_sdk/client/journals.rb +27 -0
  29. data/lib/sageone_sdk/client/ledger_accounts.rb +52 -0
  30. data/lib/sageone_sdk/client/payment_statuses.rb +18 -0
  31. data/lib/sageone_sdk/client/period_types.rb +19 -0
  32. data/lib/sageone_sdk/client/products.rb +50 -0
  33. data/lib/sageone_sdk/client/purchase_invoices.rb +61 -0
  34. data/lib/sageone_sdk/client/sales_invoices.rb +65 -0
  35. data/lib/sageone_sdk/client/services.rb +48 -0
  36. data/lib/sageone_sdk/client/tax_rates.rb +18 -0
  37. data/lib/sageone_sdk/client/transactions.rb +13 -0
  38. data/lib/sageone_sdk/configurable.rb +43 -0
  39. data/lib/sageone_sdk/default.rb +47 -0
  40. data/lib/sageone_sdk/middleware.rb +6 -0
  41. data/lib/sageone_sdk/middleware/sdata_parser.rb +29 -0
  42. data/lib/sageone_sdk/middleware/signature.rb +26 -0
  43. data/lib/sageone_sdk/sdata_error_response.rb +36 -0
  44. data/lib/sageone_sdk/sdata_response.rb +58 -0
  45. data/lib/sageone_sdk/signature.rb +115 -0
  46. data/lib/sageone_sdk/version.rb +3 -0
  47. data/sageone_sdk.gemspec +37 -0
  48. data/spec/cassettes/SageoneSdk_Client_AccountTypes/account_types/_id/returns_a_specific_account_type.json +1 -0
  49. data/spec/cassettes/SageoneSdk_Client_AccountTypes/account_types/allows_pagination.json +1 -0
  50. data/spec/cassettes/SageoneSdk_Client_AccountTypes/account_types/returns_all_account_types.json +1 -0
  51. data/spec/cassettes/SageoneSdk_Client_BankAccounts/bank_accounts/_id/returns_a_specific_bank_account.json +1 -0
  52. data/spec/cassettes/SageoneSdk_Client_BankAccounts/bank_accounts/allows_pagination.json +1 -0
  53. data/spec/cassettes/SageoneSdk_Client_BankAccounts/bank_accounts/returns_all_bank_accounts.json +1 -0
  54. data/spec/cassettes/SageoneSdk_Client_ChartOfAccounts/chart_of_accounts_structure/returns_the_chart_of_accounts_structure.json +1 -0
  55. data/spec/cassettes/SageoneSdk_Client_ChartOfAccounts/chart_of_accounts_templates/returns_the_chart_of_accounts_templates.json +1 -0
  56. data/spec/cassettes/SageoneSdk_Client_ContactTypes/contact_types/_id/returns_a_specific_contact_type.json +1 -0
  57. data/spec/cassettes/SageoneSdk_Client_ContactTypes/contact_types/allows_pagination.json +1 -0
  58. data/spec/cassettes/SageoneSdk_Client_ContactTypes/contact_types/returns_all_contact_types.json +1 -0
  59. data/spec/cassettes/SageoneSdk_Client_Contacts/contacts/_id/returns_a_specific_contact.json +1 -0
  60. data/spec/cassettes/SageoneSdk_Client_Contacts/contacts/allows_pagination.json +1 -0
  61. data/spec/cassettes/SageoneSdk_Client_Contacts/contacts/returns_all_contacts.json +1 -0
  62. data/spec/cassettes/SageoneSdk_Client_Contacts/create_contacts/creates_a_new_contact.json +1 -0
  63. data/spec/cassettes/SageoneSdk_Client_Contacts/create_contacts/on_error/responds_with_an_appropriate_error_message.json +1 -0
  64. data/spec/cassettes/SageoneSdk_Client_Contacts/delete_a_contact/deletes_the_contact.json +1 -0
  65. data/spec/cassettes/SageoneSdk_Client_Contacts/update_a_contact/updates_the_given_contact.json +1 -0
  66. data/spec/cassettes/SageoneSdk_Client_Countries/countries/_id/returns_a_specific_account_type.json +1 -0
  67. data/spec/cassettes/SageoneSdk_Client_Countries/countries/allows_pagination.json +1 -0
  68. data/spec/cassettes/SageoneSdk_Client_Countries/countries/returns_all_countries.json +1 -0
  69. data/spec/cassettes/SageoneSdk_Client_Expenditures/create_expenditures/creates_a_new_expenditure.json +1 -0
  70. data/spec/cassettes/SageoneSdk_Client_Expenditures/create_expenditures/on_error/responds_with_an_appropriate_error_message.json +1 -0
  71. data/spec/cassettes/SageoneSdk_Client_Expenditures/delete_an_expenditure/deletes_the_expenditure.json +1 -0
  72. data/spec/cassettes/SageoneSdk_Client_Expenditures/expenditures/_id/returns_a_specific_expenditure.json +1 -0
  73. data/spec/cassettes/SageoneSdk_Client_Expenditures/expenditures/allows_pagination.json +1 -0
  74. data/spec/cassettes/SageoneSdk_Client_Expenditures/expenditures/returns_all_expenditures.json +1 -0
  75. data/spec/cassettes/SageoneSdk_Client_Expenditures/update_an_expenditure/updates_the_given_expenditure.json +1 -0
  76. data/spec/cassettes/SageoneSdk_Client_ExpenseMethods/expense_methods/_id/returns_a_specific_contact_type.json +1 -0
  77. data/spec/cassettes/SageoneSdk_Client_ExpenseMethods/expense_methods/returns_all_expense_methods.json +1 -0
  78. data/spec/cassettes/SageoneSdk_Client_ExpenseMethods/income_methods/_id/returns_a_specific_contact_type.json +1 -0
  79. data/spec/cassettes/SageoneSdk_Client_ExpenseMethods/income_methods/allows_pagination.json +1 -0
  80. data/spec/cassettes/SageoneSdk_Client_ExpenseMethods/income_methods/returns_all_income_methods.json +1 -0
  81. data/spec/cassettes/SageoneSdk_Client_ExpenseTypes/expense_types/_id/returns_a_specific_contact_type.json +1 -0
  82. data/spec/cassettes/SageoneSdk_Client_ExpenseTypes/expense_types/allows_pagination.json +1 -0
  83. data/spec/cassettes/SageoneSdk_Client_ExpenseTypes/expense_types/returns_all_expense_types.json +1 -0
  84. data/spec/cassettes/SageoneSdk_Client_FinancialSettings/financial_settings/returns_the_financial_settings.json +1 -0
  85. data/spec/cassettes/SageoneSdk_Client_FinancialSettings/update_financial_settings/updates_the_financial_settings.json +1 -0
  86. data/spec/cassettes/SageoneSdk_Client_IncomeMethods/income_methods/_id/returns_a_specific_contact_type.json +1 -0
  87. data/spec/cassettes/SageoneSdk_Client_IncomeMethods/income_methods/returns_all_income_methods.json +1 -0
  88. data/spec/cassettes/SageoneSdk_Client_IncomeTypes/income_types/_id/returns_a_specific_contact_type.json +1 -0
  89. data/spec/cassettes/SageoneSdk_Client_IncomeTypes/income_types/allows_pagination.json +1 -0
  90. data/spec/cassettes/SageoneSdk_Client_IncomeTypes/income_types/returns_all_income_types.json +1 -0
  91. data/spec/cassettes/SageoneSdk_Client_Incomes/create_incomes/creates_a_new_income.json +1 -0
  92. data/spec/cassettes/SageoneSdk_Client_Incomes/create_incomes/on_error/responds_with_an_appropriate_error_message.json +1 -0
  93. data/spec/cassettes/SageoneSdk_Client_Incomes/delete_an_income/deletes_the_income.json +1 -0
  94. data/spec/cassettes/SageoneSdk_Client_Incomes/incomes/_id/returns_a_specific_income.json +1 -0
  95. data/spec/cassettes/SageoneSdk_Client_Incomes/incomes/allows_pagination.json +1 -0
  96. data/spec/cassettes/SageoneSdk_Client_Incomes/incomes/returns_all_incomes.json +1 -0
  97. data/spec/cassettes/SageoneSdk_Client_Incomes/update_an_income/updates_the_given_income.json +1 -0
  98. data/spec/cassettes/SageoneSdk_Client_Journals/journals/creates_a_journal.json +1 -0
  99. data/spec/cassettes/SageoneSdk_Client_Journals/journals/on_error/responds_with_an_appropriate_error_message.json +1 -0
  100. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/create_a_ledger_account/creates_a_new_ledger_account.json +1 -0
  101. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/create_a_ledger_account/on_error/responds_with_an_appropriate_error_message.json +1 -0
  102. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/ledger_account_balances/does_not_return_ledger_accounts_with_a_zero_balance.json +1 -0
  103. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/ledger_account_balances/returns_ledger_accounts_with_a_balance.json +1 -0
  104. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/ledger_accounts/_id/returns_a_specific_ledger_account.json +1 -0
  105. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/ledger_accounts/allows_pagination.json +1 -0
  106. data/spec/cassettes/SageoneSdk_Client_LedgerAccounts/ledger_accounts/returns_all_ledger_accounts.json +1 -0
  107. data/spec/cassettes/SageoneSdk_Client_PaymentStatuses/payment_statuses/_id/returns_a_specific_contact_type.json +1 -0
  108. data/spec/cassettes/SageoneSdk_Client_PaymentStatuses/payment_statuses/allows_pagination.json +1 -0
  109. data/spec/cassettes/SageoneSdk_Client_PaymentStatuses/payment_statuses/returns_all_payment_statuses.json +1 -0
  110. data/spec/cassettes/SageoneSdk_Client_PeriodTypes/period_types/_id/returns_a_specific_contact_type.json +1 -0
  111. data/spec/cassettes/SageoneSdk_Client_PeriodTypes/period_types/allows_pagination.json +1 -0
  112. data/spec/cassettes/SageoneSdk_Client_PeriodTypes/period_types/returns_all_period_types.json +1 -0
  113. data/spec/cassettes/SageoneSdk_Client_Products/create_products/creates_a_new_product.json +1 -0
  114. data/spec/cassettes/SageoneSdk_Client_Products/create_products/on_error/responds_with_an_appropriate_error_message.json +1 -0
  115. data/spec/cassettes/SageoneSdk_Client_Products/delete_a_product/deletes_the_product.json +1 -0
  116. data/spec/cassettes/SageoneSdk_Client_Products/products/_id/returns_a_specific_product.json +1 -0
  117. data/spec/cassettes/SageoneSdk_Client_Products/products/allows_pagination.json +1 -0
  118. data/spec/cassettes/SageoneSdk_Client_Products/products/returns_all_products.json +1 -0
  119. data/spec/cassettes/SageoneSdk_Client_Products/update_a_product/updates_the_given_product.json +1 -0
  120. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/create_purchase_invoices/creates_a_new_purchase_invoice.json +1 -0
  121. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/create_purchase_invoices/on_error/responds_with_an_appropriate_error_message.json +1 -0
  122. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/delete_a_purchase_invoice/deletes_the_purchase_invoice.json +1 -0
  123. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/purchase_invoices/_id/returns_a_specific_purchase_invoice.json +1 -0
  124. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/purchase_invoices/allows_pagination.json +1 -0
  125. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/purchase_invoices/returns_all_purchase_invoices.json +1 -0
  126. data/spec/cassettes/SageoneSdk_Client_PurchaseInvoices/update_a_purchase_invoice/updates_the_given_purchase_invoice.json +1 -0
  127. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/create_sales_invoices/creates_a_new_sales_invoice.json +1 -0
  128. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/create_sales_invoices/on_error/responds_with_an_appropriate_error_message.json +1 -0
  129. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/delete_a_sales_invoice/deletes_the_sales_invoice.json +1 -0
  130. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/sales_invoices/_id/returns_a_specific_sales_invoice.json +1 -0
  131. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/sales_invoices/allows_pagination.json +1 -0
  132. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/sales_invoices/returns_all_sales_invoices.json +1 -0
  133. data/spec/cassettes/SageoneSdk_Client_SalesInvoices/update_a_sales_invoice/updates_the_given_sales_invoice.json +1 -0
  134. data/spec/cassettes/SageoneSdk_Client_Services/create_services/creates_a_new_service.json +1 -0
  135. data/spec/cassettes/SageoneSdk_Client_Services/create_services/on_error/responds_with_an_appropriate_error_message.json +1 -0
  136. data/spec/cassettes/SageoneSdk_Client_Services/delete_a_service/deletes_the_service.json +1 -0
  137. data/spec/cassettes/SageoneSdk_Client_Services/services/_id/returns_a_specific_service.json +1 -0
  138. data/spec/cassettes/SageoneSdk_Client_Services/services/allows_pagination.json +1 -0
  139. data/spec/cassettes/SageoneSdk_Client_Services/services/returns_all_services.json +1 -0
  140. data/spec/cassettes/SageoneSdk_Client_Services/update_a_service/updates_the_given_service.json +1 -0
  141. data/spec/cassettes/SageoneSdk_Client_TaxRates/tax_rates/_id/returns_a_specific_contact_type.json +1 -0
  142. data/spec/cassettes/SageoneSdk_Client_TaxRates/tax_rates/allows_pagination.json +1 -0
  143. data/spec/cassettes/SageoneSdk_Client_TaxRates/tax_rates/returns_all_tax_rates.json +1 -0
  144. data/spec/cassettes/SageoneSdk_Client_Transactions/transactions/returns_all_transactions.json +1 -0
  145. data/spec/cassettes/account_types_index.json +1 -0
  146. data/spec/cassettes/bank_accounts_index.json +1 -0
  147. data/spec/cassettes/contact_types_index.json +1 -0
  148. data/spec/cassettes/contacts_index.json +1 -0
  149. data/spec/cassettes/countries_index.json +1 -0
  150. data/spec/cassettes/customer_create.json +1 -0
  151. data/spec/cassettes/customers_index.json +1 -0
  152. data/spec/cassettes/expenditure_create.json +1 -0
  153. data/spec/cassettes/expenditures_index.json +1 -0
  154. data/spec/cassettes/expense_methods_index.json +1 -0
  155. data/spec/cassettes/expense_types_index.json +1 -0
  156. data/spec/cassettes/income_create.json +1 -0
  157. data/spec/cassettes/income_methods_index.json +1 -0
  158. data/spec/cassettes/income_types_index.json +1 -0
  159. data/spec/cassettes/incomes_index.json +1 -0
  160. data/spec/cassettes/ledger_accounts_index.json +1 -0
  161. data/spec/cassettes/payment_statuses_index.json +1 -0
  162. data/spec/cassettes/period_types_index.json +1 -0
  163. data/spec/cassettes/product_create.json +1 -0
  164. data/spec/cassettes/products_index.json +1 -0
  165. data/spec/cassettes/purchase_invoice_create.json +1 -0
  166. data/spec/cassettes/purchase_invoices_index.json +1 -0
  167. data/spec/cassettes/sales_invoice_create.json +1 -0
  168. data/spec/cassettes/sales_invoices_index.json +1 -0
  169. data/spec/cassettes/service_create.json +1 -0
  170. data/spec/cassettes/services_index.json +1 -0
  171. data/spec/cassettes/suppliers_index.json +1 -0
  172. data/spec/cassettes/tax_rates_index.json +1 -0
  173. data/spec/sageone_sdk/client/account_types_spec.rb +29 -0
  174. data/spec/sageone_sdk/client/bank_accounts_spec.rb +34 -0
  175. data/spec/sageone_sdk/client/chart_of_accounts_spec.rb +23 -0
  176. data/spec/sageone_sdk/client/contact_types_spec.rb +29 -0
  177. data/spec/sageone_sdk/client/contacts_spec.rb +75 -0
  178. data/spec/sageone_sdk/client/countries_spec.rb +29 -0
  179. data/spec/sageone_sdk/client/expenditures_spec.rb +113 -0
  180. data/spec/sageone_sdk/client/expense_methods_spec.rb +29 -0
  181. data/spec/sageone_sdk/client/expense_types_spec.rb +29 -0
  182. data/spec/sageone_sdk/client/financial_settings_spec.rb +23 -0
  183. data/spec/sageone_sdk/client/income_methods_spec.rb +29 -0
  184. data/spec/sageone_sdk/client/income_types_spec.rb +29 -0
  185. data/spec/sageone_sdk/client/incomes_spec.rb +114 -0
  186. data/spec/sageone_sdk/client/journals_spec.rb +39 -0
  187. data/spec/sageone_sdk/client/ledger_accounts_spec.rb +65 -0
  188. data/spec/sageone_sdk/client/payment_statuses_spec.rb +29 -0
  189. data/spec/sageone_sdk/client/period_types_spec.rb +29 -0
  190. data/spec/sageone_sdk/client/products_spec.rb +75 -0
  191. data/spec/sageone_sdk/client/purchase_invoices_spec.rb +124 -0
  192. data/spec/sageone_sdk/client/sales_invoices_spec.rb +126 -0
  193. data/spec/sageone_sdk/client/services_spec.rb +75 -0
  194. data/spec/sageone_sdk/client/tax_rates_spec.rb +29 -0
  195. data/spec/sageone_sdk/client/transactions_spec.rb +16 -0
  196. data/spec/sageone_sdk_spec.rb +19 -0
  197. data/spec/spec_helper.rb +40 -0
  198. metadata +601 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5f5d8913f681c7abbf20eb961e6f70f8a2739ce8
4
+ data.tar.gz: b51a5a7e33ee0dea22fd0a77b00c7af91342e609
5
+ SHA512:
6
+ metadata.gz: 731ed54acd1fbe639d71622d99688d8d62a757bfcafd6270f43655fda3fb87fd1427616e9c2e07f9ff7f73a0e7e0523800d8da8099aeb2b43df4453d7841d62c
7
+ data.tar.gz: 357ddf19b61efa98d5afdc85ddd34fd978621f13a6d77ad6cc939c3f27582f9c30fb47832498bdbd0dd106cfe5f7629bb09d980557daf8d58eaaf20fac123805
@@ -0,0 +1,15 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
15
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --require spec_helper
@@ -0,0 +1,15 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.3.0
4
+ - 2.2.4
5
+ - 2.2.3
6
+ - 2.2.1
7
+ - 2.2.0
8
+ - 2.1.8
9
+ - 2.1.7
10
+ - 2.1.6
11
+ - 2.1.5
12
+ - 2.1.4
13
+ - 2.1.3
14
+ - 2.1.1
15
+ - 2.0.0
@@ -0,0 +1,27 @@
1
+ task_group :spec do
2
+ rspec :coverage => 80
3
+ end
4
+
5
+ task_group :docs do
6
+ task :yard, :coverage => 68
7
+ end
8
+
9
+ task_group :codestyle do
10
+ task :cane, :max_width => 120
11
+ end
12
+
13
+ task_group :duplication do
14
+ task :flay, :exclude => '^\.\/spec\/'
15
+ end
16
+
17
+ task_group :complexity do
18
+ task :flog, :exclude => '^\.\/spec\/', :methods => true
19
+ end
20
+
21
+ build :default do
22
+ task_group :docs
23
+ task_group :codestyle
24
+ task_group :complexity
25
+ task_group :duplication
26
+ task_group :spec
27
+ end
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in sageone.gemspec
4
+ gemspec
5
+
6
+ group :test do
7
+ gem "guard-rspec", require: false
8
+ gem 'webmock'
9
+ gem 'pry'
10
+ gem 'simplecov'
11
+ gem 'vcr'
12
+ end
@@ -0,0 +1,33 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ # Note: The cmd option is now required due to the increasing number of ways
5
+ # rspec may be run, below are examples of the most common uses.
6
+ # * bundler: 'bundle exec rspec'
7
+ # * bundler binstubs: 'bin/rspec'
8
+ # * spring: 'bin/rsspec' (This will use spring if running and you have
9
+ # installed the spring binstubs per the docs)
10
+ # * zeus: 'zeus rspec' (requires the server to be started separetly)
11
+ # * 'just' rspec: 'rspec'
12
+ guard :rspec, cmd: 'bundle exec rspec' do
13
+ watch(%r{^spec/.+_spec\.rb$})
14
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
15
+ watch('spec/spec_helper.rb') { "spec" }
16
+
17
+ # Rails example
18
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
19
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
20
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
21
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
22
+ watch('config/routes.rb') { "spec/routing" }
23
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
24
+ watch('spec/rails_helper.rb') { "spec" }
25
+
26
+ # Capybara features specs
27
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
28
+
29
+ # Turnip features and steps
30
+ watch(%r{^spec/acceptance/(.+)\.feature$})
31
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
32
+ end
33
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Sage
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,57 @@
1
+ # SageoneSdk
2
+
3
+ [![Build Status](https://travis-ci.org/Sage/sageone_api_ruby_sdk.svg?branch=master)](https://travis-ci.org/Sage/sageone_api_ruby_sdk)
4
+
5
+ The `sageone_sdk` gem provides Ruby methods for accessing the Sage One API endpoints.
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'sageone_sdk'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install sageone_sdk
22
+
23
+ ## Usage
24
+
25
+ To create a `SageoneSdk::Client`, you need to provide your access_token and signing_secret:
26
+
27
+ ```
28
+ @client = SageoneSdk::Client.new({access_token: @access_token,
29
+ signing_secret: @signing_secret})
30
+ ```
31
+
32
+ Further information about obtaining these is available [here](https://developers.sageone.com/docs/en/v1#overview).
33
+
34
+ You can then call the required method on the `@client`:
35
+
36
+ ```
37
+ @client.bank_accounts
38
+ => #<SageoneSdk::SDataResponse:0x007faaa9eb1760
39
+ @data=
40
+ {"$totalResults"=>2,
41
+ "$startIndex"=>0,
42
+ "$itemsPerPage"=>20,
43
+ "$resources"=>
44
+ [{"id"=>214227,
45
+ "account_name"=>"Current",
46
+ #...}]
47
+ }>
48
+ ```
49
+
50
+
51
+ ## Contributing
52
+
53
+ 1. Fork it ( https://github.com/[my-github-username]/sageone/fork )
54
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
55
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
56
+ 4. Push to the branch (`git push origin my-new-feature`)
57
+ 5. Create a new Pull Request
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+ RSpec::Core::RakeTask.new(:spec)
4
+
5
+ task :default => :fudge
6
+
7
+ # Test Fudge using Fudge
8
+ task :fudge do
9
+ exec 'fudge build 2> /dev/null'
10
+ end
@@ -0,0 +1,5 @@
1
+ flay:
2
+ max: 498
3
+ flog:
4
+ max: 28
5
+ average: 5.5
@@ -0,0 +1,16 @@
1
+ require "sageone_sdk/client"
2
+ require "sageone_sdk/default"
3
+ # SageoneSdk
4
+ module SageoneSdk
5
+ autoload :SDataResponse, "sageone_sdk/sdata_response"
6
+ class << self
7
+ include SageoneSdk::Configurable
8
+
9
+ def client
10
+ @client = SageoneSdk::Client.new unless defined?(@client)
11
+ @client
12
+ end
13
+ end
14
+ end
15
+
16
+ SageoneSdk.setup
@@ -0,0 +1,8 @@
1
+ module SageoneSdk
2
+ # Authentication
3
+ module Authentication
4
+ def token_authenticated?
5
+ !!@access_token
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,117 @@
1
+ require "sawyer"
2
+ require "faraday_middleware"
3
+ require "sageone_sdk/authentication"
4
+ require "sageone_sdk/configurable"
5
+ require "sageone_sdk/middleware"
6
+ require "sageone_sdk/client/account_types"
7
+ require "sageone_sdk/client/bank_accounts"
8
+ require "sageone_sdk/client/chart_of_accounts"
9
+ require "sageone_sdk/client/contact_types"
10
+ require "sageone_sdk/client/contacts"
11
+ require "sageone_sdk/client/countries"
12
+ require "sageone_sdk/client/expenditures"
13
+ require "sageone_sdk/client/expense_methods"
14
+ require "sageone_sdk/client/expense_types"
15
+ require "sageone_sdk/client/financial_settings"
16
+ require "sageone_sdk/client/income_methods"
17
+ require "sageone_sdk/client/income_types"
18
+ require "sageone_sdk/client/incomes"
19
+ require "sageone_sdk/client/journals"
20
+ require "sageone_sdk/client/ledger_accounts"
21
+ require "sageone_sdk/client/payment_statuses"
22
+ require "sageone_sdk/client/period_types"
23
+ require "sageone_sdk/client/purchase_invoices"
24
+ require "sageone_sdk/client/products"
25
+ require "sageone_sdk/client/sales_invoices"
26
+ require "sageone_sdk/client/services"
27
+ require "sageone_sdk/client/tax_rates"
28
+ require "sageone_sdk/client/transactions"
29
+
30
+ module SageoneSdk
31
+ # Client
32
+ class Client
33
+ include SageoneSdk::Authentication
34
+ include SageoneSdk::Configurable
35
+ include SageoneSdk::Client::AccountTypes
36
+ include SageoneSdk::Client::BankAccounts
37
+ include SageoneSdk::Client::ChartOfAccounts
38
+ include SageoneSdk::Client::ContactTypes
39
+ include SageoneSdk::Client::Contacts
40
+ include SageoneSdk::Client::Countries
41
+ include SageoneSdk::Client::Expenditures
42
+ include SageoneSdk::Client::ExpenseMethods
43
+ include SageoneSdk::Client::ExpenseTypes
44
+ include SageoneSdk::Client::FinancialSettings
45
+ include SageoneSdk::Client::IncomeMethods
46
+ include SageoneSdk::Client::IncomeTypes
47
+ include SageoneSdk::Client::Incomes
48
+ include SageoneSdk::Client::Journals
49
+ include SageoneSdk::Client::LedgerAccounts
50
+ include SageoneSdk::Client::PaymentStatuses
51
+ include SageoneSdk::Client::PeriodTypes
52
+ include SageoneSdk::Client::PurchaseInvoices
53
+ include SageoneSdk::Client::Products
54
+ include SageoneSdk::Client::SalesInvoices
55
+ include SageoneSdk::Client::Services
56
+ include SageoneSdk::Client::TaxRates
57
+ include SageoneSdk::Client::Transactions
58
+
59
+ def initialize(options = {})
60
+ SageoneSdk::Configurable.keys.each do |key|
61
+ instance_variable_set(:"@#{key}", options[key] || SageoneSdk.instance_variable_get(:"@#{key}"))
62
+ end
63
+ end
64
+
65
+ def last_response
66
+ @last_response if defined? @last_response
67
+ end
68
+
69
+ def paginate(resource, options = {})
70
+ data = get(resource, options)
71
+ data
72
+ end
73
+
74
+ def get(path, data={})
75
+ request(:get, path, data)
76
+ end
77
+
78
+ def post(path, data={})
79
+ request(:post, path, data)
80
+ end
81
+
82
+ def put(path, data={})
83
+ request(:put, path, data)
84
+ end
85
+
86
+ def delete(path, data={})
87
+ request(:delete, path, data)
88
+ end
89
+
90
+ def request(method, path, data, options = {})
91
+ path = File.join("accounts", "v1", path)
92
+ @last_response = response = agent.public_send(method, URI::Parser.new.escape(path.to_s), data, options)
93
+ response.body
94
+ end
95
+
96
+ def agent
97
+ @agent ||= Faraday.new(api_endpoint, faraday_options) do |builder|
98
+ builder.request :url_encoded
99
+ builder.headers['Accept'] = default_media_type
100
+ builder.headers['Content-Type'] = "application/x-www-form-urlencoded"
101
+ builder.headers['User-Agent'] = user_agent
102
+ if token_authenticated?
103
+ builder.authorization 'Bearer', @access_token
104
+ end
105
+ builder.use SageoneSdk::Middleware::Signature, access_token, signing_secret
106
+ builder.use SageoneSdk::Middleware::SDataParser
107
+ builder.adapter Faraday.default_adapter
108
+ end
109
+ end
110
+
111
+ private
112
+
113
+ def faraday_options
114
+ {}
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,19 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the bank account types in Sage One.
5
+ # For example, Savings or Cash in Hand.
6
+ module AccountTypes
7
+
8
+ # @return [object] Returns all of the bank account types in Sage One.
9
+ def account_types(options = {})
10
+ get "account_types", options
11
+ end
12
+
13
+ # @return [object] Returns the bank account type with the given id.
14
+ def account_type(id, options = {})
15
+ get "account_types/#{id}", options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,18 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the bank accounts for the authenticated user's business.
5
+ module BankAccounts
6
+
7
+ # @return [object] Returns all bank accounts for the authenticated user's business.
8
+ def bank_accounts(options = {})
9
+ paginate "bank_accounts", options
10
+ end
11
+
12
+ # @return [object] Returns the bank account with the given id.
13
+ def bank_account(id, options = {})
14
+ get "bank_accounts/#{id}", options
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,21 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the chart of accounts. This is a list
5
+ # of all of the accounts used by your business. It defines the structure
6
+ # of your income, expenditure, assets, liabilities and capital when
7
+ # running your management reports.
8
+ module ChartOfAccounts
9
+
10
+ # @return [object] Returns all chart of accounts templates.
11
+ def coa_templates(options = {})
12
+ get "coa_templates", options
13
+ end
14
+
15
+ # @return [object] Returns the chart of accounts for the authenticated user's business.
16
+ def coa_structure(options = {})
17
+ get "coa_structure", options
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the types of contact records in Sage One such as Customer or Supplier.
5
+ module ContactTypes
6
+ CUSTOMER = 1.freeze
7
+ SUPPLIER = 2.freeze
8
+
9
+ # @return [object] Returns all of the contact types in Sage One. For example, Customer.
10
+ def contact_types(options = {})
11
+ get "contact_types", options
12
+ end
13
+
14
+ # @return [object] Returns the contact type with the given id.
15
+ def contact_type(id, options = {})
16
+ get "contact_types/#{id}", options
17
+ end
18
+ end
19
+ end
20
+ end