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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 85cc42961d2039386b74a8d7a5e9316fc4d4fee3
4
- data.tar.gz: bff911054f15e336d6d9b0efc1fb23c9ba255356
3
+ metadata.gz: 34f3c4e267486342cf27db8344c64751379867d8
4
+ data.tar.gz: 3c33c72b6e397e449bde8b6580c5fa3ac2eb88b7
5
5
  SHA512:
6
- metadata.gz: 8dcf6a6a7ac6fc567a7ed7a30d950f436fc55305e60822256382f6329c566150f32794eb11ab9a0812e721622b5b58a052c9f27f3984495b6f59ac23402a88e0
7
- data.tar.gz: 30e45462922099e20ec6c16799fadfd8c0da1b33144a4aab330edb4e357aef31b55e2e1f5f53d3d673647fa91f798ebd85dfcac16a87de3bc6cac8cc8d1c0fd1
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(:post, url, @api_key, values)
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
@@ -2,6 +2,7 @@ module Pingpp
2
2
  class Transfer < APIResource
3
3
  include Pingpp::APIOperations::List
4
4
  include Pingpp::APIOperations::Create
5
+ include Pingpp::APIOperations::Update
5
6
 
6
7
  def self.url
7
8
  '/v1/transfers'
@@ -1,3 +1,3 @@
1
1
  module Pingpp
2
- VERSION = '2.0.14'
2
+ VERSION = '2.0.15'
3
3
  end
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 == :post, payload).update(headers),
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, is_post=false, data=nil)
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 => is_post ? 'application/json' : 'application/x-www-form-urlencoded'
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 is_post && private_key && data
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.14
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-07-26 00:00:00.000000000 Z
11
+ date: 2016-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client