api_connector 0.1.4.1 → 0.1.4.2
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/.gitignore +2 -2
- data/Gemfile.lock +4 -2
- data/api_connector.gemspec +1 -0
- data/lib/api_connector/api_connector.rb +15 -18
- data/lib/api_connector/version.rb +1 -1
- data/lib/api_connector.rb +1 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ced916b5cc6eb12c92ce2e70f701c514618f153d
|
4
|
+
data.tar.gz: 7d7497eb7cd112bea0bb62fff10260cea191452c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bd4bac3e8db943b0f08d3b60e680013329f1bea24ad4baf474cf7ea95a6a31e88d5713691325ecb2862219962186b4265660a1008e3ab0ca263ea0410b17f87
|
7
|
+
data.tar.gz: 1dfb891a653c53289d1f2bbbbf4766d4822b35f039ebed65bd65dde96c7a3cfd319d150452d59090620dc416ca55cdddf2428bfcb1c6719b54f27f7020821f06
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
api_connector (0.1.1)
|
4
|
+
api_connector (0.1.4.1)
|
5
5
|
activesupport (~> 4.2.4)
|
6
|
-
|
6
|
+
addressable (~> 2.3.8)
|
7
|
+
rest-client (~> 1.8.0)
|
7
8
|
|
8
9
|
GEM
|
9
10
|
remote: https://rubygems.org/
|
@@ -14,6 +15,7 @@ GEM
|
|
14
15
|
minitest (~> 5.1)
|
15
16
|
thread_safe (~> 0.3, >= 0.3.4)
|
16
17
|
tzinfo (~> 1.1)
|
18
|
+
addressable (2.3.8)
|
17
19
|
diff-lcs (1.2.5)
|
18
20
|
domain_name (0.5.20160309)
|
19
21
|
unf (>= 0.0.5, < 1.0.0)
|
data/api_connector.gemspec
CHANGED
@@ -4,9 +4,9 @@ module Connectors #:nodoc:
|
|
4
4
|
# === Heading
|
5
5
|
# This class has all the common logic from <b>api connectors</b>.
|
6
6
|
class ApiConnector
|
7
|
-
attr_reader :logger, :api_client_id, :api_domain, :
|
8
|
-
:
|
9
|
-
:
|
7
|
+
attr_reader :logger, :api_client_id, :api_domain, :api_domain_format,
|
8
|
+
:api_headers_token, :connection_protocol, :headers, :code, :cookies,
|
9
|
+
:cookie_jar, :request, :body
|
10
10
|
|
11
11
|
def initialize(options = {}) #:notnew:
|
12
12
|
options.symbolize_keys!
|
@@ -60,19 +60,16 @@ module Connectors #:nodoc:
|
|
60
60
|
|
61
61
|
url = (method == :get || method == :delete) ? url(endpoint,params) : url(endpoint)
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
rescue RestClient::RequestTimeout
|
74
|
-
{ status: '400', message: "RestClient timeout" }
|
75
|
-
end
|
63
|
+
RestClient::Request.execute(method: method,
|
64
|
+
url: url,
|
65
|
+
headers: header(args[:headers]),
|
66
|
+
payload: params || {}
|
67
|
+
) do |response, request, result|
|
68
|
+
#status = response.code == 200 ? :debug : :error
|
69
|
+
#print(status, request, response.body)
|
70
|
+
parse(response, endpoint)
|
71
|
+
end
|
72
|
+
|
76
73
|
end
|
77
74
|
|
78
75
|
def parse(response, endpoint = nil)
|
@@ -123,9 +120,9 @@ module Connectors #:nodoc:
|
|
123
120
|
end
|
124
121
|
|
125
122
|
def url_constructor endpoint, hash
|
126
|
-
url = "#{@connection_protocol}://#{format(@api_domain)}/#{format(@prefix)}" <<
|
123
|
+
url = "#{@connection_protocol}://#{format(@api_domain)}/#{format(@prefix)}" << "/#{format(endpoint)}"
|
127
124
|
url << ("?#{parametrize(hash)}") unless hash.empty?
|
128
|
-
url
|
125
|
+
Addressable::URI.parse(url).normalize.to_str
|
129
126
|
end
|
130
127
|
|
131
128
|
def parametrize hash
|
data/lib/api_connector.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: api_connector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.4.
|
4
|
+
version: 0.1.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Manuel Rodulfo
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-03-
|
11
|
+
date: 2016-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - ~>
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: 1.8.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: addressable
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 2.3.8
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 2.3.8
|
83
97
|
description: API Connector main class for wrapping RestClient functionality
|
84
98
|
email:
|
85
99
|
- jm.rodulfo.salcedo@gmail.com
|