paymentsds-mpesa 0.1.0.pre.alpha.16 → 0.1.0.pre.alpha.21

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: 6208693951c132095c313a9ac26a021a7b48393b4706ad75f84e14a4b6ae52c3
4
- data.tar.gz: 2db110a2bcda196df5473233462e5988e8d013f1b174100d8216951bb5914b56
3
+ metadata.gz: e4d175e328213e45fddb5647da3a6e1d9168e1e92154aee542b98b7d514c070d
4
+ data.tar.gz: 75cd7d38ea3f2681022e7708f661a0dd0bad957606041f68dce41899d3eda22a
5
5
  SHA512:
6
- metadata.gz: 6bd42a5c03bfe03c06be5ba8ff353584699c2abf9bc39bc520397122dc36a9519d0c11510440e02c82c71d9b4042ed2af1151c06fa34126f5c2659719af78078
7
- data.tar.gz: ba06b6d8fdacb595dbea06635c2d3439138917287c26ac12e89fe7e4445eea756d551a2aab48cbe68c490f130f278f496a15cc9277919ecdb6767774bbc8faeb
6
+ metadata.gz: bde89ecd224ba63bb802cc44ceeaa1f43ea914753bb4e029d786654333306d1e3bbeda74ff56afe794c978c887670f71c41bcee07d7bd38162f4b0a515154465
7
+ data.tar.gz: c40699c7a4c74c2a4885ba3699b3965145de9462dcc67ca5bd60c926abbdfb201a6e13b7d31dbdb006d8c70214da34abe2798c0f605e2261000731e39d5c8eed
@@ -4,10 +4,14 @@ module Paymentsds
4
4
  attr_accessor :scheme
5
5
  attr_accessor :domain
6
6
 
7
- def initialize(scheme, dommain)
7
+ def initialize(scheme, domain)
8
8
  @scheme = scheme
9
9
  @domain = domain
10
10
  end
11
+
12
+ def to_url
13
+ "#{@scheme}://#{@domain}"
14
+ end
11
15
  end
12
16
  end
13
17
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require 'json'
2
3
  require 'faraday'
3
4
 
4
5
  module Paymentsds
@@ -137,7 +138,7 @@ module Paymentsds
137
138
  generate_access_token
138
139
 
139
140
  request_data = {
140
- base_url: "#{@config.environment.scheme}://#{@config.environment.domain}:#{operation[:port]}",
141
+ base_url: "#{@config.environment.to_url}:#{operation[:port]}",
141
142
  url: operation[:path],
142
143
  method: operation[:method],
143
144
  path: operation[:path],
@@ -146,27 +147,30 @@ module Paymentsds
146
147
  body: build_request_body(opcode, intent)
147
148
  }
148
149
 
149
- http_client = Faraday.new do |client|
150
- client.url = "#{request_data[:base_url]}/#{request_data[:path]}"
151
- client.headers = request_data[:headers]
152
- client.options.timeout = request_data.timeout
153
- end
150
+ http_client = Faraday.new(
151
+ url: request_data[:base_url],
152
+ headers: request_data[:headers],
153
+ )
154
154
 
155
- case operation[:method]
155
+ puts request_data[:base_url]
156
156
 
157
+ case operation[:method]
157
158
  when :get
158
- response = http_client.get do |req|
159
- req.params = request_data.body
159
+ response = http_client.get(request_data[:path]) do |req|
160
+ req.params = request_data[:body]
161
+ req.options.timeout = request_data[:timeout]
160
162
  end
161
163
 
162
164
  when :post
163
- response = http_client.post do |req|
164
- req.body = request_data.body
165
+ response = http_client.post(request_data[:path]) do |req|
166
+ req.body = request_data[:body].to_json
167
+ req.options.timeout = request_data[:timeout]
165
168
  end
166
169
 
167
170
  when :put
168
- response = http_client.put do |req|
169
- req.body = request_data.body
171
+ response = http_client.put(request_data[:path]) do |req|
172
+ req.body = request_data[:body].to_json
173
+ req.options.timeout = request_data[:timeout]
170
174
  end
171
175
  end
172
176
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Paymentsds
4
4
  module MPesa
5
- VERSION = '0.1.0.pre.alpha.16'
5
+ VERSION = '0.1.0.pre.alpha.21'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paymentsds-mpesa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha.16
4
+ version: 0.1.0.pre.alpha.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edson Michaque