orchard-api-client-anm 0.1.3 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c6e66ee039d048dcaeb3323ca7ba1011735941f43dd94d87f58558437b909a6a
4
- data.tar.gz: 6360df2749da90c401d2e48906c9037d795f75dd00d1c465e7f503f1e83ab3eb
3
+ metadata.gz: 5ba7e7eb2a45c832407e65c1303e54ed05fba25ab2285cee00a2e9fcb0f4de45
4
+ data.tar.gz: be0c19aedd32b4997338ff35a84cdada2dfd18b91e80d977e241df75f513b323
5
5
  SHA512:
6
- metadata.gz: e2c5dbeb84b5f2e0653ec185a57b2c2df9e9f6bfdf9733db8e70b18a9c743c1bbe1a8dfee3ace4bfe0d73bc703e37aecd532c3106a37bdbbf3bc7345aa7f0aac
7
- data.tar.gz: 372f1b1aa0399f425630c1a65579624d191de5a56d7b54f7afd6701cdd006838cec4a34d7a4deb395d1fce814ddbc47185c94d6f92b16e2a846ddae24f9a5b16
6
+ metadata.gz: 6ace832e209f9a435860fd531e0dfb835f5e569a24a39b736a19963f4253d5062d75c969513569bd46482897957fbd81a286db17f906dcd580ea0cdc8126d692
7
+ data.tar.gz: 78b803719e98c5630eb299385a76af36cd33630fd0ef3c78f340782afc5e09fa3c7d31072d337e36215d12032cdd5cb022edc36065d09f2ddbff2f8fd69205dd
data/.rubocop.yml CHANGED
@@ -18,4 +18,7 @@ Style/Documentation:
18
18
  Enabled: false
19
19
 
20
20
  Metrics/MethodLength:
21
- Max: 15
21
+ Max: 15
22
+
23
+ Metrics/BlockLength:
24
+ AllowedMethods: ['describe', 'context', 'it']
data/Gemfile CHANGED
@@ -6,9 +6,3 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
-
10
- gem "rspec", "~> 3.0"
11
-
12
- gem "rubocop", "~> 1.21"
13
-
14
- gem "faraday", "~> 2.6"
data/README.md CHANGED
@@ -41,9 +41,9 @@ If bundler is not being used to manage dependencies, install the gem by executin
41
41
  nw = allowed_parameters['MTN','VOD','AIR']
42
42
 
43
43
  payment_request_payload = {
44
- customer_number: '',
45
- reference: '',
46
- amount: '',
44
+ customer_number: '0550000000',
45
+ reference: 'AppsNmobile Pay',
46
+ amount: '1',
47
47
  exttrid: processing_id,
48
48
  nw: 'MTN',
49
49
  trans_type: 'CTM',
@@ -53,16 +53,16 @@ If bundler is not being used to manage dependencies, install the gem by executin
53
53
  voucher_code: ''
54
54
  }
55
55
 
56
- response = client.send_payment_request(payment_request_payload, _request_configurations)
56
+ response = client.send_payment_request(payment_request_payload, request_configurations)
57
57
 
58
58
  #Send Sms
59
59
  sms_payload = {
60
- sender_id: '',
61
- recipient_number: '',
62
- msg_body: '',
60
+ sender_id: 'ANM',
61
+ recipient_number: '0550000000',
62
+ msg_body: 'Sample text message',
63
63
  trans_type: 'SMS',
64
64
  service_id: ENV['SERVICE_ID']
65
65
  }
66
66
 
67
- response = client.send_sms(sms_payload, _request_configurations)
67
+ response = client.send_sms(sms_payload)
68
68
  ```
@@ -20,8 +20,8 @@ module Orchard
20
20
  OpenSSL::HMAC.hexdigest(digest, @secret_token.to_s, @payload.to_json)
21
21
  end
22
22
 
23
- def make_post_request
24
- response = @connection.post do |request|
23
+ def make_request(method)
24
+ response = @connection.send(method) do |request|
25
25
  request.url @endpoint
26
26
  request.options.timeout = @timeout
27
27
  request.body = @payload.to_json
@@ -30,9 +30,13 @@ module Orchard
30
30
 
31
31
  JSON.parse(response.body)
32
32
  rescue StandardError => e
33
+ error_response(e)
34
+ end
35
+
36
+ def default_response(error)
33
37
  {
34
38
  "res_code" => "999",
35
- "res_desc" => e.message
39
+ "res_desc" => error.message
36
40
  }
37
41
  end
38
42
  end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orchard
4
+ module API
5
+ class CheckTransactionStatus < Orchard::API::Base
6
+ def call
7
+ @endpoint = Orchard::API::Constants::CHECK_TRANSACTION_STATUS_ENDPOINT
8
+ make_request(:post)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -5,7 +5,7 @@ module Orchard
5
5
  class SendPaymentRequest < Orchard::API::Base
6
6
  def call
7
7
  @endpoint = Orchard::API::Constants::SEND_PAYMENT_REQUEST_ENDPOINT
8
- make_post_request
8
+ make_request(:post)
9
9
  end
10
10
  end
11
11
  end
@@ -7,7 +7,7 @@ module Orchard
7
7
  format_recipients_number
8
8
  generate_unique_id
9
9
  @endpoint = Orchard::API::Constants::SEND_SMS_ENDPOINT
10
- make_post_request
10
+ make_request(:post)
11
11
  end
12
12
 
13
13
  def format_recipients_number
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Orchard
4
+ module API
5
+ class ServiceLookupRequest < Orchard::API::Base
6
+ def call
7
+ @endpoint = Orchard::API::Constants::SERVICE_LOOKUP_REQUEST_ENDPOINT
8
+ make_request(:get)
9
+ end
10
+ end
11
+ end
12
+ end
@@ -6,21 +6,29 @@ module Orchard
6
6
  @secret_token = params[:secret_token]
7
7
  @client_token = params[:client_token]
8
8
  @url = params[:url]
9
- @connection = create_connection
9
+ create_connection
10
10
  end
11
11
 
12
12
  def send_payment_request(payload, request_configurations = {})
13
- Orchard::API::SendPaymentRequest.call(token_and_payload(payload), request_configurations)
13
+ Orchard::API::SendPaymentRequest.call(payload_with_client_data(payload), request_configurations)
14
14
  end
15
15
 
16
16
  def send_sms(payload, request_configurations = {})
17
- Orchard::API::SendSMS.call(token_and_payload(payload), request_configurations)
17
+ Orchard::API::SendSMS.call(payload_with_client_data(payload), request_configurations)
18
+ end
19
+
20
+ def service_lookup_request(payload, request_configurations = {})
21
+ Orchard::API::ServiceLookupRequest.call(payload_with_client_data(payload), request_configurations)
22
+ end
23
+
24
+ def check_transaction_status(payload, request_configurations = {})
25
+ Orchard::API::CheckTransactionStatus.call(payload_with_client_data(payload), request_configurations)
18
26
  end
19
27
 
20
28
  private
21
29
 
22
30
  def create_connection
23
- Faraday.new(
31
+ @connection = Faraday.new(
24
32
  url: @url.to_s,
25
33
  headers: {
26
34
  "Content-Type" => "application/json"
@@ -28,7 +36,7 @@ module Orchard
28
36
  )
29
37
  end
30
38
 
31
- def token_and_payload(payload)
39
+ def payload_with_client_data(payload)
32
40
  {
33
41
  payload: payload,
34
42
  secret_token: @secret_token,
@@ -5,6 +5,8 @@ module Orchard
5
5
  module Constants
6
6
  SEND_PAYMENT_REQUEST_ENDPOINT = "/sendRequest"
7
7
  SEND_SMS_ENDPOINT = "/sendSms"
8
+ SERVICE_LOOKUP_REQUEST_ENDPOINT = "/get_service_lookup_req"
9
+ CHECK_TRANSACTION_STATUS_ENDPOINT = "/checkTransaction"
8
10
  end
9
11
  end
10
12
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Orchard
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
data/lib/orchard.rb CHANGED
@@ -7,5 +7,7 @@ require_relative "orchard/constants"
7
7
  require_relative "orchard/api/base"
8
8
  require_relative "orchard/api/send_payment_request"
9
9
  require_relative "orchard/api/send_sms"
10
+ require_relative "orchard/api/service_lookup_request"
11
+ require_relative "orchard/api/check_transaction_status"
10
12
 
11
13
  require_relative "orchard/api_client"
data/orchard.gemspec CHANGED
@@ -18,24 +18,17 @@ Gem::Specification.new do |spec|
18
18
  spec.metadata["homepage_uri"] = spec.homepage
19
19
  spec.metadata["source_code_uri"] = "https://github.com/appsnmobile-solutions/orchard_api_client_gem"
20
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.
21
+ spec.add_development_dependency "byebug"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
23
+ spec.add_development_dependency "rubocop", "~> 1.21"
24
+ spec.add_dependency "faraday", "~> 2.6"
25
+
23
26
  spec.files = Dir.chdir(__dir__) do
24
27
  `git ls-files -z`.split("\x0").reject do |f|
25
28
  (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
29
  end
27
30
  end
28
-
29
31
  spec.bindir = "exe"
30
32
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
31
33
  spec.require_paths = ["lib"]
32
-
33
- # Uncomment to register a new dependency of your gem
34
- spec.add_development_dependency "byebug"
35
- spec.add_development_dependency "rspec", "~> 3.0"
36
- spec.add_dependency "faraday", "~> 2.6"
37
-
38
-
39
- # For more information and examples about making a new gem, check out our
40
- # guide at: https://bundler.io/guides/creating_gem.html
41
34
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: orchard-api-client-anm
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sydney Dapilah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-20 00:00:00.000000000 Z
11
+ date: 2022-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: byebug
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '3.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.21'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.21'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: faraday
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -59,20 +73,20 @@ executables: []
59
73
  extensions: []
60
74
  extra_rdoc_files: []
61
75
  files:
62
- - ".byebug_history"
63
76
  - ".rspec"
64
77
  - ".rubocop.yml"
65
78
  - CHANGELOG.md
66
79
  - CODE_OF_CONDUCT.md
67
80
  - Gemfile
68
- - Gemfile.lock
69
81
  - LICENSE.txt
70
82
  - README.md
71
83
  - Rakefile
72
84
  - lib/orchard.rb
73
85
  - lib/orchard/api/base.rb
86
+ - lib/orchard/api/check_transaction_status.rb
74
87
  - lib/orchard/api/send_payment_request.rb
75
88
  - lib/orchard/api/send_sms.rb
89
+ - lib/orchard/api/service_lookup_request.rb
76
90
  - lib/orchard/api_client.rb
77
91
  - lib/orchard/constants.rb
78
92
  - lib/orchard/version.rb
data/.byebug_history DELETED
@@ -1,109 +0,0 @@
1
- exit
2
- "2343333333333333"[-9..]
3
- "2343333333333333".[-9..]
4
- r
5
- exit
6
- client.send_sms(sms_payload, {timeout: 5})
7
- client.send_sms(sms_payload, {timeout: 10})
8
- r
9
- exit
10
- r
11
- exit
12
- r
13
- exit
14
- client
15
- exit
16
- @connection
17
- r
18
- exit
19
- eit
20
- @endpoint
21
- r
22
- exit
23
- r
24
- exit
25
- r
26
- exit
27
- r
28
- exit
29
- r
30
- exit
31
- continue
32
- @timeout
33
- exit
34
- @timeout
35
- exit
36
- r
37
- exit
38
- r
39
- exit
40
- r
41
- exit
42
- r.body
43
- r.success?
44
- r.success
45
- r.body
46
- r.data
47
- r
48
- exit
49
- @url
50
- exit
51
- response
52
- exit
53
- response
54
- exit
55
- response
56
- continue
57
- "#{@client_token}:#{compute_signature}"
58
- @client_token
59
- @clieint_token
60
- @payload
61
- exit
62
- @payload
63
- Orchard::API::Constants::SEND_PAYMENT_REQUEST_URL
64
- OpenSSL::HMAC.hexdigest(digest, @secret_token.to_s, @payload.to_json)
65
- @client_token
66
- @payload
67
- @secrete_token
68
- digest
69
- exit
70
- digist
71
- client.ctm_request(payload)
72
- exit
73
- payload
74
- client.ctm_request(payload)
75
- exit
76
- client.ctm_request(payload)
77
- exit
78
- client.ctm_request(payload)
79
- exit
80
- params
81
- client
82
- client.ctm_request(payload)
83
- exit
84
- client.ctm_request(payload)
85
- exit
86
- client.ctm_request(payload)
87
- exit
88
- client.ctm_request(payload)
89
- exit
90
- Orchard::API::SendPaymentRequest.call(payload)
91
- client.ctm_request(payload)
92
- client
93
- payload
94
- client.ctm_request(payload)
95
- exit
96
- payload
97
- client.ctm_request(payload)
98
- exit
99
- client.ctm_request(payload)
100
- exit
101
- client.ctm_request(payload)
102
- exit
103
- client.ctm_request(payload)
104
- payload
105
- exit
106
- Orchard::ApiClient.new(params).ctm_request
107
- exit
108
- CLIENT_TOKEN="JYAX4rhY3FI3LtzFwKGoVdnAMOkH3a51hAu3TdHv0cYiCTD4AjqqecZTzdgFjRcuDlGSEnhZQ2HC5BobsHLERQ=="
109
- SECRETE_TOKEN="Na+oh2ElZk3fDy3kKQItvXm0L+9vZ5j2cPfTX2/bLpFnDZOOxhINR4ouc0kBinwZSeX/68eHkPvwByMhNx7raw=="
data/Gemfile.lock DELETED
@@ -1,67 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- orchard-api-client-anm (0.1.1)
5
- byebug
6
- faraday (~> 2.6)
7
- rspec (~> 3.0)
8
-
9
- GEM
10
- remote: https://rubygems.org/
11
- specs:
12
- ast (2.4.2)
13
- byebug (11.1.3)
14
- diff-lcs (1.5.0)
15
- faraday (2.6.0)
16
- faraday-net_http (>= 2.0, < 3.1)
17
- ruby2_keywords (>= 0.0.4)
18
- faraday-net_http (3.0.1)
19
- json (2.6.2)
20
- parallel (1.22.1)
21
- parser (3.1.2.1)
22
- ast (~> 2.4.1)
23
- rainbow (3.1.1)
24
- rake (13.0.6)
25
- regexp_parser (2.6.0)
26
- rexml (3.2.5)
27
- rspec (3.11.0)
28
- rspec-core (~> 3.11.0)
29
- rspec-expectations (~> 3.11.0)
30
- rspec-mocks (~> 3.11.0)
31
- rspec-core (3.11.0)
32
- rspec-support (~> 3.11.0)
33
- rspec-expectations (3.11.1)
34
- diff-lcs (>= 1.2.0, < 2.0)
35
- rspec-support (~> 3.11.0)
36
- rspec-mocks (3.11.1)
37
- diff-lcs (>= 1.2.0, < 2.0)
38
- rspec-support (~> 3.11.0)
39
- rspec-support (3.11.1)
40
- rubocop (1.36.0)
41
- json (~> 2.3)
42
- parallel (~> 1.10)
43
- parser (>= 3.1.2.1)
44
- rainbow (>= 2.2.2, < 4.0)
45
- regexp_parser (>= 1.8, < 3.0)
46
- rexml (>= 3.2.5, < 4.0)
47
- rubocop-ast (>= 1.20.1, < 2.0)
48
- ruby-progressbar (~> 1.7)
49
- unicode-display_width (>= 1.4.0, < 3.0)
50
- rubocop-ast (1.22.0)
51
- parser (>= 3.1.1.0)
52
- ruby-progressbar (1.11.0)
53
- ruby2_keywords (0.0.5)
54
- unicode-display_width (2.3.0)
55
-
56
- PLATFORMS
57
- x86_64-linux
58
-
59
- DEPENDENCIES
60
- faraday (~> 2.6)
61
- orchard-api-client-anm!
62
- rake (~> 13.0)
63
- rspec (~> 3.0)
64
- rubocop (~> 1.21)
65
-
66
- BUNDLED WITH
67
- 2.3.20