kalixa_api 0.1.1 → 0.1.3
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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +10 -6
- data/lib/kalixa_api.rb +7 -6
- data/lib/kalixa_api/v3/http_service.rb +8 -10
- data/lib/kalixa_api/v4/http_service.rb +13 -14
- data/lib/kalixa_api/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25b61f84afd6c64cad085925094d2686af725c44
|
4
|
+
data.tar.gz: da10cbf933be7c1930a46db8d410d56ed8d30ec8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ebf644cbc18a069d7a7b4049bb7840cff5d504ac919515676425c578781e1ae0c4b397fa7f164eaaae39000c2ef74b0b94633e815a32a73e5ce56d021b24960d
|
7
|
+
data.tar.gz: 370e55b6c1513d0ff372a6963e6e29691ad2dfbc24933cc9b8c23724065001c53da30d02bcb2ad90eb3dbd04628ffa1615eca3e2c664e9b8fe8abc2318f231cd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -20,17 +20,21 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
Initialize the the gem by setting your username, password and api mode.
|
24
|
+
|
25
|
+
Example:
|
26
|
+
|
27
|
+
config/initializers/kalixa_api.rb
|
24
28
|
|
25
29
|
```ruby
|
26
30
|
|
27
|
-
|
28
|
-
|
31
|
+
KalixaApi.api_user ||= ENV['KALIXA_API_USER']
|
32
|
+
KalixaApi.api_password ||= ENV['KALIXA_API_PASSWORD']
|
29
33
|
|
30
|
-
|
31
|
-
|
34
|
+
KalixaApi.test_api_user ||= ENV['TEST_KALIXA_API_USER']
|
35
|
+
KalixaApi.test_api_password ||= ENV['TEST_KALIXA_API_PASSWORD']
|
32
36
|
|
33
|
-
|
37
|
+
KalixaApi.api_mode ||= (ENV['KALIXA_API_MODE'].downcase == 'production') rescue false
|
34
38
|
|
35
39
|
```
|
36
40
|
|
data/lib/kalixa_api.rb
CHANGED
@@ -11,14 +11,15 @@ require 'kalixa_api/v4/merchant'
|
|
11
11
|
|
12
12
|
module KalixaApi
|
13
13
|
class << self
|
14
|
-
attr_accessor :
|
14
|
+
attr_accessor :api_user, :api_password, :test_api_user, :test_api_password, :api_mode
|
15
15
|
end
|
16
16
|
|
17
|
-
self.
|
18
|
-
self.
|
17
|
+
self.api_user ||= ENV['KALIXA_API_USER']
|
18
|
+
self.api_password ||= ENV['KALIXA_API_PASSWORD']
|
19
19
|
|
20
|
-
self.
|
21
|
-
self.
|
20
|
+
self.test_api_user ||= ENV['TEST_KALIXA_API_USER']
|
21
|
+
self.test_api_password ||= ENV['TEST_KALIXA_API_PASSWORD']
|
22
|
+
|
23
|
+
self.api_mode ||= (ENV['KALIXA_API_MODE'].downcase == 'production') rescue false
|
22
24
|
|
23
|
-
self.api_mode ||= (ENV['KALIXA_API_MODE'].downcase == 'production')
|
24
25
|
end
|
@@ -2,21 +2,20 @@ module KalixaApi
|
|
2
2
|
module V3
|
3
3
|
class HttpService
|
4
4
|
|
5
|
-
attr_accessor :
|
6
|
-
|
7
|
-
def initialize(username: nil, password: nil)
|
8
|
-
@kalixa_api_user = kalixa_api_user || KalixaApi.kalixa_api_user
|
9
|
-
@kalixa_api_password = kalixa_api_password || KalixaApi.kalixa_api_password
|
10
|
-
@test_kalixa_api_user = test_kalixa_api_user || KalixaApi.test_kalixa_api_user
|
11
|
-
@test_kalixa_api_password = test_kalixa_api_password || KalixaApi.test_kalixa_api_password
|
5
|
+
attr_accessor :api_user, :api_password, :test_api_user, :test_api_password, :api_mode
|
12
6
|
|
7
|
+
def initialize(api_user: nil, api_password: nil, test_api_user: nil, test_api_password: nil, api_mode: nil)
|
8
|
+
@api_user = api_user || KalixaApi.api_user
|
9
|
+
@api_password = api_password || KalixaApi.api_password
|
10
|
+
@test_api_user = test_api_user || KalixaApi.test_api_user
|
11
|
+
@test_api_password = test_api_password || KalixaApi.test_api_password
|
13
12
|
@api_mode = api_mode || KalixaApi.api_mode
|
14
13
|
end
|
15
14
|
|
16
15
|
def connection
|
17
16
|
@connection ||= begin
|
18
17
|
Faraday.new(:url => 'https://api.kalixa.com') do |faraday|
|
19
|
-
faraday.basic_auth(@
|
18
|
+
faraday.basic_auth(@api_user , @api_password)
|
20
19
|
faraday.adapter Faraday.default_adapter
|
21
20
|
end
|
22
21
|
end
|
@@ -25,7 +24,7 @@ module KalixaApi
|
|
25
24
|
def test_conection
|
26
25
|
@connection ||= begin
|
27
26
|
Faraday.new(:url => 'https://api.test.kalixa.com') do |faraday|
|
28
|
-
faraday.basic_auth(@
|
27
|
+
faraday.basic_auth(@test_api_user, @test_api_password)
|
29
28
|
faraday.adapter Faraday.default_adapter
|
30
29
|
end
|
31
30
|
end
|
@@ -45,7 +44,6 @@ module KalixaApi
|
|
45
44
|
req.body = data.to_xml(:root => xml_root)
|
46
45
|
end
|
47
46
|
end
|
48
|
-
|
49
47
|
end
|
50
48
|
|
51
49
|
def get_request(url, data, xml_root)
|
@@ -2,14 +2,13 @@ module KalixaApi
|
|
2
2
|
module V4
|
3
3
|
class HttpService
|
4
4
|
|
5
|
-
attr_accessor :
|
6
|
-
|
7
|
-
def initialize(username: nil, password: nil)
|
8
|
-
@kalixa_api_user = kalixa_api_user || KalixaApi.kalixa_api_user
|
9
|
-
@kalixa_api_password = kalixa_api_password || KalixaApi.kalixa_api_password
|
10
|
-
@test_kalixa_api_user = test_kalixa_api_user || KalixaApi.test_kalixa_api_user
|
11
|
-
@test_kalixa_api_password = test_kalixa_api_password || KalixaApi.test_kalixa_api_password
|
5
|
+
attr_accessor :api_user, :api_password, :test_api_user, :test_api_password, :api_mode
|
12
6
|
|
7
|
+
def initialize(api_user: nil, api_password: nil, test_api_user: nil, test_api_password: nil, api_mode: nil)
|
8
|
+
@api_user = api_user || KalixaApi.api_user
|
9
|
+
@api_password = api_password || KalixaApi.api_password
|
10
|
+
@test_api_user = test_api_user || KalixaApi.test_api_user
|
11
|
+
@test_api_password = test_api_password || KalixaApi.test_api_password
|
13
12
|
@api_mode = api_mode || KalixaApi.api_mode
|
14
13
|
end
|
15
14
|
|
@@ -17,7 +16,7 @@ module KalixaApi
|
|
17
16
|
@connection ||= begin
|
18
17
|
Faraday.new(:url => 'https://payments.kalixa.com') do |faraday|
|
19
18
|
faraday.response :json, :content_type => /\bjson$/
|
20
|
-
faraday.basic_auth(@
|
19
|
+
faraday.basic_auth(@api_user , @api_password)
|
21
20
|
faraday.adapter Faraday.default_adapter
|
22
21
|
end
|
23
22
|
end
|
@@ -27,7 +26,7 @@ module KalixaApi
|
|
27
26
|
@test_connection ||= begin
|
28
27
|
Faraday.new(:url => 'https://payments.test.kalixa.com') do |faraday|
|
29
28
|
faraday.response :json, :content_type => /\bjson$/
|
30
|
-
faraday.basic_auth(@
|
29
|
+
faraday.basic_auth(@test_api_user, @test_api_password)
|
31
30
|
faraday.adapter Faraday.default_adapter
|
32
31
|
end
|
33
32
|
end
|
@@ -35,13 +34,13 @@ module KalixaApi
|
|
35
34
|
|
36
35
|
def post_request(url, data = {})
|
37
36
|
if @api_mode
|
38
|
-
|
37
|
+
connection.post do |req|
|
39
38
|
req.url url
|
40
39
|
req.headers['Content-Type'] = 'application/json'
|
41
40
|
req.body = data.to_json
|
42
41
|
end
|
43
42
|
else
|
44
|
-
|
43
|
+
test_conection.post do |req|
|
45
44
|
req.url url
|
46
45
|
req.headers['Content-Type'] = 'application/json'
|
47
46
|
req.body = data.to_json
|
@@ -51,19 +50,19 @@ module KalixaApi
|
|
51
50
|
|
52
51
|
def get_request(url, data = {})
|
53
52
|
if @api_mode
|
54
|
-
|
53
|
+
connection.get do |req|
|
55
54
|
req.url url
|
56
55
|
req.headers['Content-Type'] = 'application/json'
|
56
|
+
req.body = data.to_json
|
57
57
|
end
|
58
58
|
else
|
59
|
-
|
59
|
+
test_conection.get do |req|
|
60
60
|
req.url url
|
61
61
|
req.headers['Content-Type'] = 'application/json'
|
62
62
|
req.body = data.to_json
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
67
66
|
end
|
68
67
|
end
|
69
68
|
end
|
data/lib/kalixa_api/version.rb
CHANGED