plate_api 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +2 -2
- data/lib/plate_api/get_request.rb +15 -2
- data/lib/plate_api/request.rb +12 -14
- data/lib/plate_api/version.rb +1 -1
- metadata +1 -2
- data/.byebug_history +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 600f799a54373ccf8b006bddb1d97e268d2ec9a427551fce6022bf1faed41e67
|
4
|
+
data.tar.gz: 775cbeedcfe25f9c77705388403be50a030b6c1350c46195026ad00e148a234f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4628865a07f17d67dc5bce69462f007a01143a46039bd133b30e9f16bccde2f925e4bd94416d5ab473d0a9fe8744f08a02b4b5ce37a82eeaa9c04f7516a6e88b
|
7
|
+
data.tar.gz: e6b6f0e6a65b2e4c3d7e1d56a38b1498a0631a58365ba3eef10cfde24fe77c98cbbec264c743a83dd0a1e2d290219096593b8ba47b0884c58a829d098ac1993a
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
plate_api (1.2.
|
4
|
+
plate_api (1.2.8)
|
5
5
|
faraday (~> 1.0.1)
|
6
6
|
mime-types (~> 3.3.1)
|
7
7
|
|
@@ -32,7 +32,7 @@ GEM
|
|
32
32
|
concurrent-ruby (~> 1.0)
|
33
33
|
mime-types (3.3.1)
|
34
34
|
mime-types-data (~> 3.2015)
|
35
|
-
mime-types-data (3.
|
35
|
+
mime-types-data (3.2022.0105)
|
36
36
|
minitest (5.14.1)
|
37
37
|
multipart-post (2.1.1)
|
38
38
|
public_suffix (4.0.5)
|
@@ -3,14 +3,27 @@ module PlateApi
|
|
3
3
|
def initialize(public_key, secret, path, parameters={}, custom_server=nil)
|
4
4
|
super(public_key, secret, "GET", path, custom_server)
|
5
5
|
|
6
|
-
|
7
|
-
@url_parameters = sorted_params.map{|x| "#{x[0]}=#{x[1]}"}.join("&")
|
6
|
+
@url_parameters = build_url_parameters(parameters)
|
8
7
|
end
|
9
8
|
|
10
9
|
def url_path
|
11
10
|
"#{@path}?#{@url_parameters}"
|
12
11
|
end
|
13
12
|
|
13
|
+
# Translate a Hash of url parameters to a query string
|
14
|
+
def build_url_parameters(parameters)
|
15
|
+
sorted_params = parameters.to_a.sort_by{|x| x[0]}
|
16
|
+
query_string = sorted_params.map do |key, value|
|
17
|
+
if value.is_a? Array
|
18
|
+
value.map{|subvalue| "#{key}[]=#{subvalue}"}.join("&")
|
19
|
+
else
|
20
|
+
"#{key}=#{value}"
|
21
|
+
end
|
22
|
+
end.join("&")
|
23
|
+
|
24
|
+
query_string
|
25
|
+
end
|
26
|
+
|
14
27
|
def url_parameters
|
15
28
|
@url_parameters
|
16
29
|
end
|
data/lib/plate_api/request.rb
CHANGED
@@ -12,7 +12,7 @@ module PlateApi
|
|
12
12
|
HttpAdapter = Faraday.default_adapter
|
13
13
|
|
14
14
|
def initialize(public_key, secret, method, path, custom_server = nil)
|
15
|
-
base_api_endpoint = custom_server
|
15
|
+
base_api_endpoint = custom_server || DefaultApiBaseEndpoint
|
16
16
|
|
17
17
|
@connection = ::Faraday.new(url: base_api_endpoint, request: { timeout: 900 }) do |faraday|
|
18
18
|
extra_builder_options(faraday)
|
@@ -33,12 +33,12 @@ module PlateApi
|
|
33
33
|
extra_request_options(request)
|
34
34
|
end
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
36
|
+
case response_type
|
37
|
+
when :raw
|
38
|
+
response.body
|
39
|
+
when :json
|
40
|
+
JSON.parse(response.body)
|
41
|
+
end
|
42
42
|
end
|
43
43
|
|
44
44
|
def request_date
|
@@ -50,9 +50,9 @@ module PlateApi
|
|
50
50
|
"#{@connection.host}\n" +
|
51
51
|
"#{@connection.path_prefix}/#{@path}\n" +
|
52
52
|
"#{url_parameters}\n" +
|
53
|
-
|
53
|
+
request_date.to_s
|
54
54
|
signature = Base64.strict_encode64(OpenSSL::HMAC.digest("SHA512", @secret, string_to_sign))
|
55
|
-
|
55
|
+
"hmac #{@public_key}:#{signature}"
|
56
56
|
end
|
57
57
|
|
58
58
|
private
|
@@ -65,14 +65,12 @@ module PlateApi
|
|
65
65
|
""
|
66
66
|
end
|
67
67
|
|
68
|
-
def extra_request_options(request)
|
69
|
-
end
|
68
|
+
def extra_request_options(request); end
|
70
69
|
|
71
|
-
def extra_builder_options(request)
|
72
|
-
end
|
70
|
+
def extra_builder_options(request); end
|
73
71
|
|
74
72
|
def strip_path(path)
|
75
|
-
path.gsub(
|
73
|
+
path.gsub(%r{^/|/$}, "")
|
76
74
|
end
|
77
75
|
end
|
78
76
|
end
|
data/lib/plate_api/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plate_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Kortleven
|
@@ -161,7 +161,6 @@ executables: []
|
|
161
161
|
extensions: []
|
162
162
|
extra_rdoc_files: []
|
163
163
|
files:
|
164
|
-
- ".byebug_history"
|
165
164
|
- ".gitignore"
|
166
165
|
- ".rspec"
|
167
166
|
- ".travis.yml"
|
data/.byebug_history
DELETED
@@ -1,48 +0,0 @@
|
|
1
|
-
c
|
2
|
-
MimeMagic.by_path(@full_path)
|
3
|
-
MimemMagic.by_path(@full_path)
|
4
|
-
@file
|
5
|
-
@full_path
|
6
|
-
c
|
7
|
-
attributes
|
8
|
-
m
|
9
|
-
c
|
10
|
-
attributes
|
11
|
-
m
|
12
|
-
c;m
|
13
|
-
m
|
14
|
-
c
|
15
|
-
m
|
16
|
-
c
|
17
|
-
attributes
|
18
|
-
s
|
19
|
-
up
|
20
|
-
s
|
21
|
-
up
|
22
|
-
s
|
23
|
-
new_object.attributes
|
24
|
-
c
|
25
|
-
new_object.attributes
|
26
|
-
new_object
|
27
|
-
c
|
28
|
-
full_path
|
29
|
-
c
|
30
|
-
n
|
31
|
-
val.is_a? File
|
32
|
-
val
|
33
|
-
c
|
34
|
-
val.is_a? File
|
35
|
-
val
|
36
|
-
parameters
|
37
|
-
c
|
38
|
-
site.id
|
39
|
-
site = subject.find(5)
|
40
|
-
c
|
41
|
-
site.class.superclass
|
42
|
-
site.class.methods
|
43
|
-
site.class
|
44
|
-
site.methods.class
|
45
|
-
site.methods - Object.methods
|
46
|
-
site.methods
|
47
|
-
site.id
|
48
|
-
site = subject.find(5)
|