bukku_rails 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +147 -0
- data/Rakefile +8 -0
- data/lib/bukku.rb +212 -0
- data/lib/bukku_rails/version.rb +5 -0
- data/lib/bukku_rails.rb +9 -0
- data/lib/bukku_test.rb +212 -0
- data/lib/client.rb +60 -0
- data/sig/bukku_rails.rbs +4 -0
- metadata +54 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 9ed6bf94470a82481cf4506e9fa920743bbbb0b54623e964a07e41de1a78a107
|
|
4
|
+
data.tar.gz: f8db6a422b83fb3ee350ad36f9f4ab469e9f6aaa577523175ab4f040200da021
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 9043be0a8e7b4c69ee501a6da75ab2ed04b560a12032ff282ab13baf8ed174417c5ab71aa6d5093e46b46107619f7b39c5423383fc5f98f8f2c037d940af1edf
|
|
7
|
+
data.tar.gz: d05253cf61d9c6b4c8d5a8dc57bb65e652d14e8cbcdc29924672f893b5a8c1eb888363ace0d4ae534928713175bfd11762523cba13d3303e50dd1190e9eac58e
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Muzaffar
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
# BukkuRails
|
|
2
|
+
|
|
3
|
+
Use Rails methods to interact with your data in [Bukku](https://bukku.my/) accounting software.
|
|
4
|
+
|
|
5
|
+
Take a look at [Bukku's API](https://developers.bukku.my) to know what data you can extract from Bukku.
|
|
6
|
+
|
|
7
|
+
> As of December 2, 2025, the gem only handles **GET** request. If you require other request, fork the gem and write it and then send us a Pull Request.
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add the gen into your Gemfile like so:
|
|
12
|
+
|
|
13
|
+
`gem "bukku_rails`
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
You will need 2 things - your **subdomain** and **API Token**.
|
|
18
|
+
|
|
19
|
+
You can get these after you login into your Bukku account, Control Panel -> Integrations -> Turn ON API Access.
|
|
20
|
+
|
|
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 great to test your Rails app if it is extracting the correct data from Bukku. Once you are satisfied you can then use access the Production server where your actual data lives.
|
|
22
|
+
|
|
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:
|
|
24
|
+
|
|
25
|
+
### Setup
|
|
26
|
+
For Staging
|
|
27
|
+
```ruby
|
|
28
|
+
# Initialize the client
|
|
29
|
+
client = BukkuTest.new(
|
|
30
|
+
token: "your_bukku_api_token",
|
|
31
|
+
domain: "your_company_subdomain"
|
|
32
|
+
)
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
For Production
|
|
36
|
+
```ruby
|
|
37
|
+
# Initialize the client
|
|
38
|
+
client = Bukku.new(
|
|
39
|
+
token: "your_bukku_api_token",
|
|
40
|
+
domain: "your_company_subdomain"
|
|
41
|
+
)
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Available Methods
|
|
45
|
+
|
|
46
|
+
Just like in Rails the methods follow the singular and plural expression. Methods with arguments are normally plural, while methods without arguments are singular methods calls.
|
|
47
|
+
|
|
48
|
+
#### Sales
|
|
49
|
+
|
|
50
|
+
| HTTP Method | Ruby Method | Endpoint |
|
|
51
|
+
|------------|-------------|----------|
|
|
52
|
+
| GET | `get_sales_quotes(**kwargs)` | `/sales/quotes` |
|
|
53
|
+
| GET | `get_sales_quote(id)` | `/sales/quotes/:id` |
|
|
54
|
+
| GET | `get_sales_orders(**kwargs)` | `/sales/orders` |
|
|
55
|
+
| GET | `get_sales_order(id)` | `/sales/orders/:id` |
|
|
56
|
+
| GET | `get_delivery_orders(**kwargs)` | `/sales/delivery_orders` |
|
|
57
|
+
| GET | `get_delivery_order(id)` | `/sales/delivery_orders/:id` |
|
|
58
|
+
| GET | `get_invoices(**kwargs)` | `/sales/invoices` |
|
|
59
|
+
| GET | `get_invoice(id)` | `/sales/invoices/:id` |
|
|
60
|
+
| GET | `get_sales_credit_notes(**kwargs)` | `/sales/credit_notes` |
|
|
61
|
+
| GET | `get_sales_credit_note(id)` | `/sales/credit_notes/:id` |
|
|
62
|
+
| GET | `get_sales_payments(**kwargs)` | `/sales/payments` |
|
|
63
|
+
| GET | `get_sales_payment(id)` | `/sales/payments/:id` |
|
|
64
|
+
| GET | `get_sales_refunds(**kwargs)` | `/sales/refunds` |
|
|
65
|
+
| GET | `get_sales_refund(id)` | `/sales/refunds/:id` |
|
|
66
|
+
|
|
67
|
+
#### Purchases
|
|
68
|
+
|
|
69
|
+
| HTTP Method | Ruby Method | Endpoint |
|
|
70
|
+
|------------|-------------|----------|
|
|
71
|
+
| GET | `get_purchase_orders(**kwargs)` | `/purchases/orders` |
|
|
72
|
+
| GET | `get_purchase_order(id)` | `/purchases/orders/:id` |
|
|
73
|
+
| GET | `get_received_notes(**kwargs)` | `/purchases/goods_received_notes` |
|
|
74
|
+
| GET | `get_received_note(id)` | `/purchases/goods_received_notes/:id` |
|
|
75
|
+
| GET | `get_bills(**kwargs)` | `/purchases/bills` |
|
|
76
|
+
| GET | `get_bill(id)` | `/purchases/bills/:id` |
|
|
77
|
+
| GET | `get_purchases_credit_notes(**kwargs)` | `/purchases/credit_notes` |
|
|
78
|
+
| GET | `get_purchases_credit_note(id)` | `/purchases/credit_notes/:id` |
|
|
79
|
+
| GET | `get_purchases_payments(**kwargs)` | `/purchases/payments` |
|
|
80
|
+
| GET | `get_purchases_payments(id)` | `/purchases/payments/:id` |
|
|
81
|
+
| GET | `get_purchases_refunds(**kwargs)` | `/purchases/refunds` |
|
|
82
|
+
| GET | `get_purchases_refund(id)` | `/purchases/refunds/:id` |
|
|
83
|
+
|
|
84
|
+
#### Banking
|
|
85
|
+
|
|
86
|
+
| HTTP Method | Ruby Method | Endpoint |
|
|
87
|
+
|------------|-------------|----------|
|
|
88
|
+
| GET | `get_banking_incomes(**kwargs)` | `/banking/incomes` |
|
|
89
|
+
| GET | `get_banking_income(id)` | `/banking/incomes/:id` |
|
|
90
|
+
| GET | `get_banking_expenses(**kwargs)` | `/banking/expenses` |
|
|
91
|
+
| GET | `get_banking_expense(id)` | `/banking/expenses/:id` |
|
|
92
|
+
| GET | `get_transfers(**kwargs)` | `/banking/transfers` |
|
|
93
|
+
| GET | `get_transfer(id)` | `/banking/transfers/:id` |
|
|
94
|
+
|
|
95
|
+
#### Contacts
|
|
96
|
+
|
|
97
|
+
| HTTP Method | Ruby Method | Endpoint |
|
|
98
|
+
|------------|-------------|----------|
|
|
99
|
+
| GET | `get_contacts(**kwargs)` | `/contacts` |
|
|
100
|
+
| GET | `get_contact(id)` | `/contacts/:id` |
|
|
101
|
+
| GET | `get_contact_groups(**kwargs)` | `/contacts/groups` |
|
|
102
|
+
| GET | `get_contact_group(id)` | `/contacts/groups/:id` |
|
|
103
|
+
|
|
104
|
+
#### Products
|
|
105
|
+
|
|
106
|
+
| HTTP Method | Ruby Method | Endpoint |
|
|
107
|
+
|------------|-------------|----------|
|
|
108
|
+
| GET | `get_products(**kwargs)` | `/products` |
|
|
109
|
+
| GET | `get_product(id)` | `/products/:id` |
|
|
110
|
+
| GET | `get_product_groups(**kwargs)` | `/products/groups` |
|
|
111
|
+
| GET | `get_product_group(id)` | `/products/groups/:id` |
|
|
112
|
+
|
|
113
|
+
#### Accounting
|
|
114
|
+
|
|
115
|
+
| HTTP Method | Ruby Method | Endpoint |
|
|
116
|
+
|------------|-------------|----------|
|
|
117
|
+
| GET | `journal_entries(**kwargs)` | `/journal_entries` |
|
|
118
|
+
| GET | `journal_entry(id)` | `/journal_entries/:id` |
|
|
119
|
+
| GET | `accounts` | `/accounts` |
|
|
120
|
+
| GET | `account(id)` | `/accounts/:id` |
|
|
121
|
+
|
|
122
|
+
### Examples
|
|
123
|
+
|
|
124
|
+
**Fetch all invoices:**
|
|
125
|
+
```ruby
|
|
126
|
+
invoices = client.get_invoices
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Fetch invoices with date filters or parameters:**
|
|
130
|
+
To know more on what Query Parameters is acceptable head to [Bukku API page](https://developers.bukku.my)
|
|
131
|
+
```ruby
|
|
132
|
+
invoices = client.get_invoices(date_from: "2025-11-01", date_to: "2025-11-30")
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
**Fetch a specific invoice:**
|
|
136
|
+
```ruby
|
|
137
|
+
invoice = client.get_invoice(123)
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
## Contributing
|
|
142
|
+
|
|
143
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/stopar/bukku_rails>.
|
|
144
|
+
|
|
145
|
+
## License
|
|
146
|
+
|
|
147
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/lib/bukku.rb
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
class Bukku < Client
|
|
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")
|
|
6
|
+
|
|
7
|
+
BASE_URI = 'https://api.bukku.my'
|
|
8
|
+
|
|
9
|
+
## SALES
|
|
10
|
+
# Quotation
|
|
11
|
+
def get_sales_quotes(**kwargs)
|
|
12
|
+
get '/sales/quotes', query: kwargs
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_sales_quote(id)
|
|
16
|
+
get "/sales/quotes/#{id}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Sales Order
|
|
20
|
+
def get_sales_orders(**kwargs)
|
|
21
|
+
get '/sales/orders', query: kwargs
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_sales_order(id)
|
|
25
|
+
get "/sales/orders/#{id}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Delivery Order
|
|
29
|
+
def get_delivery_orders(**kwargs)
|
|
30
|
+
get '/sales/delivery_orders', query: kwargs
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_delivery_order(id)
|
|
34
|
+
get "/sales/delivery_orders/#{id}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Invoice
|
|
38
|
+
def get_invoices(**kwargs)
|
|
39
|
+
get '/sales/invoices', query: kwargs
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get_invoice(id)
|
|
43
|
+
get "/sales/invoices/#{id}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Credit Note
|
|
47
|
+
def get_sales_credit_notes(**kwargs)
|
|
48
|
+
get '/sales/credit_notes', query: kwargs
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def get_sales_credit_note(id)
|
|
52
|
+
get "/sales/credit_notes/#{id}"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Payment
|
|
56
|
+
def get_sales_payments(**kwargs)
|
|
57
|
+
get '/sales/payments', query: kwargs
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def get_sales_payment(id)
|
|
61
|
+
get "/sales/payments/#{id}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Redund
|
|
65
|
+
def get_sales_refunds(**kwargs)
|
|
66
|
+
get '/sales/refunds', query: kwargs
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def get_sales_refund(id)
|
|
70
|
+
get "/sales/refunds/#{id}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
## PURCHASE
|
|
74
|
+
# Purchase Order
|
|
75
|
+
def get_purchase_orders(**kwargs)
|
|
76
|
+
get '/purchases/orders', query: kwargs
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def get_purchase_order(id)
|
|
80
|
+
get "/purchases/orders/#{id}"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
## Goods Received Note
|
|
84
|
+
def get_received_notes(**kwargs)
|
|
85
|
+
get '/purchases/goods_received_notes', query: kwargs
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def get_received_note(id)
|
|
89
|
+
get "/purchases/goods_received_notes/#{id}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Bill
|
|
93
|
+
def get_bills(**kwargs)
|
|
94
|
+
get '/purchases/bills', query: kwargs
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def get_bill(id)
|
|
98
|
+
get "/purchases/bills/#{id}"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Credit Note
|
|
102
|
+
def get_purchases_credit_notes(**kwargs)
|
|
103
|
+
get '/purchases/credit_notes', query: kwargs
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def get_purchases_credit_note(id)
|
|
107
|
+
get "/purchases/credit_notes/#{id}"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Payment
|
|
111
|
+
def get_purchases_payments(**kwargs)
|
|
112
|
+
get '/purchases/payments', query: kwargs
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def get_purchases_payment(id)
|
|
116
|
+
get "/purchases/payments/#{id}"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Refund
|
|
120
|
+
def get_purchases_refunds(**kwargs)
|
|
121
|
+
get '/purchases/refunds', query: kwargs
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def get_purchases_refund(id)
|
|
125
|
+
get "/purchases/refunds/#{id}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
## BANK
|
|
129
|
+
# Money In
|
|
130
|
+
def get_banking_incomes(**kwargs)
|
|
131
|
+
get '/banking/incomes', query: kwargs
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def get_banking_income(id)
|
|
135
|
+
get "/banking/incomes/#{id}"
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Money Out
|
|
139
|
+
def get_banking_expenses(**kwargs)
|
|
140
|
+
get '/banking/expenses', query: kwargs
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def get_banking_expense(id)
|
|
144
|
+
get "/banking/expenses/#{id}"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Transfers
|
|
148
|
+
def get_transfers(**kwargs)
|
|
149
|
+
get '/banking/transfers', query: kwargs
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def get_transfer(id)
|
|
153
|
+
get "/banking/transfers/#{id}"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
## CONTACT
|
|
157
|
+
# Contacts
|
|
158
|
+
def get_contacts(**kwargs)
|
|
159
|
+
get '/contacts', query: kwargs
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def get_contact(id)
|
|
163
|
+
get "/contacts/#{id}"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Groups
|
|
167
|
+
def get_contact_groups(**kwargs)
|
|
168
|
+
get '/contacts/groups', query: kwargs
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def get_contact_group(id)
|
|
172
|
+
get "/contacts/groups/#{id}"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
## PRODUCT
|
|
176
|
+
# Product
|
|
177
|
+
def get_products(**kwargs)
|
|
178
|
+
get '/products', query: kwargs
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def get_product(id)
|
|
182
|
+
get "/products/#{id}"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Groups
|
|
186
|
+
def get_product_groups(**kwargs)
|
|
187
|
+
get '/products/groups', query: kwargs
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def get_product_group(id)
|
|
191
|
+
get "/products/groups/#{id}"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
## ACCOUNTING
|
|
195
|
+
# Journal Entries
|
|
196
|
+
def journal_entries(**kwargs)
|
|
197
|
+
get '/journal_entries', query: kwargs
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def journal_entry(id)
|
|
201
|
+
get "/journal_entries/#{id}"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Account
|
|
205
|
+
def accounts
|
|
206
|
+
get '/accounts'
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def account(id)
|
|
210
|
+
get "/accounts/#{id}"
|
|
211
|
+
end
|
|
212
|
+
end
|
data/lib/bukku_rails.rb
ADDED
data/lib/bukku_test.rb
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
class BukkuTest < Client
|
|
2
|
+
# Usage of this integration as follows:
|
|
3
|
+
# access = BukkuTest.new(token: "bukku_token_key", domain: "domain")
|
|
4
|
+
# respond = access.<method>
|
|
5
|
+
|
|
6
|
+
# Testing URL
|
|
7
|
+
BASE_URI = 'https://api.bukku.fyi'
|
|
8
|
+
|
|
9
|
+
## SALES
|
|
10
|
+
# Quotation
|
|
11
|
+
def get_sales_quotes(**kwargs)
|
|
12
|
+
get '/sales/quotes', query: kwargs
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_sales_quote(id)
|
|
16
|
+
get "/sales/quotes/#{id}"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Sales Order
|
|
20
|
+
def get_sales_orders(**kwargs)
|
|
21
|
+
get '/sales/orders', query: kwargs
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def get_sales_order(id)
|
|
25
|
+
get "/sales/orders/#{id}"
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# Delivery Order
|
|
29
|
+
def get_delivery_orders(**kwargs)
|
|
30
|
+
get '/sales/delivery_orders', query: kwargs
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def get_delivery_order(id)
|
|
34
|
+
get "/sales/delivery_orders/#{id}"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
# Invoice
|
|
38
|
+
def get_invoices(**kwargs)
|
|
39
|
+
get '/sales/invoices', query: kwargs
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def get_invoice(id)
|
|
43
|
+
get "/sales/invoices/#{id}"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# Credit Note
|
|
47
|
+
def get_sales_credit_notes(**kwargs)
|
|
48
|
+
get '/sales/credit_notes', query: kwargs
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def get_sales_credit_note(id)
|
|
52
|
+
get "/sales/credit_notes/#{id}"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Payment
|
|
56
|
+
def get_sales_payments(**kwargs)
|
|
57
|
+
get '/sales/payments', query: kwargs
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def get_sales_payment(id)
|
|
61
|
+
get "/sales/payments/#{id}"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
# Redund
|
|
65
|
+
def get_sales_refunds(**kwargs)
|
|
66
|
+
get '/sales/refunds', query: kwargs
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def get_sales_refund(id)
|
|
70
|
+
get "/sales/refunds/#{id}"
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
## PURCHASE
|
|
74
|
+
# Purchase Order
|
|
75
|
+
def get_purchase_orders(**kwargs)
|
|
76
|
+
get '/purchases/orders', query: kwargs
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def get_purchase_order(id)
|
|
80
|
+
get "/purchases/orders/#{id}"
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
## Goods Received Note
|
|
84
|
+
def get_received_notes(**kwargs)
|
|
85
|
+
get '/purchases/goods_received_notes', query: kwargs
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
def get_received_note(id)
|
|
89
|
+
get "/purchases/goods_received_notes/#{id}"
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Bill
|
|
93
|
+
def get_bills(**kwargs)
|
|
94
|
+
get '/purchases/bills', query: kwargs
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def get_bill(id)
|
|
98
|
+
get "/purchases/bills/#{id}"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Credit Note
|
|
102
|
+
def get_purchases_credit_notes(**kwargs)
|
|
103
|
+
get '/purchases/credit_notes', query: kwargs
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def get_purchases_credit_note(id)
|
|
107
|
+
get "/purchases/credit_notes/#{id}"
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
# Payment
|
|
111
|
+
def get_purchases_payments(**kwargs)
|
|
112
|
+
get '/purchases/payments', query: kwargs
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
def get_purchases_payment(id)
|
|
116
|
+
get "/purchases/payments/#{id}"
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
# Refund
|
|
120
|
+
def get_purchases_refunds(**kwargs)
|
|
121
|
+
get '/purchases/refunds', query: kwargs
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def get_purchases_refund(id)
|
|
125
|
+
get "/purchases/refunds/#{id}"
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
## BANK
|
|
129
|
+
# Money In
|
|
130
|
+
def get_banking_incomes(**kwargs)
|
|
131
|
+
get '/banking/incomes', query: kwargs
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def get_banking_income(id)
|
|
135
|
+
get "/banking/incomes/#{id}"
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
# Money Out
|
|
139
|
+
def get_banking_expenses(**kwargs)
|
|
140
|
+
get '/banking/expenses', query: kwargs
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
def get_banking_expense(id)
|
|
144
|
+
get "/banking/expenses/#{id}"
|
|
145
|
+
end
|
|
146
|
+
|
|
147
|
+
# Transfers
|
|
148
|
+
def get_transfers(**kwargs)
|
|
149
|
+
get '/banking/transfers', query: kwargs
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
def get_transfer(id)
|
|
153
|
+
get "/banking/transfers/#{id}"
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
## CONTACT
|
|
157
|
+
# Contacts
|
|
158
|
+
def get_contacts(**kwargs)
|
|
159
|
+
get '/contacts', query: kwargs
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def get_contact(id)
|
|
163
|
+
get "/contacts/#{id}"
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
# Groups
|
|
167
|
+
def get_contact_groups(**kwargs)
|
|
168
|
+
get '/contacts/groups', query: kwargs
|
|
169
|
+
end
|
|
170
|
+
|
|
171
|
+
def get_contact_group(id)
|
|
172
|
+
get "/contacts/groups/#{id}"
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
## PRODUCT
|
|
176
|
+
# Product
|
|
177
|
+
def get_products(**kwargs)
|
|
178
|
+
get '/products', query: kwargs
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def get_product(id)
|
|
182
|
+
get "/products/#{id}"
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
# Groups
|
|
186
|
+
def get_product_groups(**kwargs)
|
|
187
|
+
get '/products/groups', query: kwargs
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
def get_product_group(id)
|
|
191
|
+
get "/products/groups/#{id}"
|
|
192
|
+
end
|
|
193
|
+
|
|
194
|
+
## ACCOUNTING
|
|
195
|
+
# Journal Entries
|
|
196
|
+
def journal_entries(**kwargs)
|
|
197
|
+
get '/journal_entries', query: kwargs
|
|
198
|
+
end
|
|
199
|
+
|
|
200
|
+
def journal_entry(id)
|
|
201
|
+
get "/journal_entries/#{id}"
|
|
202
|
+
end
|
|
203
|
+
|
|
204
|
+
# Account
|
|
205
|
+
def accounts
|
|
206
|
+
get '/accounts'
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def account(id)
|
|
210
|
+
get "/accounts/#{id}"
|
|
211
|
+
end
|
|
212
|
+
end
|
data/lib/client.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
class Client
|
|
2
|
+
# The BASE_URI below is there to facilitate test only
|
|
3
|
+
BASE_URI = "https://rekon.org"
|
|
4
|
+
|
|
5
|
+
attr_reader :token, :domain
|
|
6
|
+
|
|
7
|
+
def initialize(token:, domain:)
|
|
8
|
+
@token = token
|
|
9
|
+
@domain = domain
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def base_uri
|
|
15
|
+
self.class::BASE_URI
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def default_headers
|
|
19
|
+
{
|
|
20
|
+
'Authorization' => "Bearer #{@token}",
|
|
21
|
+
'Company-Subdomain' => "#{@domain}",
|
|
22
|
+
'Accept' => 'application/json'
|
|
23
|
+
}
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def get(path, query: {})
|
|
27
|
+
make_request Net::HTTP::Get, path, query: query
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def post(path, query: {}, body: {})
|
|
31
|
+
make_request Net::HTTP::Post, path, query: query, body: body
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def make_request(klass, path, query: {}, body: {})
|
|
35
|
+
uri = URI("#{base_uri}#{path}")
|
|
36
|
+
uri.query = URI.encode_www_form(query) if query
|
|
37
|
+
|
|
38
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
|
39
|
+
http.use_ssl = uri.instance_of?(URI::HTTPS)
|
|
40
|
+
# Uncomment below for debuging purpose to see the payload that was sent.
|
|
41
|
+
# http.set_debug_output($stdout)
|
|
42
|
+
|
|
43
|
+
request = klass.new(uri.request_uri, default_headers)
|
|
44
|
+
if body && !body.empty?
|
|
45
|
+
request.body = body.to_json
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
response = http.request(request)
|
|
49
|
+
|
|
50
|
+
case response.code.to_i
|
|
51
|
+
when 200, 201, 202, 203, 204
|
|
52
|
+
# JSON.parse(response.body) if response.body.present?
|
|
53
|
+
JSON.parse(response.body) if response.body && !response.body.empty?
|
|
54
|
+
else
|
|
55
|
+
raise Error, "#{response.code}: #{response.body}"
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
class Error < StandardError; end
|
|
60
|
+
end
|
data/sig/bukku_rails.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: bukku_rails
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Muzaffar Ariff
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2025-12-03 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Use Rails conventions to call Bukku API requests.
|
|
14
|
+
email:
|
|
15
|
+
- muz@geligalabs.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- CHANGELOG.md
|
|
21
|
+
- LICENSE.txt
|
|
22
|
+
- README.md
|
|
23
|
+
- Rakefile
|
|
24
|
+
- lib/bukku.rb
|
|
25
|
+
- lib/bukku_rails.rb
|
|
26
|
+
- lib/bukku_rails/version.rb
|
|
27
|
+
- lib/bukku_test.rb
|
|
28
|
+
- lib/client.rb
|
|
29
|
+
- sig/bukku_rails.rbs
|
|
30
|
+
homepage:
|
|
31
|
+
licenses:
|
|
32
|
+
- MIT
|
|
33
|
+
metadata:
|
|
34
|
+
source_code_uri: https://github.com/stopar/bukku_rails
|
|
35
|
+
post_install_message:
|
|
36
|
+
rdoc_options: []
|
|
37
|
+
require_paths:
|
|
38
|
+
- lib
|
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
40
|
+
requirements:
|
|
41
|
+
- - ">="
|
|
42
|
+
- !ruby/object:Gem::Version
|
|
43
|
+
version: 3.0.0
|
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
45
|
+
requirements:
|
|
46
|
+
- - ">="
|
|
47
|
+
- !ruby/object:Gem::Version
|
|
48
|
+
version: '0'
|
|
49
|
+
requirements: []
|
|
50
|
+
rubygems_version: 3.2.32
|
|
51
|
+
signing_key:
|
|
52
|
+
specification_version: 4
|
|
53
|
+
summary: Bukku Cloud accounting API implementation in Rails
|
|
54
|
+
test_files: []
|