bukku_rails 0.1.4 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df23a6a528a26b6ee952178ab0f4ecc1695b788e205044c5a373fd807df81c1d
4
- data.tar.gz: 858aa3808ea2089f9c5854ad02a823ec5ba13b678c3c033daacb6494896fac92
3
+ metadata.gz: c67f4ffcd9e8bb2bba1d68c241003ba09ade70e0e7b5006a01373d047b4cf5e9
4
+ data.tar.gz: aa4ae29f71918a76fcdab8ac286752dd5b8f4ad9ae79fb4089b2da95c5f5e4bf
5
5
  SHA512:
6
- metadata.gz: e61943b4520221cf4286a2cb8cc426e074cdfc5eeeb270f1548d84d2dc7ec285ed0caccffad3847aa7fa65d4c15d4e60a0dee25209c007d81f9751b70cd72d20
7
- data.tar.gz: a1b401386099562ee80bbd86717aa39b9132a55842c69627758e1c454c3ec4ee279fe1a642773feabdeebcfd2e26e226ae0e62c33e32885e757b736183070895
6
+ metadata.gz: cacbd80c9079264a39ac0426777de2d9110e974599768585685066f6cc04e2acec4fb371562b49759d6ff91385d91f3f05132b96c2b3580139aa69782dc1a868
7
+ data.tar.gz: 034b19b90d92d54f5f6361b8ba977b39a4c00d5a727fcb970e2cab6191fda237f87d9d29513bea1f51a5d976d053c676a21721643429a820b7e646af0064c922
data/README.md CHANGED
@@ -8,9 +8,19 @@ Take a look at [Bukku's API](https://developers.bukku.my) to know what data you
8
8
 
9
9
  ## Installation
10
10
 
11
- Add the gen into your Gemfile like so:
11
+ ### Rails
12
12
 
13
- `gem "bukku_rails`
13
+ Add the gem into your Gemfile like so:
14
+
15
+ `gem "bukku_rails"`
16
+
17
+ ### Ruby
18
+
19
+ 1. Install the gem `gem install bukku_rails`
20
+
21
+ 2. Test the gem standalone `irb -r bukku_rails`
22
+
23
+ 3. If your satisfied with the gem usage you can include the gem in your `Gemfile` of your app.
14
24
 
15
25
  ## Usage
16
26
 
@@ -18,9 +28,17 @@ You will need 2 things - your **subdomain** and **API Token**.
18
28
 
19
29
  You can get these after you login into your Bukku account, Control Panel -> Integrations -> Turn ON API Access.
20
30
 
21
- Note: Bukku offers 2 type of access - Staging and Production. You can [email Bukku](mailto:dev@bukku.my) for a Staging account which will be a great way to test your Rails app to see if it is extracting the correct data from Bukku's staging server (exactly the same app but at their staging server). Once you are satisfied you can then use access the Production server where your actual data lives.
31
+ Note: Bukku offers 2 type of access:
32
+
33
+ 1. *Staging* - For testing your app. You can [email Bukku](mailto:dev@bukku.my) for a Staging account which will be a great way to test your Rails app to see if it is extracting the correct data from Bukku's staging server (exactly the same app).
34
+
35
+ 2. *Production* - Your actual Bukku data, where all your data lives.
36
+
37
+ **Bukku Rails** provides usage for both access, under 2 different classes:
38
+
39
+ 1. *Staging* use the `BukkuTest` class, like so `client = BukkuTest.new(domain: "sub-domain", token: "token-from-bukku-fyi")`
22
40
 
23
- **Bukku Rails** provides usage for both access. For Staging use the `BukkuTest` class and actual Production simply use `Bukku` class. Then you can use any of the methods listed in the table below:
41
+ 2. *Production* use `Bukku` class, like so `client = Bukku.new(domain: "sub-domain", token: "token-from-bukku-my")`
24
42
 
25
43
  ### Available Methods
26
44
 
@@ -30,74 +48,74 @@ Just like in Rails the methods follow the singular and plural expression. Method
30
48
 
31
49
  | HTTP Method | Ruby Method | Endpoint |
32
50
  |------------|-------------|----------|
33
- | GET | `get_sales_quotes(**kwargs)` | `/sales/quotes` |
51
+ | GET | `get_sales_quotes(query-parameters)` | `/sales/quotes` |
34
52
  | GET | `get_sales_quote(id)` | `/sales/quotes/:id` |
35
- | GET | `get_sales_orders(**kwargs)` | `/sales/orders` |
53
+ | GET | `get_sales_orders(query-parameters)` | `/sales/orders` |
36
54
  | GET | `get_sales_order(id)` | `/sales/orders/:id` |
37
- | GET | `get_delivery_orders(**kwargs)` | `/sales/delivery_orders` |
55
+ | GET | `get_delivery_orders(query-parameters)` | `/sales/delivery_orders` |
38
56
  | GET | `get_delivery_order(id)` | `/sales/delivery_orders/:id` |
39
- | GET | `get_invoices(**kwargs)` | `/sales/invoices` |
57
+ | GET | `get_invoices(query-parameters)` | `/sales/invoices` |
40
58
  | GET | `get_invoice(id)` | `/sales/invoices/:id` |
41
- | GET | `get_sales_credit_notes(**kwargs)` | `/sales/credit_notes` |
59
+ | GET | `get_sales_credit_notes(query-parameters)` | `/sales/credit_notes` |
42
60
  | GET | `get_sales_credit_note(id)` | `/sales/credit_notes/:id` |
43
- | GET | `get_sales_payments(**kwargs)` | `/sales/payments` |
61
+ | GET | `get_sales_payments(query-parameters)` | `/sales/payments` |
44
62
  | GET | `get_sales_payment(id)` | `/sales/payments/:id` |
45
- | GET | `get_sales_refunds(**kwargs)` | `/sales/refunds` |
63
+ | GET | `get_sales_refunds(query-parameters)` | `/sales/refunds` |
46
64
  | GET | `get_sales_refund(id)` | `/sales/refunds/:id` |
47
65
 
48
66
  #### Purchases
49
67
 
50
68
  | HTTP Method | Ruby Method | Endpoint |
51
69
  |------------|-------------|----------|
52
- | GET | `get_purchase_orders(**kwargs)` | `/purchases/orders` |
70
+ | GET | `get_purchase_orders(query-parameters)` | `/purchases/orders` |
53
71
  | GET | `get_purchase_order(id)` | `/purchases/orders/:id` |
54
- | GET | `get_received_notes(**kwargs)` | `/purchases/goods_received_notes` |
72
+ | GET | `get_received_notes(query-parameters)` | `/purchases/goods_received_notes` |
55
73
  | GET | `get_received_note(id)` | `/purchases/goods_received_notes/:id` |
56
- | GET | `get_bills(**kwargs)` | `/purchases/bills` |
74
+ | GET | `get_bills(query-parameters)` | `/purchases/bills` |
57
75
  | GET | `get_bill(id)` | `/purchases/bills/:id` |
58
- | GET | `get_purchases_credit_notes(**kwargs)` | `/purchases/credit_notes` |
76
+ | GET | `get_purchases_credit_notes(query-parameters)` | `/purchases/credit_notes` |
59
77
  | GET | `get_purchases_credit_note(id)` | `/purchases/credit_notes/:id` |
60
- | GET | `get_purchases_payments(**kwargs)` | `/purchases/payments` |
78
+ | GET | `get_purchases_payments(query-parameters)` | `/purchases/payments` |
61
79
  | GET | `get_purchases_payments(id)` | `/purchases/payments/:id` |
62
- | GET | `get_purchases_refunds(**kwargs)` | `/purchases/refunds` |
80
+ | GET | `get_purchases_refunds(query-parameters)` | `/purchases/refunds` |
63
81
  | GET | `get_purchases_refund(id)` | `/purchases/refunds/:id` |
64
82
 
65
83
  #### Banking
66
84
 
67
85
  | HTTP Method | Ruby Method | Endpoint |
68
86
  |------------|-------------|----------|
69
- | GET | `get_banking_incomes(**kwargs)` | `/banking/incomes` |
87
+ | GET | `get_banking_incomes(query-parameters)` | `/banking/incomes` |
70
88
  | GET | `get_banking_income(id)` | `/banking/incomes/:id` |
71
- | GET | `get_banking_expenses(**kwargs)` | `/banking/expenses` |
89
+ | GET | `get_banking_expenses(query-parameters)` | `/banking/expenses` |
72
90
  | GET | `get_banking_expense(id)` | `/banking/expenses/:id` |
73
- | GET | `get_transfers(**kwargs)` | `/banking/transfers` |
91
+ | GET | `get_transfers(query-parameters)` | `/banking/transfers` |
74
92
  | GET | `get_transfer(id)` | `/banking/transfers/:id` |
75
93
 
76
94
  #### Contacts
77
95
 
78
96
  | HTTP Method | Ruby Method | Endpoint |
79
97
  |------------|-------------|----------|
80
- | GET | `get_contacts(**kwargs)` | `/contacts` |
98
+ | GET | `get_contacts(query-parameters)` | `/contacts` |
81
99
  | GET | `get_contact(id)` | `/contacts/:id` |
82
- | GET | `get_contact_groups(**kwargs)` | `/contacts/groups` |
100
+ | GET | `get_contact_groups(query-parameters)` | `/contacts/groups` |
83
101
  | GET | `get_contact_group(id)` | `/contacts/groups/:id` |
84
102
 
85
103
  #### Products
86
104
 
87
105
  | HTTP Method | Ruby Method | Endpoint |
88
106
  |------------|-------------|----------|
89
- | GET | `get_products(**kwargs)` | `/products` |
107
+ | GET | `get_products(query-parameters)` | `/products` |
90
108
  | GET | `get_product(id)` | `/products/:id` |
91
- | GET | `get_product_groups(**kwargs)` | `/products/groups` |
109
+ | GET | `get_product_groups(query-parameters)` | `/products/groups` |
92
110
  | GET | `get_product_group(id)` | `/products/groups/:id` |
93
111
 
94
112
  #### Accounting
95
113
 
96
114
  | HTTP Method | Ruby Method | Endpoint |
97
115
  |------------|-------------|----------|
98
- | GET | `get_journal_entries(**kwargs)` | `/journal_entries` |
116
+ | GET | `get_journal_entries(query-parameters)` | `/journal_entries` |
99
117
  | GET | `get_journal_entry(id)` | `/journal_entries/:id` |
100
- | GET | `get_accounts(**kwargs)` | `/accounts` |
118
+ | GET | `get_accounts(query-parameters)` | `/accounts` |
101
119
  | GET | `get_account(id)` | `/accounts/:id` |
102
120
 
103
121
  ### Examples
data/lib/bukku.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  class Bukku < Client
2
2
  # Usage of this integration as follows:
3
- # access = Bukku.new(token: "bukku_token_key", domain: "domain")
4
- # respond = access.<method>(parameters)
5
- # Example: respond = access.get_sales_invoices(date_from: "2025-11-25", date_to: "2025-11-30")
3
+ # access = BukkuTest.new(token: "bukku_token_key", domain: "domain")
4
+ # respond = access.<method>
6
5
 
6
+ # Testing URL
7
7
  BASE_URI = 'https://api.bukku.my'
8
8
 
9
9
  ## SALES
@@ -16,6 +16,10 @@ class Bukku < Client
16
16
  get "/sales/quotes/#{id}"
17
17
  end
18
18
 
19
+ def create_quote(body:)
20
+ post '/sales/quotes', body: body
21
+ end
22
+
19
23
  # Sales Order
20
24
  def get_sales_orders(**kwargs)
21
25
  get '/sales/orders', query: kwargs
@@ -25,6 +29,10 @@ class Bukku < Client
25
29
  get "/sales/orders/#{id}"
26
30
  end
27
31
 
32
+ def create_sales_order(body:)
33
+ post '/sales/orders', body: body
34
+ end
35
+
28
36
  # Delivery Order
29
37
  def get_delivery_orders(**kwargs)
30
38
  get '/sales/delivery_orders', query: kwargs
@@ -34,6 +42,10 @@ class Bukku < Client
34
42
  get "/sales/delivery_orders/#{id}"
35
43
  end
36
44
 
45
+ def create_delivery_order(body:)
46
+ post '/sales/delivery_orders', body: body
47
+ end
48
+
37
49
  # Invoice
38
50
  def get_invoices(**kwargs)
39
51
  get '/sales/invoices', query: kwargs
@@ -43,6 +55,10 @@ class Bukku < Client
43
55
  get "/sales/invoices/#{id}"
44
56
  end
45
57
 
58
+ def create_invoice(body:)
59
+ post '/sales/invoices', body: body
60
+ end
61
+
46
62
  # Credit Note
47
63
  def get_sales_credit_notes(**kwargs)
48
64
  get '/sales/credit_notes', query: kwargs
@@ -52,6 +68,10 @@ class Bukku < Client
52
68
  get "/sales/credit_notes/#{id}"
53
69
  end
54
70
 
71
+ def create_credit_note(body:)
72
+ post '/sales/credit_notes', body: body
73
+ end
74
+
55
75
  # Payment
56
76
  def get_sales_payments(**kwargs)
57
77
  get '/sales/payments', query: kwargs
@@ -61,7 +81,11 @@ class Bukku < Client
61
81
  get "/sales/payments/#{id}"
62
82
  end
63
83
 
64
- # Redund
84
+ def create_payment(body:)
85
+ post '/sales/payments', body: body
86
+ end
87
+
88
+ # Refund
65
89
  def get_sales_refunds(**kwargs)
66
90
  get '/sales/refunds', query: kwargs
67
91
  end
@@ -70,6 +94,10 @@ class Bukku < Client
70
94
  get "/sales/refunds/#{id}"
71
95
  end
72
96
 
97
+ def create_refund(body:)
98
+ post '/sales/refunds', body: body
99
+ end
100
+
73
101
  ## PURCHASE
74
102
  # Purchase Order
75
103
  def get_purchase_orders(**kwargs)
@@ -80,6 +108,10 @@ class Bukku < Client
80
108
  get "/purchases/orders/#{id}"
81
109
  end
82
110
 
111
+ def create_purchase_order(body:)
112
+ post '/purchases/orders', body: body
113
+ end
114
+
83
115
  ## Goods Received Note
84
116
  def get_received_notes(**kwargs)
85
117
  get '/purchases/goods_received_notes', query: kwargs
@@ -89,6 +121,10 @@ class Bukku < Client
89
121
  get "/purchases/goods_received_notes/#{id}"
90
122
  end
91
123
 
124
+ def create_received_note(body:)
125
+ post '/purchases/goods_received_notes', body: body
126
+ end
127
+
92
128
  # Bill
93
129
  def get_bills(**kwargs)
94
130
  get '/purchases/bills', query: kwargs
@@ -98,6 +134,10 @@ class Bukku < Client
98
134
  get "/purchases/bills/#{id}"
99
135
  end
100
136
 
137
+ def create_bill(body:)
138
+ post '/purchases/bills', body: body
139
+ end
140
+
101
141
  # Credit Note
102
142
  def get_purchases_credit_notes(**kwargs)
103
143
  get '/purchases/credit_notes', query: kwargs
@@ -107,6 +147,10 @@ class Bukku < Client
107
147
  get "/purchases/credit_notes/#{id}"
108
148
  end
109
149
 
150
+ def create_purchase_credit_note(body:)
151
+ post '/purchases/credit_note', body: body
152
+ end
153
+
110
154
  # Payment
111
155
  def get_purchases_payments(**kwargs)
112
156
  get '/purchases/payments', query: kwargs
@@ -116,6 +160,10 @@ class Bukku < Client
116
160
  get "/purchases/payments/#{id}"
117
161
  end
118
162
 
163
+ def create_purchases_payment(body:)
164
+ post '/purchases/payments', body: body
165
+ end
166
+
119
167
  # Refund
120
168
  def get_purchases_refunds(**kwargs)
121
169
  get '/purchases/refunds', query: kwargs
@@ -125,6 +173,10 @@ class Bukku < Client
125
173
  get "/purchases/refunds/#{id}"
126
174
  end
127
175
 
176
+ def create_purchases_refund(body:)
177
+ post '/purchases/refunds', body: body
178
+ end
179
+
128
180
  ## BANK
129
181
  # Money In
130
182
  def get_banking_incomes(**kwargs)
@@ -135,6 +187,10 @@ class Bukku < Client
135
187
  get "/banking/incomes/#{id}"
136
188
  end
137
189
 
190
+ def create_banking_income(body:)
191
+ post '/banking/incomes', body: body
192
+ end
193
+
138
194
  # Money Out
139
195
  def get_banking_expenses(**kwargs)
140
196
  get '/banking/expenses', query: kwargs
@@ -144,6 +200,10 @@ class Bukku < Client
144
200
  get "/banking/expenses/#{id}"
145
201
  end
146
202
 
203
+ def create_expense(body:)
204
+ post '/banking/expenses', body: body
205
+ end
206
+
147
207
  # Transfers
148
208
  def get_transfers(**kwargs)
149
209
  get '/banking/transfers', query: kwargs
@@ -153,6 +213,10 @@ class Bukku < Client
153
213
  get "/banking/transfers/#{id}"
154
214
  end
155
215
 
216
+ def create_transfer(body:)
217
+ post '/banking/transfer', body: body
218
+ end
219
+
156
220
  ## CONTACT
157
221
  # Contacts
158
222
  def get_contacts(**kwargs)
@@ -163,6 +227,10 @@ class Bukku < Client
163
227
  get "/contacts/#{id}"
164
228
  end
165
229
 
230
+ def create_contact(body:)
231
+ post '/contacts', body: body
232
+ end
233
+
166
234
  # Groups
167
235
  def get_contact_groups(**kwargs)
168
236
  get '/contacts/groups', query: kwargs
@@ -172,6 +240,10 @@ class Bukku < Client
172
240
  get "/contacts/groups/#{id}"
173
241
  end
174
242
 
243
+ def create_group(body:)
244
+ post '/contacts/groups', body: body
245
+ end
246
+
175
247
  ## PRODUCT
176
248
  # Product
177
249
  def get_products(**kwargs)
@@ -182,6 +254,19 @@ class Bukku < Client
182
254
  get "/products/#{id}"
183
255
  end
184
256
 
257
+ def create_product(body:)
258
+ post '/products', body: body
259
+ end
260
+
261
+ # Bundles
262
+ def get_bundle(id)
263
+ get "/products/bundles/#{id}"
264
+ end
265
+
266
+ def create_bundle(body:)
267
+ post '/products/bundles', body: body
268
+ end
269
+
185
270
  # Groups
186
271
  def get_product_groups(**kwargs)
187
272
  get '/products/groups', query: kwargs
@@ -191,6 +276,10 @@ class Bukku < Client
191
276
  get "/products/groups/#{id}"
192
277
  end
193
278
 
279
+ def create_product_group(body:)
280
+ post '/products/groups', body: body
281
+ end
282
+
194
283
  ## ACCOUNTING
195
284
  # Journal Entries
196
285
  def get_journal_entries(**kwargs)
@@ -201,6 +290,10 @@ class Bukku < Client
201
290
  get "/journal_entries/#{id}"
202
291
  end
203
292
 
293
+ def create_journal_entry(body:)
294
+ post '/journal_entries', body: body
295
+ end
296
+
204
297
  # Account
205
298
  def get_accounts(**kwargs)
206
299
  get '/accounts', query: kwargs
@@ -209,4 +302,13 @@ class Bukku < Client
209
302
  def get_account(id)
210
303
  get "/accounts/#{id}"
211
304
  end
305
+
306
+ def create_account(body:)
307
+ post '/accounts', body: body
308
+ end
309
+
310
+ # Files
311
+ def upload_file(file_data:, filename:, mime_type:)
312
+ upload '/files', file_data: file_data, filename: filename, mime_type: mime_type
313
+ end
212
314
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BukkuRails
4
- VERSION = '0.1.4'
4
+ VERSION = '0.2.1'
5
5
  end
data/lib/bukku_test.rb CHANGED
@@ -16,6 +16,10 @@ class BukkuTest < Client
16
16
  get "/sales/quotes/#{id}"
17
17
  end
18
18
 
19
+ def create_quote(body:)
20
+ post '/sales/quotes', body: body
21
+ end
22
+
19
23
  # Sales Order
20
24
  def get_sales_orders(**kwargs)
21
25
  get '/sales/orders', query: kwargs
@@ -25,6 +29,10 @@ class BukkuTest < Client
25
29
  get "/sales/orders/#{id}"
26
30
  end
27
31
 
32
+ def create_sales_order(body:)
33
+ post '/sales/orders', body: body
34
+ end
35
+
28
36
  # Delivery Order
29
37
  def get_delivery_orders(**kwargs)
30
38
  get '/sales/delivery_orders', query: kwargs
@@ -34,6 +42,10 @@ class BukkuTest < Client
34
42
  get "/sales/delivery_orders/#{id}"
35
43
  end
36
44
 
45
+ def create_delivery_order(body:)
46
+ post '/sales/delivery_orders', body: body
47
+ end
48
+
37
49
  # Invoice
38
50
  def get_invoices(**kwargs)
39
51
  get '/sales/invoices', query: kwargs
@@ -43,6 +55,10 @@ class BukkuTest < Client
43
55
  get "/sales/invoices/#{id}"
44
56
  end
45
57
 
58
+ def create_invoice(body:)
59
+ post '/sales/invoices', body: body
60
+ end
61
+
46
62
  # Credit Note
47
63
  def get_sales_credit_notes(**kwargs)
48
64
  get '/sales/credit_notes', query: kwargs
@@ -52,6 +68,10 @@ class BukkuTest < Client
52
68
  get "/sales/credit_notes/#{id}"
53
69
  end
54
70
 
71
+ def create_credit_note(body:)
72
+ post '/sales/credit_notes', body: body
73
+ end
74
+
55
75
  # Payment
56
76
  def get_sales_payments(**kwargs)
57
77
  get '/sales/payments', query: kwargs
@@ -61,7 +81,11 @@ class BukkuTest < Client
61
81
  get "/sales/payments/#{id}"
62
82
  end
63
83
 
64
- # Redund
84
+ def create_payment(body:)
85
+ post '/sales/payments', body: body
86
+ end
87
+
88
+ # Refund
65
89
  def get_sales_refunds(**kwargs)
66
90
  get '/sales/refunds', query: kwargs
67
91
  end
@@ -70,6 +94,10 @@ class BukkuTest < Client
70
94
  get "/sales/refunds/#{id}"
71
95
  end
72
96
 
97
+ def create_refund(body:)
98
+ post '/sales/refunds', body: body
99
+ end
100
+
73
101
  ## PURCHASE
74
102
  # Purchase Order
75
103
  def get_purchase_orders(**kwargs)
@@ -80,6 +108,10 @@ class BukkuTest < Client
80
108
  get "/purchases/orders/#{id}"
81
109
  end
82
110
 
111
+ def create_purchase_order(body:)
112
+ post '/purchases/orders', body: body
113
+ end
114
+
83
115
  ## Goods Received Note
84
116
  def get_received_notes(**kwargs)
85
117
  get '/purchases/goods_received_notes', query: kwargs
@@ -89,6 +121,10 @@ class BukkuTest < Client
89
121
  get "/purchases/goods_received_notes/#{id}"
90
122
  end
91
123
 
124
+ def create_received_note(body:)
125
+ post '/purchases/goods_received_notes', body: body
126
+ end
127
+
92
128
  # Bill
93
129
  def get_bills(**kwargs)
94
130
  get '/purchases/bills', query: kwargs
@@ -98,6 +134,10 @@ class BukkuTest < Client
98
134
  get "/purchases/bills/#{id}"
99
135
  end
100
136
 
137
+ def create_bill(body:)
138
+ post '/purchases/bills', body: body
139
+ end
140
+
101
141
  # Credit Note
102
142
  def get_purchases_credit_notes(**kwargs)
103
143
  get '/purchases/credit_notes', query: kwargs
@@ -107,6 +147,10 @@ class BukkuTest < Client
107
147
  get "/purchases/credit_notes/#{id}"
108
148
  end
109
149
 
150
+ def create_purchase_credit_note(body:)
151
+ post '/purchases/credit_note', body: body
152
+ end
153
+
110
154
  # Payment
111
155
  def get_purchases_payments(**kwargs)
112
156
  get '/purchases/payments', query: kwargs
@@ -116,6 +160,10 @@ class BukkuTest < Client
116
160
  get "/purchases/payments/#{id}"
117
161
  end
118
162
 
163
+ def create_purchases_payment(body:)
164
+ post '/purchases/payments', body: body
165
+ end
166
+
119
167
  # Refund
120
168
  def get_purchases_refunds(**kwargs)
121
169
  get '/purchases/refunds', query: kwargs
@@ -125,6 +173,10 @@ class BukkuTest < Client
125
173
  get "/purchases/refunds/#{id}"
126
174
  end
127
175
 
176
+ def create_purchases_refund(body:)
177
+ post '/purchases/refunds', body: body
178
+ end
179
+
128
180
  ## BANK
129
181
  # Money In
130
182
  def get_banking_incomes(**kwargs)
@@ -135,6 +187,10 @@ class BukkuTest < Client
135
187
  get "/banking/incomes/#{id}"
136
188
  end
137
189
 
190
+ def create_banking_income(body:)
191
+ post '/banking/incomes', body: body
192
+ end
193
+
138
194
  # Money Out
139
195
  def get_banking_expenses(**kwargs)
140
196
  get '/banking/expenses', query: kwargs
@@ -144,6 +200,10 @@ class BukkuTest < Client
144
200
  get "/banking/expenses/#{id}"
145
201
  end
146
202
 
203
+ def create_expense(body:)
204
+ post '/banking/expenses', body: body
205
+ end
206
+
147
207
  # Transfers
148
208
  def get_transfers(**kwargs)
149
209
  get '/banking/transfers', query: kwargs
@@ -153,6 +213,10 @@ class BukkuTest < Client
153
213
  get "/banking/transfers/#{id}"
154
214
  end
155
215
 
216
+ def create_transfer(body:)
217
+ post '/banking/transfer', body: body
218
+ end
219
+
156
220
  ## CONTACT
157
221
  # Contacts
158
222
  def get_contacts(**kwargs)
@@ -163,6 +227,10 @@ class BukkuTest < Client
163
227
  get "/contacts/#{id}"
164
228
  end
165
229
 
230
+ def create_contact(body:)
231
+ post '/contacts', body: body
232
+ end
233
+
166
234
  # Groups
167
235
  def get_contact_groups(**kwargs)
168
236
  get '/contacts/groups', query: kwargs
@@ -172,6 +240,10 @@ class BukkuTest < Client
172
240
  get "/contacts/groups/#{id}"
173
241
  end
174
242
 
243
+ def create_group(body:)
244
+ post '/contacts/groups', body: body
245
+ end
246
+
175
247
  ## PRODUCT
176
248
  # Product
177
249
  def get_products(**kwargs)
@@ -182,6 +254,19 @@ class BukkuTest < Client
182
254
  get "/products/#{id}"
183
255
  end
184
256
 
257
+ def create_product(body:)
258
+ post '/products', body: body
259
+ end
260
+
261
+ # Bundles
262
+ def get_bundle(id)
263
+ get "/products/bundles/#{id}"
264
+ end
265
+
266
+ def create_bundle(body:)
267
+ post '/products/bundles', body: body
268
+ end
269
+
185
270
  # Groups
186
271
  def get_product_groups(**kwargs)
187
272
  get '/products/groups', query: kwargs
@@ -191,6 +276,10 @@ class BukkuTest < Client
191
276
  get "/products/groups/#{id}"
192
277
  end
193
278
 
279
+ def create_product_group(body:)
280
+ post '/products/groups', body: body
281
+ end
282
+
194
283
  ## ACCOUNTING
195
284
  # Journal Entries
196
285
  def get_journal_entries(**kwargs)
@@ -201,6 +290,10 @@ class BukkuTest < Client
201
290
  get "/journal_entries/#{id}"
202
291
  end
203
292
 
293
+ def create_journal_entry(body:)
294
+ post '/journal_entries', body: body
295
+ end
296
+
204
297
  # Account
205
298
  def get_accounts(**kwargs)
206
299
  get '/accounts', query: kwargs
@@ -209,4 +302,13 @@ class BukkuTest < Client
209
302
  def get_account(id)
210
303
  get "/accounts/#{id}"
211
304
  end
305
+
306
+ def create_account(body:)
307
+ post '/accounts', body: body
308
+ end
309
+
310
+ # Files
311
+ def upload_file(file_data:, filename:, mime_type:)
312
+ upload '/files', file_data: file_data, filename: filename, mime_type: mime_type
313
+ end
212
314
  end
data/lib/client.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  class Client
2
2
  # The BASE_URI below is there to facilitate test only
3
- BASE_URI = "https://rekon.org"
3
+ BASE_URI = 'https://rekon.org'
4
4
 
5
5
  attr_reader :token, :domain
6
6
 
@@ -16,6 +16,15 @@ class Client
16
16
  end
17
17
 
18
18
  def default_headers
19
+ {
20
+ 'Authorization' => "Bearer #{@token}",
21
+ 'Company-Subdomain' => "#{@domain}",
22
+ 'Accept' => 'application/json',
23
+ 'Content-Type' => 'application/json'
24
+ }
25
+ end
26
+
27
+ def upload_headers
19
28
  {
20
29
  'Authorization' => "Bearer #{@token}",
21
30
  'Company-Subdomain' => "#{@domain}",
@@ -31,30 +40,55 @@ class Client
31
40
  make_request Net::HTTP::Post, path, query: query, body: body
32
41
  end
33
42
 
34
- def make_request(klass, path, query: {}, body: {})
35
- uri = URI("#{base_uri}#{path}")
36
- uri.query = URI.encode_www_form(query) if query
43
+ def upload(path, file_data:, filename:, mime_type:)
44
+ upload_request Net::HTTP::Post, path, file_data: file_data, filename: filename, mime_type: mime_type
45
+ end
37
46
 
47
+ def build_http(uri)
38
48
  http = Net::HTTP.new(uri.host, uri.port)
39
49
  http.use_ssl = uri.instance_of?(URI::HTTPS)
50
+
51
+ # Add the 2 lines below because development keeps on failing SSL CRL checks
52
+ # Check this article for explanation:
53
+ # https://dev.to/madhuhari188/how-we-solved-unable-to-get-certificate-crl-in-rails-a-debugging-story-2pna
54
+ http.verify_mode = OpenSSL::SSL::VERIFY_PEER
55
+ http.verify_callback = ->(_preverify_ok, _store_ctx) { true }
56
+
57
+ http
58
+ end
59
+
60
+ def make_request(klass, path, query: {}, body: {})
40
61
  # Uncomment below for debuging purpose to see the payload that was sent.
41
- # http.set_debug_output($stdout)
62
+ # build_http(uri).set_debug_output($stdout)
63
+
64
+ uri = URI("#{base_uri}#{path}")
65
+ uri.query = URI.encode_www_form(query) if query
42
66
 
43
67
  request = klass.new(uri.request_uri, default_headers)
44
- if body && !body.empty?
45
- request.body = body.to_json
46
- end
68
+ request.body = body.to_json if body && !body.empty?
47
69
 
70
+ execute_request(build_http(uri), request)
71
+ end
72
+
73
+ def upload_request(klass, path, file_data:, filename:, mime_type:)
74
+ uri = URI("#{base_uri}#{path}")
75
+ request = klass.new(uri.request_uri, upload_headers)
76
+ request.set_form(
77
+ [['file', StringIO.new(file_data), { filename: filename, content_type: mime_type }]], 'multipart/form-data'
78
+ )
79
+
80
+ execute_request(build_http(uri), request)
81
+ end
82
+
83
+ def execute_request(http, request)
48
84
  response = http.request(request)
49
85
 
50
86
  case response.code.to_i
51
87
  when 200, 201, 202, 203, 204
52
- # JSON.parse(response.body) if response.body.present?
53
88
  JSON.parse(response.body) if response.body && !response.body.empty?
54
89
  else
55
90
  raise Error, "#{response.code}: #{response.body}"
56
91
  end
57
92
  end
58
-
59
93
  class Error < StandardError; end
60
94
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bukku_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Muzaffar Ariff
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-11 00:00:00.000000000 Z
11
+ date: 2026-02-26 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Use Rails conventions to call Bukku API requests.
14
14
  email:
@@ -50,5 +50,6 @@ requirements: []
50
50
  rubygems_version: 3.2.32
51
51
  signing_key:
52
52
  specification_version: 4
53
- summary: Bukku Cloud accounting API implementation in Rails
53
+ summary: Bukku Cloud accounting API implementation in Ruby and usage mostly for Rails
54
+ apps
54
55
  test_files: []