paymentsds-mpesa 0.1.0.pre.alpha.12 → 0.1.0.pre.alpha.17

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: d42b016af388fd777534e8d2f96181cbe189597696cf69053ab85d4258a79ae8
4
- data.tar.gz: 2502631498d5b926a3dde3cd90162b228d874231858b096ac8a8e071828e7ec1
3
+ metadata.gz: 49ed75e6b0ee3a9e9f48640398173d61b959119e29f7f662b84ac94bd83014eb
4
+ data.tar.gz: e1444375cf22dbbaea6473e41d5de5bab5a8d42408f251da431cf90fedc16f48
5
5
  SHA512:
6
- metadata.gz: 96f0c45a882dbfbe9a7fbfb229976ef2e9c044ade1a3b811d70c172544c03b28e4c7a11531410bb5c6828b2a722b5277bf3984fc06117dfe4a5fac6b3f3b6f21
7
- data.tar.gz: 5f1a2926cf9062015584958e5849712131c8240587e42055ce60a021760894f8c287569b250747d5ef48586af5b0b317c72010d563f70a7804b33b9d9b4925b0
6
+ metadata.gz: 9fd64d4ce15517bb0c153fbb82f51870af27b60260b4d0eb97d57fdcb5c4aaecc9b423dd10cccddac5666d929123af6595744fe8fd45ecf754b382bfd4223608
7
+ data.tar.gz: 035a77d5c119230571c84c89f0eacc589646ca457f789f6a6797124bcc852bb28fb6e165566ece91f703d6e9c69782e0608a83497b30b84f8f782bf1c04c1c31
@@ -0,0 +1,13 @@
1
+ module Paymentsds
2
+ module MPesa
3
+ class Environment
4
+ attr_accessor :scheme
5
+ attr_accessor :domain
6
+
7
+ def initialize(scheme, dommain)
8
+ @scheme = scheme
9
+ @domain = domain
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,6 @@
1
1
  # frozen_string_literal: true
2
+ require 'json'
3
+ require 'faraday'
2
4
 
3
5
  module Paymentsds
4
6
  module MPesa
@@ -131,6 +133,8 @@ module Paymentsds
131
133
  end
132
134
 
133
135
  def perform_request(opcode, intent)
136
+ operation = Paymentsds::MPesa::OPERATIONS[opcode]
137
+
134
138
  generate_access_token
135
139
 
136
140
  request_data = {
@@ -143,27 +147,28 @@ module Paymentsds
143
147
  body: build_request_body(opcode, intent)
144
148
  }
145
149
 
146
- http_client = Faraday::Connection.new do |client|
147
- client.url = "#{request_data[:base_url]}/#{request_data[:path]}"
148
- client.headers = request_data[:headers]
149
- client.options.timeout = request_data.timeout
150
- end
151
-
152
- case operation[:method]
150
+ http_client = Faraday.new(
151
+ url: request_data[:base_url],
152
+ headers: request_data[:headers],
153
+ )
153
154
 
155
+ case operation[:method]
154
156
  when :get
155
- response = http_client.get do |req|
157
+ response = http_client.get(request_data[:path]) do |req|
156
158
  req.params = request_data.body
159
+ req.options.timeout = request_data[:timeout]
157
160
  end
158
161
 
159
162
  when :post
160
- response = http_client.post do |req|
161
- req.body = request_data.body
163
+ response = http_client.post(request_data[:path]) do |req|
164
+ req.body = request_data.body.to_json
165
+ req.options.timeout = request_data[:timeout]
162
166
  end
163
167
 
164
168
  when :put
165
- response = http_client.put do |req|
166
- req.body = request_data.body
169
+ response = http_client.put(request_data[:path]) do |req|
170
+ req.body = request_data.body.to_json
171
+ req.options.timeout = request_data[:timeout]
167
172
  end
168
173
  end
169
174
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Paymentsds
4
4
  module MPesa
5
- VERSION = '0.1.0.pre.alpha.12'
5
+ VERSION = '0.1.0.pre.alpha.17'
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.12
4
+ version: 0.1.0.pre.alpha.17
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edson Michaque
@@ -113,6 +113,7 @@ files:
113
113
  - lib/paymentsds/mpesa/client.rb
114
114
  - lib/paymentsds/mpesa/configuration.rb
115
115
  - lib/paymentsds/mpesa/constants.rb
116
+ - lib/paymentsds/mpesa/environment.rb
116
117
  - lib/paymentsds/mpesa/error_type.rb
117
118
  - lib/paymentsds/mpesa/operation.rb
118
119
  - lib/paymentsds/mpesa/patterns.rb