paypoint-blue 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 82b114473871861140e8796d61ac85a852a273d2
|
4
|
+
data.tar.gz: 1034d197286e603f13b8f5b409db165c89ce5edb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 721d6ef451f97773e72f2fef33a9895d9a0c624ac527ffad46320e14928d23814f2a29a6ea30c33233b780a67f39b08161e59d9dfeaeb6c60f1141321af5f85d
|
7
|
+
data.tar.gz: 041fdf89fdf82280b6459a32f1d7a0992d28d3a4b2f2057b4ed316d01854fe8a9cfb598e1a0a201484382fe79ad531af1b15e376259f64dbbafce2259eaf40e9
|
data/lib/paypoint/blue/base.rb
CHANGED
@@ -60,11 +60,11 @@ module PayPoint
|
|
60
60
|
api_password: ENV['BLUE_API_PASSWORD'],
|
61
61
|
**options)
|
62
62
|
|
63
|
-
@endpoint =
|
63
|
+
@endpoint = get_endpoint_or_override_with(endpoint)
|
64
64
|
|
65
|
-
@inst_id = inst_id or raise ArgumentError,
|
66
|
-
@api_id = api_id or raise ArgumentError,
|
67
|
-
@api_password = api_password or raise ArgumentError,
|
65
|
+
@inst_id = inst_id or raise ArgumentError, 'missing inst_id'
|
66
|
+
@api_id = api_id or raise ArgumentError, 'missing api_id'
|
67
|
+
@api_password = api_password or raise ArgumentError, 'missing api_password'
|
68
68
|
|
69
69
|
options[:url] = @endpoint
|
70
70
|
@options = options
|
@@ -78,8 +78,12 @@ module PayPoint
|
|
78
78
|
|
79
79
|
attr_reader :inst_id, :options
|
80
80
|
|
81
|
+
def get_endpoint_or_override_with(endpoint)
|
82
|
+
self.class.const_get('ENDPOINTS').fetch(endpoint, endpoint.to_s)
|
83
|
+
end
|
84
|
+
|
81
85
|
def client_options
|
82
|
-
options.select { |k,
|
86
|
+
options.select { |k, _| Faraday::ConnectionOptions.members.include?(k) }
|
83
87
|
end
|
84
88
|
|
85
89
|
def build_client
|
@@ -114,8 +118,6 @@ module PayPoint
|
|
114
118
|
f.adapter Faraday.default_adapter
|
115
119
|
end
|
116
120
|
end
|
117
|
-
|
118
121
|
end
|
119
|
-
|
120
122
|
end
|
121
123
|
end
|
data/lib/paypoint/blue/error.rb
CHANGED
@@ -11,7 +11,11 @@ module PayPoint
|
|
11
11
|
end
|
12
12
|
|
13
13
|
module ClassMethods
|
14
|
-
|
14
|
+
def shortcuts
|
15
|
+
@shortcuts ||= {}
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_writer :shortcuts
|
15
19
|
|
16
20
|
# Define a payload shortcut
|
17
21
|
#
|
@@ -27,11 +31,10 @@ module PayPoint
|
|
27
31
|
# @param [Symbol] key the shortcut key
|
28
32
|
# @param [String] path a path into the payload with segments
|
29
33
|
# separated by dots (e.g. +'transaction.money.amount.fixed'+)
|
30
|
-
def shortcut(key, path=nil)
|
34
|
+
def shortcut(key, path = nil)
|
31
35
|
if path.nil?
|
32
|
-
shortcuts
|
36
|
+
shortcuts[key]
|
33
37
|
else
|
34
|
-
self.shortcuts ||= {}
|
35
38
|
shortcuts[key] = path
|
36
39
|
end
|
37
40
|
end
|
@@ -83,8 +86,6 @@ module PayPoint
|
|
83
86
|
def interpolate_values(value, payload)
|
84
87
|
value.gsub(/%(\w+)%/) {|m| payload[$1.to_sym] || m}
|
85
88
|
end
|
86
|
-
|
87
89
|
end
|
88
|
-
|
89
90
|
end
|
90
91
|
end
|
@@ -28,13 +28,23 @@ module PayPoint
|
|
28
28
|
else
|
29
29
|
raise Error::Client, response_values(env)
|
30
30
|
end
|
31
|
-
elsif env
|
31
|
+
elsif not_found?(env)
|
32
|
+
raise Error::NotFound, response_values(env)
|
33
|
+
elsif client_error?(env)
|
32
34
|
raise Error::Client, response_values(env)
|
33
35
|
end
|
34
36
|
end
|
35
37
|
|
36
38
|
private
|
37
39
|
|
40
|
+
def not_found?(env)
|
41
|
+
env.status == 404 && env.body[:reason_code] == "A400"
|
42
|
+
end
|
43
|
+
|
44
|
+
def client_error?(env)
|
45
|
+
env.status >= 400
|
46
|
+
end
|
47
|
+
|
38
48
|
def fetch_outcome(env)
|
39
49
|
env.body.is_a?(Hash) && env.body[:outcome]
|
40
50
|
end
|
@@ -46,8 +56,6 @@ module PayPoint
|
|
46
56
|
body: env.body
|
47
57
|
}
|
48
58
|
end
|
49
|
-
|
50
59
|
end
|
51
|
-
|
52
60
|
end
|
53
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paypoint-blue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laszlo Bacsi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-05-
|
11
|
+
date: 2015-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|