openpix-ruby_sdk 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +30 -49
- data/lib/openpix/ruby_sdk/api_body_formatter.rb +0 -14
- data/lib/openpix/ruby_sdk/resources/charge.rb +9 -9
- data/lib/openpix/ruby_sdk/resources/customer.rb +3 -3
- data/lib/openpix/ruby_sdk/resources/payment.rb +3 -13
- data/lib/openpix/ruby_sdk/resources/refund.rb +2 -12
- data/lib/openpix/ruby_sdk/resources/resource.rb +1 -1
- data/lib/openpix/ruby_sdk/resources/subscription.rb +3 -2
- data/lib/openpix/ruby_sdk/resources/webhook.rb +1 -1
- data/lib/openpix/ruby_sdk/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: efe2aa84bfbd12ee2ba2cc447ac1861f0698a9b6447e4306ac0e8ac40d937de2
|
4
|
+
data.tar.gz: abd20ecbf7f22d10c6515c109484e2f317ffd98c91525e5ada0f6a81f544f29b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 575e19123b1bd5ade726154dd4ab10109766a7c643df7c0cdb585bf995873625498a4598de25d2921eaab52aad6b18530e0c3a94f88365317c0630e987388dcc
|
7
|
+
data.tar.gz: 875d6302b1e7d140ba981a907afd598eaf3cb2a07cb32c4d7e2424f8b93f6dc9b88794526a05d7f49068b490d37a644c65d5717d0a9d020a9f2893c8ec35bc5a
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [2.0.0](https://github.com/Open-Pix/ruby-sdk/compare/v1.2.0...v2.0.0) (2023-07-24)
|
4
|
+
|
5
|
+
|
6
|
+
### ⚠ BREAKING CHANGES
|
7
|
+
|
8
|
+
* Refactor resources params to reflect better API payload structure ([#29](https://github.com/Open-Pix/ruby-sdk/issues/29))
|
9
|
+
|
10
|
+
### Bug Fixes
|
11
|
+
|
12
|
+
* Refactor resources params to reflect better API payload structure ([#29](https://github.com/Open-Pix/ruby-sdk/issues/29)) ([c03692a](https://github.com/Open-Pix/ruby-sdk/commit/c03692acc02e83d66f3884a1d49d03941bc8a221))
|
13
|
+
|
3
14
|
## [1.2.0](https://github.com/Open-Pix/ruby-sdk/compare/v1.1.1...v1.2.0) (2023-07-04)
|
4
15
|
|
5
16
|
|
data/README.md
CHANGED
@@ -1,24 +1,32 @@
|
|
1
1
|
# OpenPix/Woovi Ruby SDK
|
2
|
+
|
2
3
|
Welcome to the Woovi Ruby SDK! This SDK provides convenient access to the Woovi REST API, allowing you to easily integrate Woovi's REST API into your Ruby applications.
|
3
4
|
|
4
5
|
## Documentation
|
6
|
+
|
5
7
|
Documentation for Woovi REST API can be found [here](https://developers.woovi.com/api).
|
6
8
|
RDoc documentation for classes included in the gem can be found [here]().
|
7
9
|
|
8
10
|
## Installation
|
11
|
+
|
9
12
|
To install this gem using Bundler, add this following line to your `Gemfile`.
|
13
|
+
|
10
14
|
```shell
|
11
15
|
gem 'openpix-ruby_sdk', '~> 0.1.0'
|
12
16
|
```
|
13
17
|
|
14
18
|
To manually install `openpix-ruby_sdk` via Rubygems simply:
|
19
|
+
|
15
20
|
```shell
|
16
21
|
gem install openpix-ruby_sdk -v 1.0.0
|
17
22
|
```
|
18
23
|
|
19
24
|
## Usage
|
25
|
+
|
20
26
|
Main class `openpix/ruby_sdk/client` is your entrypoint to the endpoints.
|
27
|
+
|
21
28
|
### Authenticating client
|
29
|
+
|
22
30
|
```ruby
|
23
31
|
require 'openpix/ruby_sdk'
|
24
32
|
|
@@ -27,9 +35,12 @@ app_id = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
|
|
27
35
|
|
28
36
|
client = Openpix::RubySdk::Client.new(app_id)
|
29
37
|
```
|
38
|
+
|
30
39
|
### Using resources
|
31
|
-
|
40
|
+
|
41
|
+
`Openpix::RubySdk::Client` has access to all resources available through a accessor method with resource name in plural form
|
32
42
|
E.g: Charge -> client.charges (returns the charge resource class with all available methods)
|
43
|
+
|
33
44
|
```ruby
|
34
45
|
# Creating a Charge
|
35
46
|
client.charges.init_body(
|
@@ -70,27 +81,33 @@ response = client.charges.find(id: 'my-charge-id')
|
|
70
81
|
response = client.charges.destroy(id: 'my-charge-id')
|
71
82
|
response.success? # this operations just returns success
|
72
83
|
```
|
84
|
+
|
73
85
|
### Available resources
|
86
|
+
|
74
87
|
The available resources are:
|
88
|
+
|
75
89
|
- Charge (charges)
|
76
90
|
- Customer (customers)
|
77
91
|
- Payment (payments)
|
78
92
|
- Refund (refunds)
|
79
93
|
- Subscription (subscriptions)
|
80
94
|
- Webhook (webhooks)
|
95
|
+
|
81
96
|
### Handling errors
|
82
|
-
|
97
|
+
|
98
|
+
All available resource methods have their bang! version, which raises an error whenever something goes wrong so you can properly handle those cases
|
83
99
|
All errors have some helpful message, showing response status and error response from API
|
84
100
|
|
85
|
-
Error classes are:
|
86
|
-
**save!** -> `Openpix::RubySdk::Resources::RequestError`
|
87
|
-
**fetch!** -> `Openpix::RubySdk::Resources::RequestError`
|
88
|
-
**fetch_next_page!** -> `Openpix::RubySdk::Resources::RequestError`, `Openpix::RubySdk::Resources::NotFetchedError`, `Openpix::RubySdk::Resources::PageNotDefinedError`
|
89
|
-
**fetch_previous_page!** -> `Openpix::RubySdk::Resources::RequestError`, `Openpix::RubySdk::Resources::NotFetchedError`, `Openpix::RubySdk::Resources::PageNotDefinedError`
|
90
|
-
**find!** -> `Openpix::RubySdk::Resources::RequestError`
|
91
|
-
**destroy!** -> `Openpix::RubySdk::Resources::RequestError`
|
101
|
+
Error classes are:
|
102
|
+
**save!** -> `Openpix::RubySdk::Resources::RequestError`
|
103
|
+
**fetch!** -> `Openpix::RubySdk::Resources::RequestError`
|
104
|
+
**fetch_next_page!** -> `Openpix::RubySdk::Resources::RequestError`, `Openpix::RubySdk::Resources::NotFetchedError`, `Openpix::RubySdk::Resources::PageNotDefinedError`
|
105
|
+
**fetch_previous_page!** -> `Openpix::RubySdk::Resources::RequestError`, `Openpix::RubySdk::Resources::NotFetchedError`, `Openpix::RubySdk::Resources::PageNotDefinedError`
|
106
|
+
**find!** -> `Openpix::RubySdk::Resources::RequestError`
|
107
|
+
**destroy!** -> `Openpix::RubySdk::Resources::RequestError`
|
92
108
|
|
93
109
|
For the safe version (without bang!) there will be an `error_response` attribute setted in the API response whenever `success?` is false.
|
110
|
+
|
94
111
|
```ruby
|
95
112
|
response = client.customers.save
|
96
113
|
|
@@ -100,47 +117,11 @@ end
|
|
100
117
|
```
|
101
118
|
|
102
119
|
## Contributing
|
103
|
-
We welcome contributions to the Woovi Ruby SDK! If you would like to contribute, please follow these steps:
|
104
|
-
|
105
|
-
- Fork the repository
|
106
|
-
- Create a new branch for your feature or bug fix
|
107
|
-
- Write your code and tests
|
108
|
-
- Commit your changes and push your branch to GitHub
|
109
|
-
- Submit a pull request
|
110
|
-
|
111
|
-
Please make sure to adhere to the [code of conduct](#code-of-conduct).
|
112
|
-
|
113
|
-
## Code of Conduct
|
114
|
-
Our Pledge
|
115
|
-
We pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
116
120
|
|
117
|
-
|
118
|
-
Examples of behavior that contributes to creating a positive environment include:
|
121
|
+
If you have suggestions for how Woovi Ruby SDK could be improved, or want to report a bug, open an issue! We'd love all and any contributions.
|
119
122
|
|
120
|
-
|
121
|
-
Being respectful of differing viewpoints and experiences
|
122
|
-
Gracefully accepting constructive criticism
|
123
|
-
Focusing on what is best for the community
|
124
|
-
Showing empathy towards other community members
|
125
|
-
Examples of unacceptable behavior by participants include:
|
126
|
-
|
127
|
-
The use of sexualized language or imagery and unwelcome sexual attention or advances
|
128
|
-
Trolling, insulting/derogatory comments, and personal or political attacks
|
129
|
-
Public or private harassment
|
130
|
-
Publishing others' private information, such as a physical or electronic address, without explicit permission
|
131
|
-
Other conduct which could reasonably be considered inappropriate in a professional setting
|
132
|
-
Our Responsibilities
|
133
|
-
As project maintainers, we are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
|
134
|
-
|
135
|
-
As contributors, you have the responsibility to adhere to these standards and report any instances of unacceptable behavior.
|
136
|
-
|
137
|
-
Enforcement
|
138
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the project team at <developers@woovi.com>. The project team will review and investigate all complaints and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
|
139
|
-
|
140
|
-
Project maintainers who do not follow or enforce the code of conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
|
141
|
-
|
142
|
-
Attribution
|
143
|
-
This Code of Conduct is adapted from the Contributor Covenant, version 1.4, available at http://contributor-covenant.org/version/1/4.
|
123
|
+
For more, check out the [Contributing Guide](CONTRIBUTING.md).
|
144
124
|
|
145
125
|
## License
|
146
|
-
|
126
|
+
|
127
|
+
Woovi Ruby SDK is distributed under the terms of the [MIT license](LICENSE).
|
@@ -8,25 +8,11 @@ module Openpix
|
|
8
8
|
# Helper class to format body params before request
|
9
9
|
class ApiBodyFormatter
|
10
10
|
class << self
|
11
|
-
def format_entity_param(entity)
|
12
|
-
formatted_entity = {}
|
13
|
-
|
14
|
-
entity.each do |attr, value|
|
15
|
-
formatted_entity[transform_id_pattern(attr)] = value
|
16
|
-
end
|
17
|
-
|
18
|
-
remove_empty_values(formatted_entity)
|
19
|
-
end
|
20
|
-
|
21
11
|
def remove_empty_values(entity)
|
22
12
|
entity.compact.reject do |_key, value|
|
23
13
|
value.empty? if value.respond_to?(:empty?)
|
24
14
|
end
|
25
15
|
end
|
26
|
-
|
27
|
-
def transform_id_pattern(attr_key)
|
28
|
-
attr_key.camelize(:lower).gsub('Id', 'ID')
|
29
|
-
end
|
30
16
|
end
|
31
17
|
end
|
32
18
|
end
|
@@ -9,18 +9,18 @@ module Openpix
|
|
9
9
|
# Make API operations on Charge resource
|
10
10
|
class Charge < Resource
|
11
11
|
ATTRS = %w[
|
12
|
-
|
12
|
+
correlationID
|
13
13
|
value
|
14
14
|
type
|
15
15
|
comment
|
16
16
|
identifier
|
17
|
-
|
17
|
+
expiresIn
|
18
18
|
customer
|
19
|
-
|
20
|
-
|
19
|
+
daysForDueDate
|
20
|
+
daysAfterDueDate
|
21
21
|
interests
|
22
22
|
fines
|
23
|
-
|
23
|
+
additionalInfo
|
24
24
|
].freeze
|
25
25
|
|
26
26
|
attr_accessor(*ATTRS)
|
@@ -47,11 +47,11 @@ module Openpix
|
|
47
47
|
|
48
48
|
return body if body['customer'].nil? || body['customer'].empty?
|
49
49
|
|
50
|
-
body['customer'] = Openpix::RubySdk::ApiBodyFormatter.
|
50
|
+
body['customer'] = Openpix::RubySdk::ApiBodyFormatter.remove_empty_values(body['customer'])
|
51
51
|
|
52
52
|
return body if body['customer']['address'].nil? || body['customer']['address'].empty?
|
53
53
|
|
54
|
-
customer_address_parsed = Openpix::RubySdk::ApiBodyFormatter.
|
54
|
+
customer_address_parsed = Openpix::RubySdk::ApiBodyFormatter.remove_empty_values(body['customer']['address'])
|
55
55
|
body['customer'] = body['customer'].merge({ 'address' => customer_address_parsed })
|
56
56
|
|
57
57
|
body
|
@@ -61,9 +61,9 @@ module Openpix
|
|
61
61
|
# @param key [String] the key
|
62
62
|
# @param value [String] the value
|
63
63
|
def add_additional_info(key, value)
|
64
|
-
@
|
64
|
+
@additionalInfo = [] if @additionalInfo.nil?
|
65
65
|
|
66
|
-
@
|
66
|
+
@additionalInfo << { 'key' => key, 'value' => value }
|
67
67
|
end
|
68
68
|
|
69
69
|
# set interests configuration for creating this resource
|
@@ -12,8 +12,8 @@ module Openpix
|
|
12
12
|
name
|
13
13
|
email
|
14
14
|
phone
|
15
|
-
|
16
|
-
|
15
|
+
taxID
|
16
|
+
correlationID
|
17
17
|
address
|
18
18
|
].freeze
|
19
19
|
|
@@ -38,7 +38,7 @@ module Openpix
|
|
38
38
|
|
39
39
|
return body if body['address'].nil? || body['address'].empty?
|
40
40
|
|
41
|
-
body['address'] = Openpix::RubySdk::ApiBodyFormatter.
|
41
|
+
body['address'] = Openpix::RubySdk::ApiBodyFormatter.remove_empty_values(body['address'])
|
42
42
|
|
43
43
|
body
|
44
44
|
end
|
@@ -12,10 +12,10 @@ module Openpix
|
|
12
12
|
class Payment < Resource
|
13
13
|
ATTRS = %w[
|
14
14
|
value
|
15
|
-
|
16
|
-
|
15
|
+
destinationAlias
|
16
|
+
correlationID
|
17
17
|
comment
|
18
|
-
|
18
|
+
sourceAccountId
|
19
19
|
].freeze
|
20
20
|
|
21
21
|
attr_accessor(*ATTRS)
|
@@ -34,16 +34,6 @@ module Openpix
|
|
34
34
|
'payment'
|
35
35
|
end
|
36
36
|
|
37
|
-
def to_body
|
38
|
-
body = super
|
39
|
-
|
40
|
-
return body unless body['sourceAccountID']
|
41
|
-
|
42
|
-
body['sourceAccountId'] = body['sourceAccountID']
|
43
|
-
|
44
|
-
body.except('sourceAccountID')
|
45
|
-
end
|
46
|
-
|
47
37
|
# rubocop:disable Lint/UnusedMethodArgument
|
48
38
|
def destroy(id:)
|
49
39
|
raise(
|
@@ -12,8 +12,8 @@ module Openpix
|
|
12
12
|
class Refund < Resource
|
13
13
|
ATTRS = %w[
|
14
14
|
value
|
15
|
-
|
16
|
-
|
15
|
+
transactionEndToEndId
|
16
|
+
correlationID
|
17
17
|
comment
|
18
18
|
].freeze
|
19
19
|
|
@@ -33,16 +33,6 @@ module Openpix
|
|
33
33
|
'refund'
|
34
34
|
end
|
35
35
|
|
36
|
-
def to_body
|
37
|
-
body = super
|
38
|
-
|
39
|
-
return body unless body['transactionEndToEndID']
|
40
|
-
|
41
|
-
body['transactionEndToEndId'] = body['transactionEndToEndID']
|
42
|
-
|
43
|
-
body.except('transactionEndToEndID')
|
44
|
-
end
|
45
|
-
|
46
36
|
# rubocop:disable Lint/UnusedMethodArgument
|
47
37
|
def destroy(id:)
|
48
38
|
raise(
|
@@ -70,7 +70,7 @@ module Openpix
|
|
70
70
|
body = {}
|
71
71
|
|
72
72
|
create_attributes.each do |attr|
|
73
|
-
body[
|
73
|
+
body[attr] = send(attr)
|
74
74
|
end
|
75
75
|
|
76
76
|
compacted_body = Openpix::RubySdk::ApiBodyFormatter.remove_empty_values(body)
|
@@ -10,8 +10,9 @@ module Openpix
|
|
10
10
|
class Subscription < Resource
|
11
11
|
ATTRS = %w[
|
12
12
|
value
|
13
|
-
|
13
|
+
dayGenerateCharge
|
14
14
|
customer
|
15
|
+
chargeType
|
15
16
|
].freeze
|
16
17
|
|
17
18
|
attr_accessor(*ATTRS)
|
@@ -39,7 +40,7 @@ module Openpix
|
|
39
40
|
|
40
41
|
return body if body['customer'].nil? || body['customer'].empty?
|
41
42
|
|
42
|
-
body['customer'] = Openpix::RubySdk::ApiBodyFormatter.
|
43
|
+
body['customer'] = Openpix::RubySdk::ApiBodyFormatter.remove_empty_values(body['customer'])
|
43
44
|
|
44
45
|
body
|
45
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: openpix-ruby_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erick Takeshi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-07-
|
11
|
+
date: 2023-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|