mpayer_ruby 0.0.09 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +0 -1
- data/bin/console +1 -1
- data/lib/mpayer_ruby/configuration.rb +3 -3
- data/lib/mpayer_ruby/endpoints/{endpoint.rb → _endpoint.rb} +0 -0
- data/lib/mpayer_ruby/endpoints/client.rb +2 -2
- data/lib/mpayer_ruby/endpoints/message.rb +22 -0
- data/lib/mpayer_ruby/fetch.rb +2 -2
- data/lib/mpayer_ruby/support/fake_mpayer/messages/.keep +0 -0
- data/lib/mpayer_ruby/support/fake_mpayer.rb +1 -1
- data/lib/mpayer_ruby/version.rb +1 -1
- data/lib/mpayer_ruby.rb +15 -14
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f16f461bac9407c17afcf540d4095a091965ed8d
|
4
|
+
data.tar.gz: 194c8a4618311845f991401be2624d752f9c1bf6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6aa9d45fe3ce0d126c1b0a453cbe3cbd62da017e6c13387217d24bdb006cd8c370c424ad0bdf40e249f285027940ff0de60ed35d6682423aa06d9a2a1ca49ffe
|
7
|
+
data.tar.gz: 25c7d112955514318ebe54ea7c78f9cf243e65d352a83314e56cd1ebb61b861a3c18820afb99f47be97ff6f6ac1edf5d3e6cc39d2f50818ff029228c9dd749dc
|
data/Guardfile
CHANGED
data/bin/console
CHANGED
@@ -2,8 +2,8 @@ module Mpayer
|
|
2
2
|
class Configuration
|
3
3
|
attr_accessor :user_no, :token, :base_url
|
4
4
|
|
5
|
-
def initialize(user_no:nil,token:nil)
|
6
|
-
@base_url
|
5
|
+
def initialize(user_no:nil,token:nil,base_url:'https://app.mpayer.co.ke/api/')
|
6
|
+
@base_url ||= base_url
|
7
7
|
@user_no ||= user_no
|
8
8
|
@token ||= token
|
9
9
|
end
|
@@ -13,7 +13,7 @@ module Mpayer
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def header
|
16
|
-
{'Content-Type'=> 'application/json', 'Accept' => 'application/json', 'X-WSSE' => auth
|
16
|
+
{'Content-Type'=> 'application/json', 'Accept' => 'application/json', 'X-WSSE' => auth.to_s}
|
17
17
|
end
|
18
18
|
|
19
19
|
end
|
File without changes
|
@@ -22,7 +22,7 @@ module Mpayer
|
|
22
22
|
def create(options={})
|
23
23
|
url = "/clients"
|
24
24
|
response = Mpayer::Fetch.post(url,body: options.to_json)
|
25
|
-
client = new(options.merge!(id:response.id ,response:response))
|
25
|
+
client = new(options.merge!(id:response.id ,response:response, account: response.account.first))
|
26
26
|
end
|
27
27
|
|
28
28
|
end
|
@@ -30,7 +30,7 @@ module Mpayer
|
|
30
30
|
# Mpayer::Client.find(id:20284).account(accountsid)
|
31
31
|
def account(account_id=nil,client_id=id)
|
32
32
|
account_id ||= @account.id rescue nil
|
33
|
-
raise
|
33
|
+
raise "Arguments missing: account_id or client_id" if client_id.nil? or account_id.nil?
|
34
34
|
url = "/clients/#{client_id}/accounts/#{account_id}"
|
35
35
|
if (@account.id == account_id rescue false)
|
36
36
|
@account ||= Mpayer::Fetch.get(url)
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Mpayer
|
2
|
+
class Message < Mpayer::Endpoint
|
3
|
+
|
4
|
+
class << self
|
5
|
+
# message_attributes = {message: 'Please send me a message', destination:'0722737343,343843843'}
|
6
|
+
# Mpayer::Message.create(message_attributes)
|
7
|
+
def create(options={})
|
8
|
+
url = "/messages"
|
9
|
+
response = Mpayer::Fetch.post(url,body: options.to_json)
|
10
|
+
message = new(options.merge!(id:response.id ,response:response))
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
protected
|
16
|
+
|
17
|
+
def after_initialize
|
18
|
+
@endpoint = 'messages'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
data/lib/mpayer_ruby/fetch.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Mpayer
|
2
2
|
class Fetch
|
3
3
|
include HTTParty
|
4
|
-
|
4
|
+
|
5
5
|
base_uri "https://app.mpayer.co.ke/api/"
|
6
6
|
parser proc {|data| Hashie::Mash.new(response: (JSON.parse(data) rescue {data:data}.to_json) ).response}
|
7
7
|
format :json
|
@@ -26,7 +26,7 @@ module Mpayer
|
|
26
26
|
def save_json(response)
|
27
27
|
request_method = response.request.http_method.name.split('::').last.upcase
|
28
28
|
file_path = response.request.path.to_s
|
29
|
-
slash,model,*file_name = file_path.split(
|
29
|
+
slash,model,*file_name = file_path.split(/\/|\?/)
|
30
30
|
file_location = "lib/mpayer_ruby/support/fake_mpayer/#{model}/#{request_method}_#{file_name.join('_')}.json"
|
31
31
|
File.write(file_location, response.body)
|
32
32
|
end
|
File without changes
|
@@ -8,7 +8,7 @@ class FakeMpayer < Sinatra::Base
|
|
8
8
|
if (request.env['HTTP_X_WSSE'].empty? rescue true)
|
9
9
|
[200, {}, [{base:["Authentication Failed"]}.to_json]]
|
10
10
|
else
|
11
|
-
slash,api,model,*path = request.path_info.split(
|
11
|
+
slash,api,model,*path = request.path_info.split(/\/|\?/)
|
12
12
|
json_response 200, "#{model}/#{request.request_method}_#{path.join('_')}.json"
|
13
13
|
end
|
14
14
|
end
|
data/lib/mpayer_ruby/version.rb
CHANGED
data/lib/mpayer_ruby.rb
CHANGED
@@ -4,11 +4,12 @@ require "hashie"
|
|
4
4
|
require "mpayer_ruby/version"
|
5
5
|
require "mpayer_ruby/configuration"
|
6
6
|
require "mpayer_ruby/fetch"
|
7
|
-
require "mpayer_ruby/endpoints/
|
7
|
+
require "mpayer_ruby/endpoints/_endpoint"
|
8
8
|
require "mpayer_ruby/endpoints/client"
|
9
9
|
require "mpayer_ruby/endpoints/transaction"
|
10
10
|
require "mpayer_ruby/endpoints/account"
|
11
11
|
require "mpayer_ruby/endpoints/payable"
|
12
|
+
require "mpayer_ruby/endpoints/message"
|
12
13
|
|
13
14
|
# begin
|
14
15
|
# require "pry"
|
@@ -19,22 +20,22 @@ require "mpayer_ruby/endpoints/payable"
|
|
19
20
|
module Mpayer
|
20
21
|
class << self
|
21
22
|
attr_writer :configuration
|
22
|
-
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
def configuration
|
25
|
+
@configuration ||= Configuration.new
|
26
|
+
end
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
28
|
+
def reset
|
29
|
+
@configuration = Configuration.new
|
30
|
+
end
|
31
31
|
|
32
|
-
|
33
|
-
|
34
|
-
|
32
|
+
def setup
|
33
|
+
yield(configuration)
|
34
|
+
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
def login
|
37
|
+
Mpayer::Fetch.post('/login',post: {user_no: ENV['MPAYER_USER'],password:ENV['MPAYER_PASSWORD']}.to_json)
|
38
|
+
end
|
39
|
+
end
|
39
40
|
|
40
41
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mpayer_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kariuki Gathitu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -241,15 +241,17 @@ files:
|
|
241
241
|
- lib/mpayer-ruby.rb
|
242
242
|
- lib/mpayer_ruby.rb
|
243
243
|
- lib/mpayer_ruby/configuration.rb
|
244
|
+
- lib/mpayer_ruby/endpoints/_endpoint.rb
|
244
245
|
- lib/mpayer_ruby/endpoints/account.rb
|
245
246
|
- lib/mpayer_ruby/endpoints/client.rb
|
246
|
-
- lib/mpayer_ruby/endpoints/
|
247
|
+
- lib/mpayer_ruby/endpoints/message.rb
|
247
248
|
- lib/mpayer_ruby/endpoints/payable.rb
|
248
249
|
- lib/mpayer_ruby/endpoints/transaction.rb
|
249
250
|
- lib/mpayer_ruby/fetch.rb
|
250
251
|
- lib/mpayer_ruby/support/fake_mpayer.rb
|
251
252
|
- lib/mpayer_ruby/support/fake_mpayer/accounts/.keep
|
252
253
|
- lib/mpayer_ruby/support/fake_mpayer/clients/.keep
|
254
|
+
- lib/mpayer_ruby/support/fake_mpayer/messages/.keep
|
253
255
|
- lib/mpayer_ruby/support/fake_mpayer/payables/.keep
|
254
256
|
- lib/mpayer_ruby/support/fake_mpayer/transactions/.keep
|
255
257
|
- lib/mpayer_ruby/version.rb
|