airvend 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/.byebug_history +19 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.rubocop.yml +10 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/Gemfile +12 -0
- data/Gemfile.lock +148 -0
- data/LICENSE.txt +21 -0
- data/README.md +346 -0
- data/Rakefile +12 -0
- data/airvend.gemspec +43 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/airvend.rb +105 -0
- data/lib/airvend/airvend_objects/airtime.rb +28 -0
- data/lib/airvend/airvend_objects/internet.rb +45 -0
- data/lib/airvend/airvend_objects/power.rb +26 -0
- data/lib/airvend/airvend_objects/television.rb +29 -0
- data/lib/airvend/base/base.rb +180 -0
- data/lib/airvend/base_endpoints.rb +21 -0
- data/lib/airvend/errors.rb +37 -0
- data/lib/airvend/upper_case_string.rb +5 -0
- data/lib/airvend/vend.rb +43 -0
- data/lib/airvend/version.rb +5 -0
- metadata +166 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e8779b413dd8f8efb5b0263e161814e671b914b7f2ecc990ec7d080da399ab1f
|
4
|
+
data.tar.gz: fd7d73d444c292622545c441fc78d614caa0e53bce738481ea4be72929335fb7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3bc28beb95fe5066f3e7ef75b3af9e3210c96eeaa4996630f12871b96df848d2c7da7a7f839fb0cd2ba94250b5bd94ef8db05a26e5c7d1eb245b0b2d45d0b355
|
7
|
+
data.tar.gz: '092aabc5563547b77e0208a78384fa1fabf2817bc33ce189983eddf96241b2e4d062aa1756a2aaecfe7994b7dd686ae8923bc2a3e76c2e4b891ba64f58c9e5d3'
|
data/.byebug_history
ADDED
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
6
|
+
|
7
|
+
We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
|
8
|
+
|
9
|
+
## Our Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to a positive environment for our community include:
|
12
|
+
|
13
|
+
* Demonstrating empathy and kindness toward other people
|
14
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
15
|
+
* Giving and gracefully accepting constructive feedback
|
16
|
+
* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
|
17
|
+
* Focusing on what is best not just for us as individuals, but for the overall community
|
18
|
+
|
19
|
+
Examples of unacceptable behavior include:
|
20
|
+
|
21
|
+
* The use of sexualized language or imagery, and sexual attention or
|
22
|
+
advances of any kind
|
23
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or email
|
26
|
+
address, without their explicit permission
|
27
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
28
|
+
professional setting
|
29
|
+
|
30
|
+
## Enforcement Responsibilities
|
31
|
+
|
32
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
33
|
+
|
34
|
+
Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
|
35
|
+
|
36
|
+
## Scope
|
37
|
+
|
38
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
|
39
|
+
|
40
|
+
## Enforcement
|
41
|
+
|
42
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at 14131938+urchymanny@users.noreply.github.com. All complaints will be reviewed and investigated promptly and fairly.
|
43
|
+
|
44
|
+
All community leaders are obligated to respect the privacy and security of the reporter of any incident.
|
45
|
+
|
46
|
+
## Enforcement Guidelines
|
47
|
+
|
48
|
+
Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
|
49
|
+
|
50
|
+
### 1. Correction
|
51
|
+
|
52
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
|
53
|
+
|
54
|
+
**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
|
55
|
+
|
56
|
+
### 2. Warning
|
57
|
+
|
58
|
+
**Community Impact**: A violation through a single incident or series of actions.
|
59
|
+
|
60
|
+
**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
|
61
|
+
|
62
|
+
### 3. Temporary Ban
|
63
|
+
|
64
|
+
**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
|
65
|
+
|
66
|
+
**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
|
67
|
+
|
68
|
+
### 4. Permanent Ban
|
69
|
+
|
70
|
+
**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
|
71
|
+
|
72
|
+
**Consequence**: A permanent ban from any sort of public interaction within the community.
|
73
|
+
|
74
|
+
## Attribution
|
75
|
+
|
76
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
|
77
|
+
available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
78
|
+
|
79
|
+
Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
80
|
+
|
81
|
+
[homepage]: https://www.contributor-covenant.org
|
82
|
+
|
83
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
84
|
+
https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,148 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
airvend (0.1.0)
|
5
|
+
faraday (~> 1.4)
|
6
|
+
faraday-detailed_logger (~> 2.3)
|
7
|
+
httparty (~> 0.18)
|
8
|
+
json (~> 2.5)
|
9
|
+
typhoeus (~> 1.4)
|
10
|
+
|
11
|
+
GEM
|
12
|
+
remote: https://rubygems.org/
|
13
|
+
specs:
|
14
|
+
actionpack (6.1.3.2)
|
15
|
+
actionview (= 6.1.3.2)
|
16
|
+
activesupport (= 6.1.3.2)
|
17
|
+
rack (~> 2.0, >= 2.0.9)
|
18
|
+
rack-test (>= 0.6.3)
|
19
|
+
rails-dom-testing (~> 2.0)
|
20
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
21
|
+
actionview (6.1.3.2)
|
22
|
+
activesupport (= 6.1.3.2)
|
23
|
+
builder (~> 3.1)
|
24
|
+
erubi (~> 1.4)
|
25
|
+
rails-dom-testing (~> 2.0)
|
26
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
27
|
+
activesupport (6.1.3.2)
|
28
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
29
|
+
i18n (>= 1.6, < 2)
|
30
|
+
minitest (>= 5.1)
|
31
|
+
tzinfo (~> 2.0)
|
32
|
+
zeitwerk (~> 2.3)
|
33
|
+
ast (2.4.2)
|
34
|
+
builder (3.2.4)
|
35
|
+
byebug (11.1.3)
|
36
|
+
concurrent-ruby (1.1.9)
|
37
|
+
crass (1.0.6)
|
38
|
+
diff-lcs (1.4.4)
|
39
|
+
dotenv (2.7.6)
|
40
|
+
dotenv-rails (2.7.6)
|
41
|
+
dotenv (= 2.7.6)
|
42
|
+
railties (>= 3.2)
|
43
|
+
erubi (1.10.0)
|
44
|
+
ethon (0.14.0)
|
45
|
+
ffi (>= 1.15.0)
|
46
|
+
faraday (1.4.2)
|
47
|
+
faraday-em_http (~> 1.0)
|
48
|
+
faraday-em_synchrony (~> 1.0)
|
49
|
+
faraday-excon (~> 1.1)
|
50
|
+
faraday-net_http (~> 1.0)
|
51
|
+
faraday-net_http_persistent (~> 1.1)
|
52
|
+
multipart-post (>= 1.2, < 3)
|
53
|
+
ruby2_keywords (>= 0.0.4)
|
54
|
+
faraday-detailed_logger (2.3.0)
|
55
|
+
faraday (>= 0.8, < 2)
|
56
|
+
faraday-em_http (1.0.0)
|
57
|
+
faraday-em_synchrony (1.0.0)
|
58
|
+
faraday-excon (1.1.0)
|
59
|
+
faraday-net_http (1.0.1)
|
60
|
+
faraday-net_http_persistent (1.1.0)
|
61
|
+
ffi (1.15.1)
|
62
|
+
httparty (0.18.1)
|
63
|
+
mime-types (~> 3.0)
|
64
|
+
multi_xml (>= 0.5.2)
|
65
|
+
i18n (1.8.10)
|
66
|
+
concurrent-ruby (~> 1.0)
|
67
|
+
json (2.5.1)
|
68
|
+
loofah (2.10.0)
|
69
|
+
crass (~> 1.0.2)
|
70
|
+
nokogiri (>= 1.5.9)
|
71
|
+
method_source (1.0.0)
|
72
|
+
mime-types (3.3.1)
|
73
|
+
mime-types-data (~> 3.2015)
|
74
|
+
mime-types-data (3.2021.0225)
|
75
|
+
minitest (5.14.4)
|
76
|
+
multi_xml (0.6.0)
|
77
|
+
multipart-post (2.1.1)
|
78
|
+
nokogiri (1.11.7-x86_64-darwin)
|
79
|
+
racc (~> 1.4)
|
80
|
+
parallel (1.20.1)
|
81
|
+
parser (3.0.1.1)
|
82
|
+
ast (~> 2.4.1)
|
83
|
+
racc (1.5.2)
|
84
|
+
rack (2.2.3)
|
85
|
+
rack-test (1.1.0)
|
86
|
+
rack (>= 1.0, < 3)
|
87
|
+
rails-dom-testing (2.0.3)
|
88
|
+
activesupport (>= 4.2.0)
|
89
|
+
nokogiri (>= 1.6)
|
90
|
+
rails-html-sanitizer (1.3.0)
|
91
|
+
loofah (~> 2.3)
|
92
|
+
railties (6.1.3.2)
|
93
|
+
actionpack (= 6.1.3.2)
|
94
|
+
activesupport (= 6.1.3.2)
|
95
|
+
method_source
|
96
|
+
rake (>= 0.8.7)
|
97
|
+
thor (~> 1.0)
|
98
|
+
rainbow (3.0.0)
|
99
|
+
rake (13.0.3)
|
100
|
+
regexp_parser (2.1.1)
|
101
|
+
rexml (3.2.5)
|
102
|
+
rspec (3.10.0)
|
103
|
+
rspec-core (~> 3.10.0)
|
104
|
+
rspec-expectations (~> 3.10.0)
|
105
|
+
rspec-mocks (~> 3.10.0)
|
106
|
+
rspec-core (3.10.1)
|
107
|
+
rspec-support (~> 3.10.0)
|
108
|
+
rspec-expectations (3.10.1)
|
109
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
110
|
+
rspec-support (~> 3.10.0)
|
111
|
+
rspec-mocks (3.10.2)
|
112
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
113
|
+
rspec-support (~> 3.10.0)
|
114
|
+
rspec-support (3.10.2)
|
115
|
+
rubocop (0.93.1)
|
116
|
+
parallel (~> 1.10)
|
117
|
+
parser (>= 2.7.1.5)
|
118
|
+
rainbow (>= 2.2.2, < 4.0)
|
119
|
+
regexp_parser (>= 1.8)
|
120
|
+
rexml
|
121
|
+
rubocop-ast (>= 0.6.0)
|
122
|
+
ruby-progressbar (~> 1.7)
|
123
|
+
unicode-display_width (>= 1.4.0, < 2.0)
|
124
|
+
rubocop-ast (1.7.0)
|
125
|
+
parser (>= 3.0.1.1)
|
126
|
+
ruby-progressbar (1.11.0)
|
127
|
+
ruby2_keywords (0.0.4)
|
128
|
+
thor (1.1.0)
|
129
|
+
typhoeus (1.4.0)
|
130
|
+
ethon (>= 0.9.0)
|
131
|
+
tzinfo (2.0.4)
|
132
|
+
concurrent-ruby (~> 1.0)
|
133
|
+
unicode-display_width (1.7.0)
|
134
|
+
zeitwerk (2.4.2)
|
135
|
+
|
136
|
+
PLATFORMS
|
137
|
+
x86_64-darwin-20
|
138
|
+
|
139
|
+
DEPENDENCIES
|
140
|
+
airvend!
|
141
|
+
byebug
|
142
|
+
dotenv-rails
|
143
|
+
rake (~> 13.0)
|
144
|
+
rspec (~> 3.0)
|
145
|
+
rubocop (~> 0.80)
|
146
|
+
|
147
|
+
BUNDLED WITH
|
148
|
+
2.2.3
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2021 Uchenna Mba
|
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,346 @@
|
|
1
|
+
# Airvend Ruby
|
2
|
+
|
3
|
+
This gem makes it easy for businesses or individuals to implement vending of Airtime, Data, Electricity, Utilities & Television subscriptions to their application. This is a simplifiication of the [Airvend](https://airvend.ng) API
|
4
|
+
|
5
|
+
### Documentation
|
6
|
+
|
7
|
+
See [Here](https://documenter.getpostman.com/view/6349852/SVSHrpfv) for Airvend REST API Docs.
|
8
|
+
|
9
|
+
To use this resource, you would need to register on the [Airvend B2B](https://business.airvend.ng/) to get access to personal test API Keys or contact me hey@uche.io
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'airvend'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
$ bundle install
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
$ gem install airvend
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
### Initialization
|
30
|
+
|
31
|
+
#### Instantiate Airvend object in sandbox with environment variable:
|
32
|
+
|
33
|
+
To use the Airvend Gem, you need to instantiate the Airvend class with your credentials including your Username, Password & API Key. Best practice requires you to add your credentials to your Environment Variables `AIRVEND_USERNAME`, `AIRVEND_PASSWORD` & `AIRVEND_API_KEY`. You can call the new method on the Airvend Class afterwards
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
airvend = Airvend.new
|
37
|
+
```
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
you can also call the class with your credentials without Environment Variables pre set
|
42
|
+
|
43
|
+
```ruby
|
44
|
+
airvend = Airvend.new("YOUR-AIRVEND-USERNAME", "YOUR-AIRVEND-PASSWORD", "YOUR-AIRVEND-API-KEY")
|
45
|
+
```
|
46
|
+
|
47
|
+
Expect a `AirvendBadUserError`, `AirvendBadPassError`, or `AirvendBadKeyError` if the username, password or API key is missing or invalid respectively.
|
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
|
+
|
52
|
+
|
53
|
+
## Airvend Objects
|
54
|
+
|
55
|
+
- [VEND](#vend)
|
56
|
+
- [Airtime Vending - Vend::Airtime.new(airvend)](#airtime-vending)
|
57
|
+
- [Internet Data Vending - Vend::InternetData.new(airvend)](#internet-data-vending)
|
58
|
+
- [Electricity Vending - Vend::Power.new(airvend)](#electricity-vending)
|
59
|
+
- [TV Vending - Vend::Television](#tv-vending)
|
60
|
+
|
61
|
+
# VEND
|
62
|
+
|
63
|
+
To vend different services, you have access to the different classes for the different services
|
64
|
+
|
65
|
+
|
66
|
+
|
67
|
+
## Airtime Vending
|
68
|
+
|
69
|
+
To vend airtime, you need to instantiate the Airtime Class with the [`airvend`](#instantiate-airvend-object-in-sandbox-with-environment-variable) object
|
70
|
+
|
71
|
+
```ruby
|
72
|
+
airtime = Vend::Airtime.new(airvend)
|
73
|
+
```
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
To purchase airtime for a phone number that is registered with any of the NCC licensed mobile networks `MTN`, `GLO`, `AIRTEL`, `9MOBILE` you can utilize the method below
|
78
|
+
|
79
|
+
First, we need to provide the required data in the payload
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
payload = {
|
83
|
+
ref: "YOUR-OWN-REF-HERE",
|
84
|
+
phone: "08138236694",
|
85
|
+
mno: "mtn", # can also be `glo`, `airtel` or `9mobile`
|
86
|
+
amount: "200"
|
87
|
+
}
|
88
|
+
```
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
Next, we call the method to process the airtime purchase as shown below
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
airtime.buy(payload)
|
96
|
+
```
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
## Internet Data Vending
|
101
|
+
|
102
|
+
To vend Internet data subscriptions, you need to instantiate the `Internet` Class with the [`airvend`](#instantiate-airvend-object-in-sandbox-with-environment-variable) object
|
103
|
+
|
104
|
+
```ruby
|
105
|
+
internet = Vend::Internet.new(airvend)
|
106
|
+
```
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
To purchase internet data for a phone number that is registered with any of the NCC licensed mobile networks `MTN`, `GLO`, `AIRTEL`, `9MOBILE` you can utilize the method below
|
111
|
+
|
112
|
+
First, we need to fetch a list of available internet data plans for the selected mobile network with the payload
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
internet_plans = internet.plans("mtn") # can also be `glo`, `airtel` or `9mobile`
|
116
|
+
```
|
117
|
+
|
118
|
+
|
119
|
+
|
120
|
+
This return an array of hashes with each containing a data plan in the format
|
121
|
+
|
122
|
+
```ruby
|
123
|
+
[
|
124
|
+
...
|
125
|
+
{
|
126
|
+
:description=>"350MB",
|
127
|
+
:amount=>"300",
|
128
|
+
:code=>"300",
|
129
|
+
:validity=>" for 7 Days"
|
130
|
+
}
|
131
|
+
...
|
132
|
+
]
|
133
|
+
```
|
134
|
+
|
135
|
+
#### Note the `code` is an identifier for the plan and is different from the amount
|
136
|
+
|
137
|
+
|
138
|
+
|
139
|
+
Next, you can proceed to purchase the selected internet data plan with the payload
|
140
|
+
|
141
|
+
```ruby
|
142
|
+
payload = {
|
143
|
+
ref: "YOUR-OWN-REF-HERE",
|
144
|
+
phone: "08138236694",
|
145
|
+
mno: "mtn", # can also be `glo`, `airtel` or `9mobile`
|
146
|
+
code: "200" # this is code from the selected internet data plan from the list of data plans
|
147
|
+
}
|
148
|
+
```
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
then we can proceed to make subscription after charging customer or your app user
|
153
|
+
|
154
|
+
```ruby
|
155
|
+
internet.buy(payload)
|
156
|
+
```
|
157
|
+
|
158
|
+
|
159
|
+
|
160
|
+
## Electricity Vending
|
161
|
+
|
162
|
+
To vend Electricity Bills, you need to instantiate the `Power` Class with the [`airvend`](#instantiate-airvend-object-in-sandbox-with-environment-variable) object
|
163
|
+
|
164
|
+
```ruby
|
165
|
+
power = Vend::Power.new(airvend)
|
166
|
+
```
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
Before paying for electricity bills, it's important to confirm the customers details before proceeding
|
171
|
+
|
172
|
+
```ruby
|
173
|
+
payload = {
|
174
|
+
account: "45701113131", #this is the customers meter number
|
175
|
+
provider: "aedc",
|
176
|
+
account_type: "prepaid" # can also be "postpaid"
|
177
|
+
}
|
178
|
+
```
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
the following providers are supported:
|
183
|
+
|
184
|
+
- `aedc` for Abuja Electricity Distribution Company
|
185
|
+
- `ie` for Ikeja Electricity
|
186
|
+
- `eko` for Eko Distribution
|
187
|
+
- `phed` for Port Harcourt Electricity Distribution
|
188
|
+
- `eedc` for Enugu Electricity Distribution Company
|
189
|
+
- `kedco` for Kaduna Electricity Distribution Company
|
190
|
+
- `ibedc` for Ibadan Electricity Distribution Company
|
191
|
+
|
192
|
+
|
193
|
+
|
194
|
+
To get the customer details, use the `verify` method
|
195
|
+
|
196
|
+
````ruby
|
197
|
+
customer = power.verify(payload)
|
198
|
+
````
|
199
|
+
|
200
|
+
which returns:
|
201
|
+
|
202
|
+
``` ruby
|
203
|
+
{
|
204
|
+
:name=>"OLUWAFEMI ODIGIE",
|
205
|
+
:accountstatus=>"OPEN",
|
206
|
+
:customernumber=>"BA36F4AEF88763454678BF9D1A85E4AE6F166CECA01DE4B58C1100DA3DA87362A6CBD3410E2B7F809C1A33E1AD6756BBA853F4C0275270B398BC69E8AC050E75|eyJwcm9kdWN0IjoiUE9SVEhBUkNPVVJURUxFQ1RSSUNJVFkiLCJ0eXBlIjoiUFJFUEFJRCIsImFjY291bnQiOiIwMTI0MDAxMjQ3Njk5IiwibmFtZSI6IkVzIE9tYWNoaSIsImFkZHJlc3MiOiJOTyA2NSBXb2ppIFJkIE5PIDY1IFdvamkgUmQiLCJ0YXJyaWYiOiJSMiIsImFycmVhcnMiOiIwIiwicGhvbmUiOiIiLCJtZXRlck51bWJlciI6IjAxMjQwMDEyNDc2OTkiLCJjdXN0b21lck51bWJlciI6IjgxNDE3MDIyODMwMSIsInRvdGFsQmlsbCI6IjAiLCJpYmNOYW1lIjoiR2FyZGVuIENpdHkgSW5kdXN0cmlhbCIsImJzY05hbWUiOiJSdW11b2diYSJ9",
|
207
|
+
:account=>"7021959296",
|
208
|
+
:customeraccounttype=>""
|
209
|
+
}
|
210
|
+
```
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
Finally, to purchase power for the verified customer, you would prepare a payload using the customer number that is gotten from the `verify` method
|
215
|
+
|
216
|
+
``` ruby
|
217
|
+
payload = {
|
218
|
+
ref: "YOUR-OWN-REF-HERE",
|
219
|
+
account: "02188019141",
|
220
|
+
provider: "aedc",
|
221
|
+
amount: "2000",
|
222
|
+
customernumber:"BA36F4AEF88763454678BF9D1A85E4AE6F166CECA01DE4B58C1100DA3DA87362A6CBD3410E2B7F809C1A33E1AD6756BBA853F4C0275270B398BC69E8AC050E75|eyJwcm9kdWN0IjoiUE9SVEhBUkNPVVJURUxFQ1RSSUNJVFkiLCJ0eXBlIjoiUFJFUEFJRCIsImFjY291bnQiOiIwMTI0MDAxMjQ3Njk5IiwibmFtZSI6IkVzIE9tYWNoaSIsImFkZHJlc3MiOiJOTyA2NSBXb2ppIFJkIE5PIDY1IFdvamkgUmQiLCJ0YXJyaWYiOiJSMiIsImFycmVhcnMiOiIwIiwicGhvbmUiOiIiLCJtZXRlck51bWJlciI6IjAxMjQwMDEyNDc2OTkiLCJjdXN0b21lck51bWJlciI6IjgxNDE3MDIyODMwMSIsInRvdGFsQmlsbCI6IjAiLCJpYmNOYW1lIjoiR2FyZGVuIENpdHkgSW5kdXN0cmlhbCIsImJzY05hbWUiOiJSdW11b2diYSJ9" #data contained in the response from verify customer method
|
223
|
+
}
|
224
|
+
```
|
225
|
+
|
226
|
+
The `customernumber` is contained in the response from the `verify` method
|
227
|
+
|
228
|
+
|
229
|
+
|
230
|
+
Next, to process the power purchase, use the method below on the provided payload
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
power.buy(payload)
|
234
|
+
```
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
## TV Vending
|
239
|
+
|
240
|
+
To vend TV Subscriptions like DStv & GoTv, you need to instantiate the `Television` Class with the [`airvend`](#instantiate-airvend-object-in-sandbox-with-environment-variable) object
|
241
|
+
|
242
|
+
``` ruby
|
243
|
+
tv = Vend::Television
|
244
|
+
```
|
245
|
+
|
246
|
+
|
247
|
+
|
248
|
+
Before paying for TV subscriptions, it's important to confirm the customers details before proceeding
|
249
|
+
|
250
|
+
``` ruby
|
251
|
+
payload = {
|
252
|
+
provider: "dstv",
|
253
|
+
account: "7021959296" # customer decoder iuc number
|
254
|
+
}
|
255
|
+
```
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
To get the customer details, use the `verify` method
|
260
|
+
|
261
|
+
``` ruby
|
262
|
+
customer = tv.verify(payload)
|
263
|
+
```
|
264
|
+
|
265
|
+
which returns:
|
266
|
+
|
267
|
+
``` ruby
|
268
|
+
{
|
269
|
+
:name=>"OLUWAFEMI ODIGIE",
|
270
|
+
:accountstatus=>"OPEN",
|
271
|
+
:customernumber=>56920080,
|
272
|
+
:account=>"7021959296"
|
273
|
+
}
|
274
|
+
```
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
Also, for processing TV Subscriptions, customers would be interested in selecting a subscription plan from their provider. You can get a list of available plans from each specific subscriber
|
279
|
+
|
280
|
+
``` ruby
|
281
|
+
tv_plans = tv.plans("dstv") # can also be `gotv`
|
282
|
+
```
|
283
|
+
|
284
|
+
This return an array of hashes with each containing a tv plans in the format
|
285
|
+
|
286
|
+
```ruby
|
287
|
+
[
|
288
|
+
...
|
289
|
+
{
|
290
|
+
:description=>"DStv Compact",
|
291
|
+
:amount=> "7900",
|
292
|
+
:code=>"COMPE36"
|
293
|
+
}
|
294
|
+
...
|
295
|
+
]
|
296
|
+
```
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
Finally, to subscribe to a tv plan for the verified customer, you would prepare a payload using the customer
|
301
|
+
|
302
|
+
``` ruby
|
303
|
+
payload = {
|
304
|
+
ref: "YOUR-OWN-REF-HERE",
|
305
|
+
account: "02188019141",
|
306
|
+
provider: "aedc",
|
307
|
+
account_type: "prepaid",
|
308
|
+
amount: "2000",
|
309
|
+
customernumber: "56920080"
|
310
|
+
}
|
311
|
+
```
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
next, to process the power purchase, use the method below on the provided payload
|
316
|
+
|
317
|
+
```ruby
|
318
|
+
tv.buy(payload)
|
319
|
+
```
|
320
|
+
|
321
|
+
|
322
|
+
|
323
|
+
## Transactions
|
324
|
+
|
325
|
+
#### NOTE: This is currently not available.
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
## Development
|
330
|
+
|
331
|
+
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.
|
332
|
+
|
333
|
+
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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
334
|
+
|
335
|
+
## Contributing
|
336
|
+
|
337
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/urchymanny/airvend-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/urchymanny/airvend-rails/blob/master/CODE_OF_CONDUCT.md).
|
338
|
+
|
339
|
+
## License
|
340
|
+
|
341
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
342
|
+
|
343
|
+
## Code of Conduct
|
344
|
+
|
345
|
+
Everyone interacting in the Airvend project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/urchymanny/airvend-rails/blob/master/CODE_OF_CONDUCT.md).
|
346
|
+
|