oyi 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.tool-versions +1 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +66 -0
- data/LICENSE.txt +21 -0
- data/README.md +152 -0
- data/Rakefile +11 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/oyi.rb +15 -0
- data/lib/oyi/acceptance.rb +33 -0
- data/lib/oyi/account.rb +13 -0
- data/lib/oyi/client.rb +71 -0
- data/lib/oyi/disbursement.rb +53 -0
- data/lib/oyi/errors.rb +20 -0
- data/lib/oyi/status_codes.rb +15 -0
- data/lib/oyi/version.rb +5 -0
- data/lib/oyi/virtual_account.rb +33 -0
- data/oyi.gemspec +29 -0
- metadata +81 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f83762c6223642f99bcb237c6a8996708002102aa6d36f33d256e49f01777777
|
4
|
+
data.tar.gz: d1f34080970ae1d8fe601357c01dccd7c4d9c8e17da61261666c05f1bc6a71e2
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e6db05cc7ab9b469f22128ec28dc6e9d4355a33044aa758c5eb4eddfe3f504e979b69c814a12c4626f37b51a9c00707797c1169589a21d67f3a28d683afc8a09
|
7
|
+
data.tar.gz: fd3c4a5da13586a6f170d86ec9c93a2ef1ce1e54c797e19d0586bc7703c2cb6d758306857ab21ab217ddf2dd485b9be8e6181e4b25c6dfb7b7766d94ec40ad53
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 2.6.6
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at me@itsgg.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
oyi (0.1.0)
|
5
|
+
rest-client
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
addressable (2.7.0)
|
11
|
+
public_suffix (>= 2.0.2, < 5.0)
|
12
|
+
crack (0.4.4)
|
13
|
+
diff-lcs (1.3)
|
14
|
+
domain_name (0.5.20190701)
|
15
|
+
unf (>= 0.0.5, < 1.0.0)
|
16
|
+
hashdiff (1.0.1)
|
17
|
+
http-accept (1.7.0)
|
18
|
+
http-cookie (1.0.3)
|
19
|
+
domain_name (~> 0.5)
|
20
|
+
mime-types (3.3.1)
|
21
|
+
mime-types-data (~> 3.2015)
|
22
|
+
mime-types-data (3.2020.0512)
|
23
|
+
netrc (0.11.0)
|
24
|
+
public_suffix (4.0.6)
|
25
|
+
rake (12.3.3)
|
26
|
+
rest-client (2.1.0)
|
27
|
+
http-accept (>= 1.7.0, < 2.0)
|
28
|
+
http-cookie (>= 1.0.2, < 2.0)
|
29
|
+
mime-types (>= 1.16, < 4.0)
|
30
|
+
netrc (~> 0.8)
|
31
|
+
rspec (3.9.0)
|
32
|
+
rspec-core (~> 3.9.0)
|
33
|
+
rspec-expectations (~> 3.9.0)
|
34
|
+
rspec-mocks (~> 3.9.0)
|
35
|
+
rspec-core (3.9.1)
|
36
|
+
rspec-support (~> 3.9.1)
|
37
|
+
rspec-expectations (3.9.0)
|
38
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
39
|
+
rspec-support (~> 3.9.0)
|
40
|
+
rspec-mocks (3.9.1)
|
41
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
42
|
+
rspec-support (~> 3.9.0)
|
43
|
+
rspec-support (3.9.3)
|
44
|
+
unf (0.1.4)
|
45
|
+
unf_ext
|
46
|
+
unf_ext (0.0.7.7)
|
47
|
+
vcr (5.1.0)
|
48
|
+
webmock (3.9.1)
|
49
|
+
addressable (>= 2.3.6)
|
50
|
+
crack (>= 0.3.2)
|
51
|
+
hashdiff (>= 0.4.0, < 2.0.0)
|
52
|
+
yard (0.9.25)
|
53
|
+
|
54
|
+
PLATFORMS
|
55
|
+
ruby
|
56
|
+
|
57
|
+
DEPENDENCIES
|
58
|
+
oyi!
|
59
|
+
rake
|
60
|
+
rspec
|
61
|
+
vcr
|
62
|
+
webmock
|
63
|
+
yard
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Ganesh Gunasegaran
|
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,152 @@
|
|
1
|
+
# Oyi
|
2
|
+
|
3
|
+
Ruby library for https://oyindonesia.com/ APIs
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'oyi'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
bundle install
|
17
|
+
````
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
```bash
|
22
|
+
gem install oyi
|
23
|
+
```
|
24
|
+
|
25
|
+
## Development
|
26
|
+
|
27
|
+
### Running the tests
|
28
|
+
|
29
|
+
```bash
|
30
|
+
rake spec
|
31
|
+
```
|
32
|
+
### Generate Documentation
|
33
|
+
```bash
|
34
|
+
rake yard
|
35
|
+
```
|
36
|
+
## Usage
|
37
|
+
|
38
|
+
### Configure the client
|
39
|
+
|
40
|
+
For the request params and responses please refer https://api-docs.oyindonesia.com/
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
Oyi::Client.configure(api_url: 'url', api_username: 'username', api_key: 'api_key')
|
44
|
+
```
|
45
|
+
|
46
|
+
### Account Methods
|
47
|
+
|
48
|
+
Get beneficiery account details
|
49
|
+
```ruby
|
50
|
+
Oyi::Account.inquiry(params)
|
51
|
+
```
|
52
|
+
|
53
|
+
### Disbursement Methods
|
54
|
+
|
55
|
+
Get beneficiary account details
|
56
|
+
```ruby
|
57
|
+
Oyi::Disbursement.inquiry(params)
|
58
|
+
```
|
59
|
+
|
60
|
+
Start disbursing money to a specific amount
|
61
|
+
```ruby
|
62
|
+
Oyi::Disbursement.remit(params)
|
63
|
+
```
|
64
|
+
|
65
|
+
Get status of a disbursement request
|
66
|
+
```ruby
|
67
|
+
Oyi::Disbursement.remit_status(params)
|
68
|
+
```
|
69
|
+
|
70
|
+
Get partner balance
|
71
|
+
```ruby
|
72
|
+
Oyi::Disbursement.balance
|
73
|
+
```
|
74
|
+
|
75
|
+
Create a scheduled disbursement
|
76
|
+
```ruby
|
77
|
+
Oyi::Disbursement.schedule_remit(params)
|
78
|
+
```
|
79
|
+
|
80
|
+
Get the details of a scheduled remit
|
81
|
+
```ruby
|
82
|
+
Oyi::Disbursement.schedule_remit_details(params)
|
83
|
+
```
|
84
|
+
|
85
|
+
Get a list of all scheduled remits
|
86
|
+
```ruby
|
87
|
+
Oyi::Disbursement.list_scheduled_remit(params)
|
88
|
+
```
|
89
|
+
|
90
|
+
Delete a scheduled remit
|
91
|
+
```ruby
|
92
|
+
Oyi::Disbursement.cancel_scheduled_remit(params)
|
93
|
+
```
|
94
|
+
|
95
|
+
Retry a scheduled remit
|
96
|
+
```ruby
|
97
|
+
Oyi::Disbursement.retry_scheduled_remit(params)
|
98
|
+
```
|
99
|
+
|
100
|
+
### Virtual Account Methods
|
101
|
+
|
102
|
+
Create a new VA number
|
103
|
+
```ruby
|
104
|
+
Oyi::VirtualAccount.create(params)
|
105
|
+
```
|
106
|
+
|
107
|
+
Get VA details
|
108
|
+
```ruby
|
109
|
+
Oyi::VirtualAccount.get(id)
|
110
|
+
```
|
111
|
+
|
112
|
+
Update existing VA
|
113
|
+
```ruby
|
114
|
+
Oyi::VirtualAccount.update(id, params)
|
115
|
+
```
|
116
|
+
|
117
|
+
Get all VAs
|
118
|
+
```ruby
|
119
|
+
Oyi::VirtualAccount.all(params)
|
120
|
+
```
|
121
|
+
|
122
|
+
Get all transactions for a VA
|
123
|
+
```ruby
|
124
|
+
Oyi::VirtualAccount.transaction(id, params)
|
125
|
+
```
|
126
|
+
|
127
|
+
### Acceptance Methods
|
128
|
+
|
129
|
+
Create a payment checkout URL
|
130
|
+
```ruby
|
131
|
+
Oyi::Acceptance.payment_checkout(params)
|
132
|
+
```
|
133
|
+
|
134
|
+
Create a payment checkout URL with addtional details for invoicing
|
135
|
+
```ruby
|
136
|
+
Oyi::Acceptance.create_invoice(params)
|
137
|
+
```
|
138
|
+
|
139
|
+
Get the status of a transaction
|
140
|
+
```ruby
|
141
|
+
Oyi::Acceptance.status(params)
|
142
|
+
```
|
143
|
+
|
144
|
+
Delete a payment/invoice link
|
145
|
+
```ruby
|
146
|
+
Oyi::Acceptance.delete(params)
|
147
|
+
```
|
148
|
+
|
149
|
+
Get the details of a payment/invoice link
|
150
|
+
```ruby
|
151
|
+
Oyi::Acceptance.get(params)
|
152
|
+
```
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "oyi"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/oyi.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rest-client'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
require 'oyi/status_codes'
|
7
|
+
require 'oyi/errors'
|
8
|
+
require 'oyi/version'
|
9
|
+
require 'oyi/client'
|
10
|
+
require 'oyi/account'
|
11
|
+
require 'oyi/disbursement'
|
12
|
+
require 'oyi/acceptance'
|
13
|
+
require 'oyi/virtual_account'
|
14
|
+
|
15
|
+
module Oyi; end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
# Accept fund from yoru customers
|
5
|
+
class Acceptance
|
6
|
+
class << self
|
7
|
+
# Create a payment checkout URL
|
8
|
+
def payment_checkout(params)
|
9
|
+
Client.request http_method: :post, endpoint: '/api/payment-checkout/create-v2', params: params
|
10
|
+
end
|
11
|
+
|
12
|
+
# Create a payment checkout URL with addtional details for invoicing
|
13
|
+
def create_invoice(params)
|
14
|
+
Client.request http_method: :post, endpoint: '/api/payment-checkout/create-invoice', params: params
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get the status of a transaction
|
18
|
+
def status(params)
|
19
|
+
Client.request http_method: :get, endpoint: "/api/payment-checkout/status?#{URI.encode_www_form(params)}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Delete a payment/invoice link
|
23
|
+
def delete(params)
|
24
|
+
Client.request http_method: :delete, endpoint: "/api/payment-checkout/#{params[:payment_link_id_or_partner_tx_id]}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get the details of a payment/invoice link
|
28
|
+
def get(params)
|
29
|
+
Client.request http_method: :get, endpoint: "/api/payment-checkout/#{params[:payment_link_id_or_partner_tx_id]}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/oyi/account.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
# Handles beneficiary account details
|
5
|
+
class Account
|
6
|
+
class << self
|
7
|
+
# Get beneficiery account details
|
8
|
+
def inquiry(params)
|
9
|
+
Client.request http_method: :post, endpoint: '/api/account-inquiry', params: params
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/oyi/client.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
# The REST client that talks to OY API
|
5
|
+
class Client
|
6
|
+
class << self
|
7
|
+
def configure(api_url:, api_username:, api_key:)
|
8
|
+
@api_url = api_url
|
9
|
+
@api_username = api_username
|
10
|
+
@api_key = api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
def configured?
|
14
|
+
@api_url && @api_username && @api_key
|
15
|
+
end
|
16
|
+
|
17
|
+
def request(http_method:, endpoint:, params: nil)
|
18
|
+
raise Error.new(message: 'Oyi client not configured') unless configured?
|
19
|
+
|
20
|
+
begin
|
21
|
+
response = RestClient::Request.execute method: http_method, url: "#{@api_url}/#{endpoint}",
|
22
|
+
payload: params&.to_json, headers: {
|
23
|
+
'Content-Type': 'application/json',
|
24
|
+
'Accept': 'application/json',
|
25
|
+
'X-OY-Username': @api_username,
|
26
|
+
'X-Api-Key': @api_key
|
27
|
+
}
|
28
|
+
@code = response.code
|
29
|
+
@message = begin
|
30
|
+
JSON.parse(response.body)
|
31
|
+
rescue JSON::ParserError
|
32
|
+
response.body
|
33
|
+
end
|
34
|
+
rescue RestClient::RequestFailed => e
|
35
|
+
@code = e.http_code
|
36
|
+
@message = e.message
|
37
|
+
end
|
38
|
+
status = @message['status']
|
39
|
+
if @code == HTTP_OK_CODE
|
40
|
+
raise ApiError.new(message: @message['message']) if status == false
|
41
|
+
|
42
|
+
custom_error_code = status.is_a?(Hash) && status['code']
|
43
|
+
if custom_error_code && !VALID_CODES.include?(custom_error_code)
|
44
|
+
raise ApiError.new(code: custom_error_code, message: @message)
|
45
|
+
end
|
46
|
+
|
47
|
+
return @message
|
48
|
+
end
|
49
|
+
|
50
|
+
raise error_class(@code).new(code: @code, message: @message)
|
51
|
+
end
|
52
|
+
|
53
|
+
def error_class(code)
|
54
|
+
case code
|
55
|
+
when HTTP_BAD_REQUEST_CODE
|
56
|
+
BadRequestError
|
57
|
+
when HTTP_UNAUTHORIZED_CODE
|
58
|
+
UnauthorizedError
|
59
|
+
when HTTP_FORBIDDEN_CODE
|
60
|
+
ForbiddenError
|
61
|
+
when HTTP_NOT_FOUND_CODE
|
62
|
+
NotFoundError
|
63
|
+
when HTTP_UNPROCESSABLE_ENTITY_CODE
|
64
|
+
UnprocessableEntityError
|
65
|
+
else
|
66
|
+
ApiError
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
# Allows you to disburse fund to any bank accounts in Indonesia
|
5
|
+
class Disbursement
|
6
|
+
class << self
|
7
|
+
# Get beneficiary account details
|
8
|
+
def account_inquiry(params)
|
9
|
+
Client.request http_method: :post, endpoint: '/api/inquiry', params: params
|
10
|
+
end
|
11
|
+
|
12
|
+
# Start disbursing money to a specific amount
|
13
|
+
def remit(params)
|
14
|
+
Client.request http_method: :post, endpoint: '/api/remit', params: params
|
15
|
+
end
|
16
|
+
|
17
|
+
# Get status of a disbursement request
|
18
|
+
def remit_status(params)
|
19
|
+
Client.request http_method: :post, endpoint: '/api/remit-status', params: params
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get partner balance
|
23
|
+
def balance
|
24
|
+
Client.request http_method: :get, endpoint: '/api/balance'
|
25
|
+
end
|
26
|
+
|
27
|
+
# Create a scheduled disbursement
|
28
|
+
def schedule_remit(params)
|
29
|
+
Client.request http_method: :post, endpoint: '/api/scheduled-remit', params: params
|
30
|
+
end
|
31
|
+
|
32
|
+
# Get the details of a scheduled remit
|
33
|
+
def scheduled_remit_details(params)
|
34
|
+
Client.request http_method: :get, endpoint: '/api/scheduled-remit', params: params
|
35
|
+
end
|
36
|
+
|
37
|
+
# Get a list of all scheduled remits
|
38
|
+
def list_scheduled_remit
|
39
|
+
Client.request http_method: :post, endpoint: '/api/scheduled-remit/list'
|
40
|
+
end
|
41
|
+
|
42
|
+
# Delete a scheduled remit
|
43
|
+
def cancel_scheduled_remit(params)
|
44
|
+
Client.request http_method: :delete, endpoint: '/api/scheduled-remit', params: params
|
45
|
+
end
|
46
|
+
|
47
|
+
# Retry a scheduled remit
|
48
|
+
def retry_scheduled_remit(params)
|
49
|
+
Client.request http_method: :post, endpoint: '/api/scheduled-remit/retry', params: params
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/oyi/errors.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
# Custom Error Classes
|
5
|
+
class Error < StandardError
|
6
|
+
attr_accessor :code, :message
|
7
|
+
|
8
|
+
def initialize(code: nil, message:)
|
9
|
+
@code = code
|
10
|
+
@message = message
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
BadRequestError = Class.new(Error)
|
15
|
+
UnauthorizedError = Class.new(Error)
|
16
|
+
ForbiddenError = Class.new(Error)
|
17
|
+
NotFoundError = Class.new(Error)
|
18
|
+
UnprocessableEntityError = Class.new(Error)
|
19
|
+
ApiError = Class.new(Error)
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
HTTP_OK_CODE = 200
|
5
|
+
HTTP_BAD_REQUEST_CODE = 400
|
6
|
+
HTTP_UNAUTHORIZED_CODE = 401
|
7
|
+
HTTP_FORBIDDEN_CODE = 403
|
8
|
+
HTTP_NOT_FOUND_CODE = 404
|
9
|
+
HTTP_UNPROCESSABLE_ENTITY_CODE = 429
|
10
|
+
VALID_CODES = [
|
11
|
+
'000', # Success
|
12
|
+
'101', # Request processed
|
13
|
+
'103' # Scheduled
|
14
|
+
].freeze
|
15
|
+
end
|
data/lib/oyi/version.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Oyi
|
4
|
+
# Use unique Virutal Account number as a payment method for your customers
|
5
|
+
class VirtualAccount
|
6
|
+
class << self
|
7
|
+
# Create a new VA number
|
8
|
+
def create(params)
|
9
|
+
Client.request http_method: :post, endpoint: '/api/generate-static-va', params: params
|
10
|
+
end
|
11
|
+
|
12
|
+
# Get VA details
|
13
|
+
def get(id)
|
14
|
+
Client.request http_method: :get, endpoint: "/api/static-virtual-account/#{id}"
|
15
|
+
end
|
16
|
+
|
17
|
+
# Update existing VA
|
18
|
+
def update(id, params)
|
19
|
+
Client.request http_method: :put, endpoint: "/api/static-virtual-account/#{id}", params: params
|
20
|
+
end
|
21
|
+
|
22
|
+
# Get all VAs
|
23
|
+
def all(params = {})
|
24
|
+
Client.request http_method: :get, endpoint: "/api/static-virtual-account?#{URI.encode_www_form(params)}"
|
25
|
+
end
|
26
|
+
|
27
|
+
# Get all transactions for a VA
|
28
|
+
def transactions(id, params = {})
|
29
|
+
Client.request http_method: :get, endpoint: "/api/va-tx-history/#{id}?#{URI.encode_www_form(params)}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/oyi.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/oyi/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = 'oyi'
|
7
|
+
spec.version = Oyi::VERSION
|
8
|
+
spec.authors = ['Ganesh Gunasegaran']
|
9
|
+
spec.email = ['me@itsgg.com']
|
10
|
+
|
11
|
+
spec.summary = 'Ruby library for https://oyindonesia.com/ APIs'
|
12
|
+
spec.homepage = 'https://www.bukukas.co.id/'
|
13
|
+
spec.license = 'MIT'
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
15
|
+
|
16
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
17
|
+
spec.metadata['source_code_uri'] = 'https://github.com/itsgg/oyi'
|
18
|
+
|
19
|
+
spec.add_dependency 'rest-client'
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = 'exe'
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ['lib']
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: oyi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Ganesh Gunasegaran
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rest-client
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description:
|
28
|
+
email:
|
29
|
+
- me@itsgg.com
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- ".gitignore"
|
35
|
+
- ".rspec"
|
36
|
+
- ".tool-versions"
|
37
|
+
- ".travis.yml"
|
38
|
+
- CODE_OF_CONDUCT.md
|
39
|
+
- Gemfile
|
40
|
+
- Gemfile.lock
|
41
|
+
- LICENSE.txt
|
42
|
+
- README.md
|
43
|
+
- Rakefile
|
44
|
+
- bin/console
|
45
|
+
- bin/setup
|
46
|
+
- lib/oyi.rb
|
47
|
+
- lib/oyi/acceptance.rb
|
48
|
+
- lib/oyi/account.rb
|
49
|
+
- lib/oyi/client.rb
|
50
|
+
- lib/oyi/disbursement.rb
|
51
|
+
- lib/oyi/errors.rb
|
52
|
+
- lib/oyi/status_codes.rb
|
53
|
+
- lib/oyi/version.rb
|
54
|
+
- lib/oyi/virtual_account.rb
|
55
|
+
- oyi.gemspec
|
56
|
+
homepage: https://www.bukukas.co.id/
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata:
|
60
|
+
homepage_uri: https://www.bukukas.co.id/
|
61
|
+
source_code_uri: https://github.com/itsgg/oyi
|
62
|
+
post_install_message:
|
63
|
+
rdoc_options: []
|
64
|
+
require_paths:
|
65
|
+
- lib
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 2.3.0
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
requirements: []
|
77
|
+
rubygems_version: 3.0.3
|
78
|
+
signing_key:
|
79
|
+
specification_version: 4
|
80
|
+
summary: Ruby library for https://oyindonesia.com/ APIs
|
81
|
+
test_files: []
|