Class: Blingee::API
- Inherits:
-
Relax::Service
- Object
- Relax::Service
- Blingee::API
- Defined in:
- lib/blingee/api.rb
Overview
:nodoc:all
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.generate_signature(parameters, secret) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/blingee/api.rb', line 7 def self.generate_signature(parameters, secret) Digest::MD5.hexdigest(parameters. sort { |a,b| a.to_s <=> b.to_s }. map { |k,v| k.to_s + '=' + (v.to_s || '') }. concat([secret]). join('&')) end |
Instance Method Details
#request(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/blingee/api.rb', line 15 def request(&block) begin yield rescue RestClient::RequestTimeout raise Blingee::ConnectionError.from_exception($!) rescue RestClient::RequestFailed case $!.http_code when 403 raise Blingee::AuthenticationFailure.from_exception_with_response($!, $!.response) else raise Blingee::ErrorWithResponse.from_exception_with_response($!, $!.response) end rescue raise Blingee::Error.from_exception($!) end end |