sageone_sdk 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
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,82 @@
1
+ module SageoneSdk
2
+ class Client
3
+ # Represents the contacts for the authenticated user's business.
4
+ module Contacts
5
+
6
+ # @return [object] Returns all contacts for the authenticated user's business.
7
+ def contacts(options = {})
8
+ paginate "contacts", options
9
+ end
10
+
11
+ # @return [object] Returns the contact with the given id.
12
+ def contact(id, options = {})
13
+ get "contacts/#{id}", options
14
+ end
15
+
16
+ # @return [object] Returns all customers for the authenticated user's business.
17
+ def customers(options = {})
18
+ options["contact_type_id"] = ContactTypes::CUSTOMER
19
+
20
+ contacts(options)
21
+ end
22
+
23
+ # @return [object] Returns all suppliers for the authenticated user's business.
24
+ def suppliers(options = {})
25
+ options["contact_type_id"] = ContactTypes::SUPPLIER
26
+
27
+ contacts(options)
28
+ end
29
+
30
+ # Creates a contact record with the data provided.
31
+ # @example Create a new contact record
32
+ # @client.create_contact(1, {"name" => "My new customer",
33
+ # "company_name" => "Sage UK Ltd"})
34
+ # @param type [integer] The contact type id. 1 = Customer, 2 = Supplier.
35
+ # @param data [hash] The contact record information.
36
+ # @param options [hash]
37
+ def create_contact(type, data, options = {})
38
+ data['contact_type_id'] = type
39
+
40
+ post "contacts", :contact => data
41
+ end
42
+
43
+ # Creates a customer record with the data provided.
44
+ # @example Create a new customer record
45
+ # @client.create_customer({"name" => "My new customer",
46
+ # "company_name" => "Sage UK Ltd"})
47
+ # @param data [hash] The customer record information.
48
+ # @param options [hash]
49
+ def create_customer(data, options = {})
50
+ create_contact(ContactTypes::CUSTOMER, data, options)
51
+ end
52
+
53
+ # Creates a supplier record with the data provided.
54
+ # @example Create a new supplier record
55
+ # @client.create_supplier({"name" => "My new supplier",
56
+ # "company_name" => "Sage UK Ltd"})
57
+ # @param data [hash] The supplier record information.
58
+ # @param options [hash]
59
+ def create_supplier(data, options = {})
60
+ create_contact(ContactTypes::SUPPLIER, data, options)
61
+ end
62
+
63
+ # Updates the given contact record with the data provided.
64
+ # @example Update contact record with id 1234
65
+ # @client.update_contact(1234, {"name" => "Updated contact name",
66
+ # "company_name" => "Updated company name"})
67
+ # @param id [integer] The id of the contact record to update.
68
+ # @param data [hash] The contact record information to update.
69
+ # @param options [hash]
70
+ def update_contact(id, data, options = {})
71
+ put "contacts/#{id}", :contact => data
72
+ end
73
+
74
+ # Deletes the given contact record.
75
+ # @param id [integer] The id of the contact record to delete.
76
+ # @param options [hash]
77
+ def delete_contact(id, options = {})
78
+ delete "contacts/#{id}"
79
+ end
80
+ end
81
+ end
82
+ end
@@ -0,0 +1,18 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the countries available to select in Sage One.
5
+ module Countries
6
+
7
+ # @return [object] Returns all countries.
8
+ def countries(options = {})
9
+ get "countries", options
10
+ end
11
+
12
+ # @return [object] Returns the country with the given id.
13
+ def country(id, options = {})
14
+ get "countries/#{id}", options
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ module SageoneSdk
2
+ class Client
3
+ # Expenditures
4
+ module Expenditures
5
+ def expenditures(options = {})
6
+ paginate "expenditures", options
7
+ end
8
+
9
+ def expenditure(id, options = {})
10
+ get "expenditures/#{id}", options
11
+ end
12
+
13
+ def create_expenditure(data, options = {})
14
+ post "expenditures", :expenditure => data
15
+ end
16
+
17
+ def update_expenditure(id, data, options = {})
18
+ put "expenditures/#{id}", :expenditure => data
19
+ end
20
+
21
+ def delete_expenditure(id, options = {})
22
+ delete "expenditures/#{id}"
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the payment methods available when recording a purchase.
5
+ # For example, credit card payment.
6
+ module ExpenseMethods
7
+
8
+ # @return [object] Returns all payment methods.
9
+ def expense_methods(options = {})
10
+ get "expense_methods", options
11
+ end
12
+
13
+ # @return [object] Returns the payment method with the given id.
14
+ def expense_method(id, options = {})
15
+ get "expense_methods/#{id}", options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents types of expense in Sage One. These are the categories
5
+ # a user can make purchases against.
6
+ module ExpenseTypes
7
+
8
+ # @return [object] Returns all expense types.
9
+ def expense_types(options = {})
10
+ get "expense_types", options
11
+ end
12
+
13
+ # @return [object] Returns the expense type with the given id.
14
+ def expense_type(id, options = {})
15
+ get "expense_types/#{id}", options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,23 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the financial settings in Sage One. This includes
5
+ # year end date and tax schemes.
6
+ module FinancialSettings
7
+
8
+ # @return [object] Returns the financial settings.
9
+ def financial_settings(options = {})
10
+ get "financial_settings", options
11
+ end
12
+
13
+ # Updates the financial settings with the data provided.
14
+ # @example Change the year end date
15
+ # @client.update_financial_settings({"year_end_date" => "2016-12-31"})
16
+ # @param data [hash] The settings information to update.
17
+ # @param options [hash]
18
+ def update_financial_settings(data, options = {})
19
+ put "financial_settings", :financial_settings => data
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,19 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the payment methods available when recording a sale.
5
+ # For example, bank receipt.
6
+ module IncomeMethods
7
+
8
+ # @return [object] Returns all payment methods.
9
+ def income_methods(options = {})
10
+ get "income_methods", options
11
+ end
12
+
13
+ # @return [object] Returns the payment method with the given id.
14
+ def income_method(id, options = {})
15
+ get "income_methods/#{id}", options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents types of sale in Sage One. These are the categories
5
+ # a user can make sales against.
6
+ module IncomeTypes
7
+
8
+ # @return [object] Returns all sales types.
9
+ def income_types(options = {})
10
+ get "income_types", options
11
+ end
12
+
13
+ # @return [object] Returns the sales type with the given id.
14
+ def income_type(id, options = {})
15
+ get "income_types/#{id}", options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,51 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents other income transactions for the authenticated user's business.
5
+ module Incomes
6
+
7
+ # @return [object] Returns all other income transactions for the authenticated user's business.
8
+ def incomes(options = {})
9
+ paginate "incomes", options
10
+ end
11
+
12
+ # @return [object] Returns the other income transaction with the given id.
13
+ def income(id, options = {})
14
+ get "incomes/#{id}", options
15
+ end
16
+
17
+ # Creates an other income transaction with the data provided.
18
+ # @example Create a new income transaction
19
+ # @client.create_income({"date" => "2016-01-25",
20
+ # "amount" => 100.0,
21
+ # "tax_amount" => 20.0,
22
+ # "tax_percentage_rate" => 20.0,
23
+ # "tax_code_id" => 1,
24
+ # "source_id" => 434,
25
+ # "destination_id" => 415,
26
+ # "payment_method_id" => 2})
27
+ # @param data [hash] The transaction information.
28
+ # @param options [hash]
29
+ def create_income(data, options = {})
30
+ post "incomes", :income => data
31
+ end
32
+
33
+ # Updates the given transaction with the data provided.
34
+ # @example Update the date of an income transaction
35
+ # @client.update_income(655324, {"date" => "2016-01-31"})
36
+ # @param id [integer] The id of the income transaction to update.
37
+ # @param data [hash] The transaction information to update.
38
+ # @param options [hash]
39
+ def update_income(id, data, options = {})
40
+ put "incomes/#{id}", :income => data
41
+ end
42
+
43
+ # Deletes the given income transaction.
44
+ # @param id [integer] The id of the income transaction to delete.
45
+ # @param options [hash]
46
+ def delete_income(id, options = {})
47
+ delete "incomes/#{id}"
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,27 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents journal trasnactions in Sage One.
5
+ module Journals
6
+
7
+ # Creates a journal entry with the data provided.
8
+ # @example Create a new journal transaction
9
+ # @client.create_journal({"reference" => "ref001",
10
+ # "description" => "description",
11
+ # "date" => "2016-01-01",
12
+ # "journal_lines[0][credit]" => 50.0,
13
+ # "journal_lines[0][debit]" => 0.0,
14
+ # "journal_lines[0][details]" => "detail",
15
+ # "journal_lines[0][ledger_account][nominal_code]" => 1,
16
+ # "journal_lines[1][credit]" => 0.0,
17
+ # "journal_lines[1][debit]" => 50.0,
18
+ # "journal_lines[1][details]" => "detail",
19
+ # "journal_lines[1][ledger_account][nominal_code]" => 9999})
20
+ # @param data [hash] The journal entry information.
21
+ # @param options [hash]
22
+ def create_journal(data, options = {})
23
+ post "journals", :journal => data
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,52 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents ledger accounts for the authenticated user's business.
5
+ module LedgerAccounts
6
+
7
+ # @return [object] Returns all ledger accounts for the authenticated user's business.
8
+ def ledger_accounts(options = {})
9
+ get "ledger_accounts", options
10
+ end
11
+
12
+ # @return [object] Returns the ledger account with the given id.
13
+ def ledger_account(id, options = {})
14
+ get "ledger_accounts/#{id}", options
15
+ end
16
+
17
+ # @return [object] Returns all ledger accounts with a balance for the given date range.
18
+ # @param options [hash]
19
+ # @option options [date] from_date The transaction from date.
20
+ # @option options [date] to_date The transaction to date.
21
+ # @example Get balances for January 2015
22
+ # @client.ledger_account_balances({'from_date' => '2015-01-01', 'to_date' => '2015-01-31'})
23
+ def ledger_account_balances(options = {})
24
+ get "ledger_accounts/balances", options
25
+ end
26
+
27
+ # @return [object] Returns the given ledger account and its balance for the given date range.
28
+ # @param id [integer] The ledger account id.
29
+ # @param options [hash]
30
+ # @option options [date] from_date The transaction from date.
31
+ # @option options [date] to_date The transaction to date.
32
+ # @example Get balances for ledger account id 1233 for January 2015
33
+ # @client.ledger_account_balances(1233, {'from_date' => '2015-01-01', 'to_date' => '2015-01-31'})
34
+ def ledger_account_balance(id, options = {})
35
+ get "ledger_accounts/#{id}/balance", options
36
+ end
37
+
38
+ # Creates a ledger account with the data provided.
39
+ # @example Create a new ledger account
40
+ # @client.create_ledger_account({ledger_name: "My new ledger account",
41
+ # display_name: "My new ledger account",
42
+ # nominal_code: 1235,
43
+ # included_in_chart: true,
44
+ # category_id: 1})
45
+ # @param data [hash] The ledger account information.
46
+ # @param options [hash]
47
+ def create_ledger_account(data, options = {})
48
+ post "ledger_accounts", :ledger_account => data
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,18 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the payment status of an invoice in Sage One. For example, Paid or Void.
5
+ module PaymentStatuses
6
+
7
+ # @return [object] Returns all payment statuses.
8
+ def payment_statuses(options = {})
9
+ get "payment_statuses", options
10
+ end
11
+
12
+ # @return [object] Returns the payment status with the given id.
13
+ def payment_status(id, options = {})
14
+ get "payment_statuses/#{id}", options
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the rate frequency in Sage One and refers to the chargeable
5
+ # period of a service. For example, hourly or daily.
6
+ module PeriodTypes
7
+
8
+ # @return [object] Returns all rate frequencies.
9
+ def period_types(options = {})
10
+ get "period_types", options
11
+ end
12
+
13
+ # @return [object] Returns the rate frequency with the given id.
14
+ def period_type(id, options = {})
15
+ get "period_types/#{id}", options
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,50 @@
1
+ module SageoneSdk
2
+ class Client
3
+
4
+ # Represents the products for the authenticated user's business.
5
+ module Products
6
+
7
+ # @return [object] Returns all products for the authenticated user's business.
8
+ def products(options = {})
9
+ paginate "products", options
10
+ end
11
+
12
+ # @return [object] Returns the product with the given id.
13
+ def product(id, options = {})
14
+ get "products/#{id}", options
15
+ end
16
+
17
+ # Creates a product record with the data provided.
18
+ # @example Create a new product record
19
+ # @client.create_product({description: "My new product",
20
+ # sales_price_includes_tax: false,
21
+ # ledger_account_id: 438,
22
+ # tax_code_id: 1,
23
+ # product_code: "PROD001",
24
+ # last_cost_price: 41.5,
25
+ # sales_price: 99.99})
26
+ # @param data [hash] The product record information.
27
+ # @param options [hash]
28
+ def create_product(data, options = {})
29
+ post "products", :product => data
30
+ end
31
+
32
+ # Updates the given product record with the data provided.
33
+ # @example Update a product sales price
34
+ # @client.update_product(2341, {sales_price: 199.99})
35
+ # @param id [integer] The id of the product record to update.
36
+ # @param data [hash] The product information to update.
37
+ # @param options [hash]
38
+ def update_product(id, data, options = {})
39
+ put "products/#{id}", :product => data
40
+ end
41
+
42
+ # Deletes the given product record.
43
+ # @param id [integer] The id of the product record to delete.
44
+ # @param options [hash]
45
+ def delete_product(id, options = {})
46
+ delete "products/#{id}"
47
+ end
48
+ end
49
+ end
50
+ end