Skip to content

Commit 5d1ba32

Browse files
Merge pull request #4 from Iphytech/iphie/workflow
Iphie/workflow
2 parents 4a0b51a + 4f89bfa commit 5d1ba32

File tree

12 files changed

+288
-23
lines changed

12 files changed

+288
-23
lines changed

.env.example

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
TEST_SECRET_KEY=
2+
TEST_PUBLIC_KEY=
3+
TEST_ENCRYPTION_KEY=

.github/pull_request_template.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<!--- Provide a general summary of your changes in the Title above -->
2+
3+
#### Description
4+
<!--- Describe your changes in detail -->
5+
6+
#### Related Issue
7+
<!--- This project only accepts pull requests related to open issues -->
8+
<!--- If suggesting a new feature or change, please discuss it in an issue first -->
9+
<!--- If fixing a bug, there should be an issue describing it with steps to reproduce -->
10+
<!--- Please link to the issue here: -->
11+
12+
#### Motivation and Context
13+
<!--- Why is this change required? What problem does it solve? -->
14+
15+
#### How Has This Been Tested?
16+
<!--- Please describe in detail how you tested your changes. -->
17+
<!--- Include details of your testing environment, and the tests you ran to -->
18+
<!--- see how your change affects other areas of the code, etc. -->
19+
20+
#### Types of changes
21+
<!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: -->
22+
- [ ] Bug fix (non-breaking change which fixes an issue)
23+
- [ ] Refactor (non-breaking change which improves implementation)
24+
- [ ] Performance (non-breaking change which improves performance. Please add associated performance test and results)
25+
- [ ] New feature (non-breaking change which adds functionality)
26+
- [ ] Breaking change (fix or feature that would cause existing functionality to change)
27+
- [ ] Non-functional change (xml comments/documentation/etc)
28+
29+
#### Checklist:
30+
<!--- The following is a checklist of items that MUST be completed before a PR is accepted -->
31+
<!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! -->
32+
- [ ] My code follows the code style of this project.
33+
- [ ] I have read the **CONTRIBUTING** [document](https://github.com/QuantConnect/Lean/blob/master/CONTRIBUTING.md).
34+
- [ ] I have added tests to cover my changes. <!--- If not applicable, please explain why -->
35+
- [ ] All new and existing tests passed.
36+
- [ ] My branch follows the naming convention `bug-<issue#>-<description>` or `feature-<issue#>-<description>`
37+
38+
39+
@Flutterwave/Corvus97 What do you think about these updates?
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Review changes on Dev (Commits/PRs)
2+
on:
3+
push:
4+
branches: ["dev"]
5+
pull_request:
6+
types:
7+
- opened
8+
9+
jobs:
10+
code-check:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
ruby-version: ["3.1", "3.0", "2.7"]
16+
17+
steps:
18+
- name: checkout code
19+
uses: actions/checkout@v2
20+
21+
- name: setup ruby environment
22+
uses: ruby/setup-ruby@v1
23+
with:
24+
bundler-cache: true
25+
ruby-version: ${{ matrix.ruby-version }}
26+
27+
- name: install ruby dependencies
28+
run: |
29+
gem install bundler
30+
bundle install --jobs 4 --retry 3
31+
32+
- name: run unit tests and coverage scan
33+
env:
34+
PUBLIC_KEY: ${{ secrets.PUBLIC_KEY }}
35+
ENCRYPTION_KEY: ${{ secrets.ENCRYPTION_KEY }}
36+
RAVE_SECRET_KEY: ${{ secrets.SECRET_KEY }}
37+
run: |
38+
bundle exec rspec --format progress --format json --out coverage/coverage.json
39+
40+
- name: upload coverage report to codecov
41+
uses: codecov/codecov-action@v2
42+
with:
43+
file: coverage/coverage.json
44+
45+
- name: push build status to slack
46+
uses: 8398a7/action-slack@v3
47+
with:
48+
status: ${{ job.status }}
49+
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
50+
env:
51+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
52+
if: always()

.github/workflows/ruby-publish.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Publish changes to Rubygems
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
jobs:
8+
check-readme-and-changelog:
9+
runs-on: ubuntu-latest
10+
env:
11+
OS: ubuntu-latest
12+
ruby-version: "3.1"
13+
steps:
14+
- name: checkout code
15+
uses: actions/checkout@v2
16+
17+
- name: check for changes in readme and changelog files
18+
run: |
19+
if ! git diff --quiet HEAD~ HEAD -- README.md CHANGELOG.md; then
20+
echo "README and/or CHANGELOG have been modified. Proceeding with deployment."
21+
else
22+
echo "README and/or CHANGELOG have not been modified. Terminating deployment."
23+
exit 1
24+
fi
25+
26+
- name: push build status to Slack
27+
uses: 8398a7/action-slack@v3
28+
with:
29+
status: ${{ job.status }}
30+
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
31+
env:
32+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
33+
if: always()
34+
35+
publish:
36+
needs: check-readme-and-changelog
37+
runs-on: ubuntu-latest
38+
env:
39+
OS: ubuntu-latest
40+
ruby-version: "3.1"
41+
steps:
42+
- name: checkout code
43+
uses: actions/checkout@v2
44+
45+
- name: Setup ruby environment
46+
uses: actions/setup-ruby@v1
47+
with:
48+
ruby-version: "3.1"
49+
50+
- name: install ruby dependencies
51+
run: bundle install
52+
53+
- name: Publish gems to Rubygems
54+
env:
55+
GEM_HOST_API_KEY: ${{secrets.GEM_HOST_API_KEY}}
56+
run: gem push gems/*.gem
57+
58+
- name: push build status to Slack
59+
uses: 8398a7/action-slack@v3
60+
with:
61+
status: ${{ job.status }}
62+
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest
63+
env:
64+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
65+
if: always()

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
/tmp/
99

1010
.env
11+
/sample_code
12+
sample_code/
13+
sample_code
1114

1215
# rspec failure tracking
1316
.rspec_status
@@ -33,4 +36,4 @@ virtual_account_number_test.rb
3336
bills_test.rb
3437
preauth_test.rb
3538
rspec_results.html
36-
flutterwave_sdk-0.1.0.gem
39+
flutterwave_sdk-0.1.0.gem

Gemfile.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,20 @@ PATH
22
remote: .
33
specs:
44
flutterwave_sdk (0.1.1)
5+
httparty (~> 0.16.3)
56

67
GEM
78
remote: https://rubygems.org/
89
specs:
910
diff-lcs (1.3)
11+
dotenv (2.8.1)
12+
httparty (0.16.4)
13+
mime-types (~> 3.0)
14+
multi_xml (>= 0.5.2)
15+
mime-types (3.4.1)
16+
mime-types-data (~> 3.2015)
17+
mime-types-data (3.2023.0218.1)
18+
multi_xml (0.6.0)
1019
rake (12.3.3)
1120
rspec (3.9.0)
1221
rspec-core (~> 3.9.0)
@@ -26,6 +35,8 @@ PLATFORMS
2635
ruby
2736

2837
DEPENDENCIES
38+
bundler (~> 2.1.4)
39+
dotenv (~> 2.8.1)
2940
flutterwave_sdk!
3041
rake (~> 12.0)
3142
rspec (~> 3.0)

changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## [0.1.1] - 2023-07-20
4+
### Added
5+
- Test suite for mobile money TZS transactions.
6+
- Workflow scripts for review and publish
7+
8+
### Fixed
9+
- Fix test suite for card.
10+
11+
312
## [0.1.1] - 2022-06-02
413
### Added
514
- Test suite for mobile money transactions.

flutterwave_sdk.gemspec

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,12 @@ spec.date = '2020-05-10'
2525
spec.bindir = "exe"
2626
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
2727
spec.require_paths = ["lib"]
28+
29+
spec.add_development_dependency "bundler", "~> 2.1.4"
30+
#add dotenv
31+
spec.add_development_dependency "dotenv", "~> 2.8.1"
32+
33+
# Dependencies
34+
spec.required_ruby_version = ">= 2.5.3"
35+
spec.add_runtime_dependency 'httparty', '~> 0.16.3'
2836
end

lib/flutterwave_sdk/flutterwave_objects/card.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33

44
class Card < CardBase
55

6-
# method to initiate card charge
6+
# method to initiate card charge
77
def initiate_charge(data)
88
base_url = flutterwave_object.base_url
99
encryption_key = flutterwave_object.encryption_key
1010
public_key = flutterwave_object.public_key
11-
11+
1212
# only update the payload with the transaction reference if it isn't already added to the payload
1313
if !data.key?("tx_ref")
1414
data.merge!({"tx_ref" => Util.transaction_reference_generator})
@@ -29,13 +29,13 @@ def initiate_charge(data)
2929
type = "card"
3030
payload = payload.to_json
3131

32-
response = post_request("#{base_url}#{BASE_ENDPOINTS::CHARGE_ENDPOINT}?type=#{type}", payload)
33-
32+
response = post_request("#{base_url}#{BASE_ENDPOINTS::CHARGE_ENDPOINT}?type=#{type}", payload)
33+
3434
return response
3535

3636
end
3737

38-
def validate_charge(flw_ref, otp)
38+
def validate_charge(flw_ref, otp)
3939
base_url = flutterwave_object.base_url
4040
payload = {
4141
"otp" => otp,
@@ -52,4 +52,4 @@ def verify_charge(id)
5252
response = get_request("#{base_url}/transactions/#{id}/verify")
5353
return response
5454
end
55-
end
55+
end

lib/flutterwave_sdk/flutterwave_objects/mobile_money.rb

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
class MobileMoney < Base
55
def initiate_charge(data)
6-
base_url = flutterwave_object.base_url
7-
6+
base_url = flutterwave_object.base_url
7+
88
# only update the payload with the transaction reference if it isn't already added to the payload
99
if !data.key?("tx_ref")
1010
data.merge!({"tx_ref" => Util.transaction_reference_generator})
1111
end
12-
# check the currency to determine the type and the required parameters
12+
# check the currency to determine the type and the required parameters
1313
if data["currency"] == "KES"
1414
required_parameters = [ "amount", "email", "phone_number", "tx_ref", "currency"]
1515
type = "mpesa"
@@ -22,12 +22,15 @@ def initiate_charge(data)
2222
elsif data["currency"] == "ZMW"
2323
required_parameters = ["amount", "email", "phone_number","tx_ref", "currency"]
2424
type = "mobile_money_zambia"
25-
elsif data["currency"] == "RWF"
25+
elsif data["currency"] == "RWF"
2626
required_parameters = ["amount", "email", "phone_number","tx_ref", "currency"]
2727
type = "mobile_money_rwanda"
2828
elsif data["currency"] == "XAF" || data["currency"] == "XOF"
2929
required_parameters = ["amount", "email", "phone_number", "tx_ref", "currency"]
3030
type = "mobile_money_franco"
31+
elsif data["currency"] == "TZS"
32+
required_parameters = ["amount", "email", "phone_number", "tx_ref", "currency"]
33+
type = "mobile_money_tanzania"
3134
else
3235
return "pass a valid currency"
3336
end
@@ -36,7 +39,7 @@ def initiate_charge(data)
3639
type = type
3740
payload = data.to_json
3841

39-
response = post_request("#{base_url}#{BASE_ENDPOINTS::CHARGE_ENDPOINT}?type=#{type}", payload)
42+
response = post_request("#{base_url}#{BASE_ENDPOINTS::CHARGE_ENDPOINT}?type=#{type}", payload)
4043
return response
4144
end
4245

0 commit comments

Comments
 (0)