okra-ruby 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 01f30c247f81018a9bab302ef54352cfd2ff5b5a9f9c5d915ba55e4a08fefd99
4
+ data.tar.gz: e147cbae5cdeecb5c213856a64b1a5ff4b026af63f14da1f08cb6d8024e3c5fc
5
+ SHA512:
6
+ metadata.gz: 0354a10a89230b95f638e5c99e5c5071b033cc0b4b6a158f9d4792f48d6e07aeb03d7f8eef000341b4d6bbe893e3108f463a1806e41c50ffbac7b5ce16c4fabe
7
+ data.tar.gz: 1364840edd388ce9e254799f0d482e9519e0781b17c911260b6a8ac48c134d6e2d8ed5d1c850100c864c29a0d02e180f4d531bcb7a78cf448cbcc25017dc7f1f
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+ auth_test.rb
13
+ identity_test.rb
14
+ bank_test.rb
15
+ balance_test.rb
16
+ account_test.rb
17
+ payment_test.rb
18
+ .DS_Store
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.6.3
7
+ before_install: gem install bundler -v 1.17.2
@@ -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 ifavour902@gmail.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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in okra-ruby.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ okra-ruby (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.4.4)
10
+ rake (10.5.0)
11
+ rspec (3.10.0)
12
+ rspec-core (~> 3.10.0)
13
+ rspec-expectations (~> 3.10.0)
14
+ rspec-mocks (~> 3.10.0)
15
+ rspec-core (3.10.1)
16
+ rspec-support (~> 3.10.0)
17
+ rspec-expectations (3.10.1)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.10.0)
20
+ rspec-mocks (3.10.2)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.10.0)
23
+ rspec-support (3.10.2)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.17)
30
+ okra-ruby!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.17.2
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Iphytech
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,187 @@
1
+ # Okra Ruby SDK
2
+
3
+ This is a Ruby gem for easy integration of [Okra](okra.ng) products.
4
+
5
+ # Documentation
6
+
7
+ See [Here](https://docs.okra.ng/docs/get-started-with-okra) for the API Docs.
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ gem 'okra-ruby'
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install okra-ruby
24
+
25
+ ## Usage
26
+
27
+ ## Instantiate Okra Object
28
+
29
+ To use the SDK in your project, you need to instantiate the Okra::ruby with your API keys( public and secret). We recommed that you store API keys in your environment variable named OKRA_PUBLIC_KEY, OKRA_SECRET_KEY. Instantiating your Okra object after adding your API keys in your environment is illustrated as follows below:
30
+
31
+ ```ruby
32
+
33
+ OkraTest = OkraSDK.new
34
+
35
+ ```
36
+
37
+ This throws a `OKRABadKeyError` if no key is found in the environment variable.
38
+
39
+ ### Instantiate Okra object in Sandbox without environment variable:
40
+
41
+ You can instantiate your Okra object by passing your public , secret key as an argument of the `OkraSDk` class just as displayed below:
42
+
43
+ ```ruby
44
+
45
+ OkraTest = OkraSDK.new("public_key", "secret_key)
46
+
47
+ ```
48
+
49
+ #### `NOTE:` It is best practice to always set your API keys to your environment variable for security purpose. Please be warned not use this package without setting your API keys in your environment variables in production.
50
+
51
+ #### To instantiate Okra object in production with environment variable:
52
+
53
+ Simply use it as displayed below:
54
+
55
+ ```ruby
56
+
57
+ OkraTest = OkraSDK.new("YOUR_OKRA_LIVE_PUBLIC_KEY", "YOUR_OKRA_LIVE_SECRET_KEY", true)
58
+
59
+ ```
60
+
61
+
62
+ ### List of all the Okra class available in the gem
63
+
64
+ NB - See the documentation for the request for each method of the products
65
+
66
+ - Auth.new(OkraTest)
67
+ - Account.new(OkraTest)
68
+ - AssetsAndLiabilities.new(OkraTest)
69
+ - Balance.new(OkraTest)
70
+ - Bank.new(OkraTest)
71
+ - Customer.new(OkraTest)
72
+ - Identity.new(OkraTest)
73
+ - Income.new(OkraTest)
74
+ - OtherProducts.new(OkraTest)
75
+ - Payment.new(OkraTest)
76
+ - Revenue.new(OkraTest)
77
+ - Transactions.new(OkraTest)
78
+ - Widget.new(OkraTest)
79
+
80
+
81
+ ## How to use
82
+
83
+ Once you initailzie a project with any of the classes listed above, you will be able to use their methods. To see all the available methods, kindly run the following command
84
+
85
+ Eg. ClassName.methods
86
+
87
+ ```cmd
88
+ Auth.instance_methods - Object.instance_methods
89
+
90
+ ```
91
+
92
+ The above command will output all the methods associated with the `Auth` class.
93
+
94
+
95
+ ### Full Auth Sample payload
96
+
97
+ ```ruby
98
+
99
+ require './okra_sdk'
100
+
101
+
102
+ OkraTest = OkraSDK.new("public_key", "secret_key")
103
+ auth = Auth.new(OkraTest)
104
+
105
+ # ========================= Get by ID
106
+
107
+ payload = {
108
+ "id" => "607d4xxxxx951e8ff79bxx79"
109
+ }
110
+ response = auth.get_by_id(payload)
111
+ puts response
112
+
113
+
114
+ # ===================================== Retrieve all auths
115
+
116
+ payload = {
117
+ "page" => 20,
118
+ "limit" => 2
119
+ }
120
+
121
+ response = auth.fetch_auths(payload)
122
+ puts response
123
+
124
+
125
+ # ===================================== get by customer
126
+
127
+ payload = {
128
+ "customer" => "xxxxx486"
129
+ }
130
+
131
+ response = auth.get_by_customer(payload)
132
+ puts response
133
+
134
+
135
+ # ===================================== get by date
136
+
137
+ payload = {
138
+ "from" => "2020-04-25",
139
+ "to" => "2020-06-29"
140
+ }
141
+
142
+ response = auth.get_by_date(payload)
143
+ puts response
144
+
145
+
146
+ # ======================================== get by bank
147
+
148
+ payload = {
149
+ "bank" => "5d6fe57a4099cc4b210bbeb3"
150
+ }
151
+
152
+ response = auth.get_by_bank(payload)
153
+ puts response
154
+
155
+
156
+ # ====================================== get by customerDate
157
+
158
+ payload = {
159
+ "customer" => "",
160
+ "to" => "2020-06-29",
161
+ "from" => "2020-04-25"
162
+ }
163
+
164
+ response = auth.get_by_customerDate(payload)
165
+ puts response
166
+
167
+ ```
168
+
169
+
170
+
171
+ ## Development
172
+
173
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
174
+
175
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
176
+
177
+ ## Contributing
178
+
179
+ Bug reports and pull requests are welcome on GitHub at https://github.com/okraHQ/okra-ruby. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
180
+
181
+ ## License
182
+
183
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
184
+
185
+ ## Code of Conduct
186
+
187
+ Everyone interacting in the Okra::Ruby project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/OkraHQ/okra-ruby/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "okra/ruby"
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
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/lib/okra/error.rb ADDED
@@ -0,0 +1,13 @@
1
+ class OkraServerError < StandardError
2
+ attr_reader :response
3
+
4
+ def initialize(response=nil)
5
+ @response = response
6
+ end
7
+
8
+ class OkraBadKeyError < StandardError
9
+ end
10
+
11
+ class ArgumentError < StandardError
12
+ end
13
+ end
@@ -0,0 +1,11 @@
1
+ module BASE_ENDPOINTS
2
+ OKRA_LIVE_URL = "https://api.okra.ng/v2"
3
+ OKRA_SANDBOX_URL = "https://api.okra.ng/v2/sandbox"
4
+ AUTH_ENDPOINT = "/auth"
5
+ IDENTITY_ENDPOINT = "/identity"
6
+ BALANCE_ENDPOINT = "/balance"
7
+ ACCOUNT_ENDPOINT = "/accounts"
8
+ TRANSACTION_ENDPOINT = "/transactions"
9
+ INCOME_ENDPOINT = "/income"
10
+ REVENUE_ENDPOINT = "/revenue"
11
+ end
@@ -0,0 +1,64 @@
1
+ require_relative "base/base.rb"
2
+ require 'json'
3
+
4
+ class Account < Base
5
+ def realtime_bank_account_info(data)
6
+ base_url = okra_object.base_url
7
+ #certain that the required parameters are passed
8
+ required_params = ["page", "limit"]
9
+ check_passed_parameters(required_params, data)
10
+ payload = data.to_json
11
+ response = post_request("#{base_url}/products/accounts", payload)
12
+ return response
13
+ end
14
+
15
+ def get_by_id(data)
16
+ base_url = okra_object.base_url
17
+ #certain that the required parameters are passed
18
+ required_params = ["id"]
19
+ check_passed_parameters(required_params, data)
20
+ payload = data.to_json
21
+ response = post_request("#{base_url}#{BASE_ENDPOINTS::ACCOUNT_ENDPOINT}/getById", payload)
22
+ return response
23
+ end
24
+
25
+ def get_by_customer(data)
26
+ base_url = okra_object.base_url
27
+ #certain that the required parameters are passed
28
+ required_params = ["customer"]
29
+ check_passed_parameters(required_params, data)
30
+ payload = data.to_json
31
+ response = post_request("#{base_url}#{BASE_ENDPOINTS::ACCOUNT_ENDPOINT}/getByCustomer", payload)
32
+ return response
33
+ end
34
+
35
+ def get_by_bank(data)
36
+ base_url = okra_object.base_url
37
+ #certain that the required parameters are passed
38
+ required_params = ["bank"]
39
+ check_passed_parameters(required_params, data)
40
+ payload = data.to_json
41
+ response = post_request("#{base_url}#{BASE_ENDPOINTS::ACCOUNT_ENDPOINT}/getByBank", payload)
42
+ return response
43
+ end
44
+
45
+ def get_by_date(data)
46
+ base_url = okra_object.base_url
47
+ #certain that the required parameters are passed
48
+ required_params = ["from", "to"]
49
+ check_passed_parameters(required_params, data)
50
+ payload = data.to_json
51
+ response = post_request("#{base_url}#{BASE_ENDPOINTS::ACCOUNT_ENDPOINT}/getByDate", payload)
52
+ return response
53
+ end
54
+
55
+ def get_by_customerDate(data)
56
+ base_url = okra_object.base_url
57
+ #certain that the required parameters are passed
58
+ required_params = ["to", "from", "customer"]
59
+ check_passed_parameters(required_params, data)
60
+ payload = data.to_json
61
+ response = post_request("#{base_url}#{BASE_ENDPOINTS::ACCOUNT_ENDPOINT}/getByCustomerDate", payload)
62
+ return response
63
+ end
64
+ end