Class: Sellsy::Api
- Inherits:
-
Object
- Object
- Sellsy::Api
- Defined in:
- lib/sellsy/api.rb
Defined Under Namespace
Classes: Configuration
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .authentication_header ⇒ Object
- .configure {|configuration| ... } ⇒ Object
- .info ⇒ Object
- .request(payload) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
7 8 9 |
# File 'lib/sellsy/api.rb', line 7 def configuration @configuration end |
Class Method Details
.authentication_header ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sellsy/api.rb', line 15 def self.authentication_header encoded_key = URI::escape(self.configuration.consumer_secret) + "&" + URI::escape(self.configuration.user_secret) now = Time.now oauth_params = { 'oauth_consumer_key' => self.configuration.consumer_token, 'oauth_token' => self.configuration.user_token, 'oauth_nonce' => Digest::MD5.hexdigest((now.to_i + rand(0..1000)).to_s), 'oauth_timestamp' => now.to_i.to_s, 'oauth_signature_method' => 'PLAINTEXT', 'oauth_version' => '1.0', 'oauth_signature' => encoded_key } return 'OAuth ' + oauth_params.map { |k, v| k + '="' + v + '"' }.join(', ') end |
.configure {|configuration| ... } ⇒ Object
10 11 12 13 |
# File 'lib/sellsy/api.rb', line 10 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
.info ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/sellsy/api.rb', line 31 def self.info command = { :method => 'Infos.getInfos', :params => {} } MultiJson.load(self.request command) end |
.request(payload) ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/sellsy/api.rb', line 40 def self.request(payload) params = { 'request' => 1, 'io_mode' => 'json', 'do_in' => payload.to_json } # RestClient.log = 'stdout' RestClient.post 'https://apifeed.sellsy.com/0/', {:request => 1, :io_mode => 'json', 'do_in' => payload.to_json, :multipart => true}, {:authorization => self.authentication_header} end |