pingpp 2.0.14 → 2.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pingpp/api_operations/update.rb +12 -1
- data/lib/pingpp/transfer.rb +1 -0
- data/lib/pingpp/version.rb +1 -1
- data/lib/pingpp.rb +5 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34f3c4e267486342cf27db8344c64751379867d8
|
4
|
+
data.tar.gz: 3c33c72b6e397e449bde8b6580c5fa3ac2eb88b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ae7a70101fe62b04175a3dca29282d2f842529d4e923ab927c5c4089563c80742381ffc859264f86d2fa22b6bac2a31a7a09b28483ca82e4c9a190cd07905c
|
7
|
+
data.tar.gz: 2cf75ed4eabbb83fd891c4f7a106d9a68bf4a3864cde4ae41b6dc72b298d6d646b4000f638b245131ac94c5de20e082880233d457322ba68c24637a6517e317d
|
@@ -1,6 +1,13 @@
|
|
1
1
|
module Pingpp
|
2
2
|
module APIOperations
|
3
3
|
module Update
|
4
|
+
module ClassMethods
|
5
|
+
def update(id, params={}, api_key=nil)
|
6
|
+
response, opts = Pingpp.request(:put, "#{self.url}/#{id}", api_key, params)
|
7
|
+
Util.convert_to_pingpp_object(response, opts)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
4
11
|
def save(opts={})
|
5
12
|
values = serialize_params(self).merge(opts)
|
6
13
|
|
@@ -11,7 +18,7 @@ module Pingpp
|
|
11
18
|
if values.length > 0
|
12
19
|
values.delete(:id)
|
13
20
|
|
14
|
-
response, api_key = Pingpp.request(:
|
21
|
+
response, api_key = Pingpp.request(:put, url, @api_key, values)
|
15
22
|
refresh_from(response, api_key)
|
16
23
|
end
|
17
24
|
self
|
@@ -52,6 +59,10 @@ module Pingpp
|
|
52
59
|
obj
|
53
60
|
end
|
54
61
|
end
|
62
|
+
|
63
|
+
def self.included(base)
|
64
|
+
base.extend(ClassMethods)
|
65
|
+
end
|
55
66
|
end
|
56
67
|
end
|
57
68
|
end
|
data/lib/pingpp/transfer.rb
CHANGED
data/lib/pingpp/version.rb
CHANGED
data/lib/pingpp.rb
CHANGED
@@ -118,7 +118,7 @@ module Pingpp
|
|
118
118
|
payload = JSON.generate(params)
|
119
119
|
end
|
120
120
|
|
121
|
-
request_opts.update(:headers => request_headers(api_key, method.to_s.downcase.to_sym
|
121
|
+
request_opts.update(:headers => request_headers(api_key, method.to_s.downcase.to_sym, payload).update(headers),
|
122
122
|
:method => method, :open_timeout => 30,
|
123
123
|
:payload => payload, :url => url, :timeout => 80)
|
124
124
|
|
@@ -175,11 +175,12 @@ module Pingpp
|
|
175
175
|
map { |k,v| "#{k}=#{Util.url_encode(v)}" }.join('&')
|
176
176
|
end
|
177
177
|
|
178
|
-
def self.request_headers(api_key,
|
178
|
+
def self.request_headers(api_key, method_sym, data=nil)
|
179
|
+
post_or_put = (method_sym == :post or method_sym == :put)
|
179
180
|
headers = {
|
180
181
|
:user_agent => "Pingpp/v1 RubyBindings/#{Pingpp::VERSION}",
|
181
182
|
:authorization => "Bearer #{api_key}",
|
182
|
-
:content_type =>
|
183
|
+
:content_type => post_or_put ? 'application/json' : 'application/x-www-form-urlencoded'
|
183
184
|
}
|
184
185
|
|
185
186
|
headers[:pingplusplus_version] = api_version if api_version
|
@@ -192,7 +193,7 @@ module Pingpp
|
|
192
193
|
:error => "#{e} (#{e.class})")
|
193
194
|
end
|
194
195
|
|
195
|
-
if
|
196
|
+
if post_or_put && private_key && data
|
196
197
|
signature = sign_request(data, private_key)
|
197
198
|
headers.update(:pingplusplus_signature => signature)
|
198
199
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pingpp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Xufeng Weng
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-08-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|