nuorder 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +99 -0
- data/Rakefile +5 -0
- data/lib/nuorder.rb +27 -0
- data/lib/nuorder/client.rb +100 -0
- data/lib/nuorder/client/oauth.rb +50 -0
- data/lib/nuorder/configurable.rb +37 -0
- data/lib/nuorder/default.rb +39 -0
- data/lib/nuorder/version.rb +3 -0
- data/nuorder.gemspec +32 -0
- data/spec/nuorder/client_spec.rb +135 -0
- data/spec/nuorder_spec.rb +48 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/shared_examples.rb +12 -0
- data/spec/support/vcr.rb +16 -0
- data/spec/vcr/Nuorder_Client/_api_initiate/returns_temp_oauth_token_and_oauth_token_secret_from_API.yml +46 -0
- data/spec/vcr/Nuorder_Client/_get/raises_error_if_NuOrder_api_returns_error.yml +44 -0
- data/spec/vcr/Nuorder_Client/_get_oauth_token/returns_real_oauth_token_and_oauth_token_secret_from_API.yml +46 -0
- metadata +200 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: f919892f8872490de613adf403fa7464c506bda7
         | 
| 4 | 
            +
              data.tar.gz: 85b9320a67b7276d7dfb0bee612542d0b32515bb
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: a78b3002cd697926d2a9b785d6f0ccb9d288b30b8adb2b5bc2cc062a4ea938221010e24b02e1397ef06aff722524b49040482fc7669712acdf5d8c30d5e4d71d
         | 
| 7 | 
            +
              data.tar.gz: 4a10ab611a5fe08961df027139196715513e3372af48ce40dc72a274364e26a3f64bfc245d289a4a93932388af5e76ca1165d6f2d010fc5007664954e3acc998
         | 
    
        data/.gitignore
    ADDED
    
    
    
        data/.travis.yml
    ADDED
    
    
    
        data/CHANGELOG.md
    ADDED
    
    
    
        data/Gemfile
    ADDED
    
    
    
        data/LICENSE.txt
    ADDED
    
    | @@ -0,0 +1,22 @@ | |
| 1 | 
            +
            Copyright (c) 2015 Springboard Retail
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            MIT License
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Permission is hereby granted, free of charge, to any person obtaining
         | 
| 6 | 
            +
            a copy of this software and associated documentation files (the
         | 
| 7 | 
            +
            "Software"), to deal in the Software without restriction, including
         | 
| 8 | 
            +
            without limitation the rights to use, copy, modify, merge, publish,
         | 
| 9 | 
            +
            distribute, sublicense, and/or sell copies of the Software, and to
         | 
| 10 | 
            +
            permit persons to whom the Software is furnished to do so, subject to
         | 
| 11 | 
            +
            the following conditions:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            The above copyright notice and this permission notice shall be
         | 
| 14 | 
            +
            included in all copies or substantial portions of the Software.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
            THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
         | 
| 17 | 
            +
            EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
         | 
| 18 | 
            +
            MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
         | 
| 19 | 
            +
            NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
         | 
| 20 | 
            +
            LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
         | 
| 21 | 
            +
            OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
         | 
| 22 | 
            +
            WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
         | 
    
        data/README.md
    ADDED
    
    | @@ -0,0 +1,99 @@ | |
| 1 | 
            +
            # NuORDER
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            [](https://travis-ci.org/springboardretail/nuorder)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem that wraps up the communication with the API services from [NuORDER](http://www.nuorder.com/)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            [Faraday](https://github.com/lostisland/faraday) and [Excon](https://github.com/excon/excon) are used for creating persistent connections.
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            ## Installation
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            Add this line to your application's Gemfile:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
            ```ruby
         | 
| 14 | 
            +
            gem 'nuorder'
         | 
| 15 | 
            +
            ```
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            And then execute:
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                $ bundle
         | 
| 20 | 
            +
             | 
| 21 | 
            +
            Or install it yourself as:
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                $ gem install nuorder
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            ## Usage
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            ### Configuration
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            The following options are available when configuring NuORDER:
         | 
| 30 | 
            +
             | 
| 31 | 
            +
            1. `app_name` Default: `'Springboard Retail'`
         | 
| 32 | 
            +
            2. `api_endpoint` Default: `'http://buyer.nuorder.com'`
         | 
| 33 | 
            +
            3. `oauth_consumer_key`
         | 
| 34 | 
            +
            4. `oauth_consumer_secret`
         | 
| 35 | 
            +
            5. `oauth_token`
         | 
| 36 | 
            +
            6. `oauth_token_secret`
         | 
| 37 | 
            +
            7. `oauth_callback` Default: `'oob'`
         | 
| 38 | 
            +
                * NuORDER will POST the callback the `oauth_verifier` token.
         | 
| 39 | 
            +
                * If the callback is set to `'oob'`, the `oauth_verifier` token must be supplied manually by the user. 
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            #### Example
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            ```ruby
         | 
| 44 | 
            +
            Nuorder.configure do |config|
         | 
| 45 | 
            +
              config.oauth_consumer_key = 'key'
         | 
| 46 | 
            +
              config.oauth_consumer_secret = 'key'
         | 
| 47 | 
            +
              config.oauth_token = 'key'
         | 
| 48 | 
            +
              config.oauth_token_secret = 'key'
         | 
| 49 | 
            +
            end
         | 
| 50 | 
            +
            ````
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            or
         | 
| 53 | 
            +
             | 
| 54 | 
            +
            ```
         | 
| 55 | 
            +
            client = Nuorder::Client.new(oauth_token: 'key', oauth_token_secret: 'key')
         | 
| 56 | 
            +
            ```
         | 
| 57 | 
            +
             | 
| 58 | 
            +
            ### Authorization (OAuth 1.0)
         | 
| 59 | 
            +
             | 
| 60 | 
            +
            NuORDER uses OAuth 1.0 for authorization.
         | 
| 61 | 
            +
             | 
| 62 | 
            +
            To get the oauth tokens the following methods must be called:
         | 
| 63 | 
            +
             | 
| 64 | 
            +
            1. `Nuorder.api_initiate`
         | 
| 65 | 
            +
              * An inital call will be made in order to get the temporary tokens.
         | 
| 66 | 
            +
            2. `Nuorder.get_oauth_token(oauth_verifier)`
         | 
| 67 | 
            +
              * Call for getting the permanent tokens.
         | 
| 68 | 
            +
              * `oauth_verifier` must be supplied. 
         | 
| 69 | 
            +
             | 
| 70 | 
            +
            Retrieve tokens:
         | 
| 71 | 
            +
             | 
| 72 | 
            +
            ```ruby
         | 
| 73 | 
            +
            oauth_token = Nuorder.oauth_token
         | 
| 74 | 
            +
            oauth_token_secret = Nuorder.oauth_token_secret
         | 
| 75 | 
            +
            ```
         | 
| 76 | 
            +
             | 
| 77 | 
            +
            ### Requests
         | 
| 78 | 
            +
            TODO
         | 
| 79 | 
            +
             | 
| 80 | 
            +
            ## Contributing
         | 
| 81 | 
            +
             | 
| 82 | 
            +
            1. Fork it ( https://github.com/springboardretail/nuorder/fork )
         | 
| 83 | 
            +
            2. Create your feature branch (`git checkout -b my-new-feature`)
         | 
| 84 | 
            +
            3. Commit your changes (`git commit -am 'Add some feature'`)
         | 
| 85 | 
            +
            4. Push to the branch (`git push origin my-new-feature`)
         | 
| 86 | 
            +
            5. Create a new Pull Request
         | 
| 87 | 
            +
             | 
| 88 | 
            +
            ### Running tests
         | 
| 89 | 
            +
             | 
| 90 | 
            +
            Place your consumer keys and tokens in the `.env` file
         | 
| 91 | 
            +
             | 
| 92 | 
            +
            ```
         | 
| 93 | 
            +
            OAUTH_CONSUMER_KEY = 'nuorder-consumer-key'
         | 
| 94 | 
            +
            OAUTH_CONSUMER_SECRET = 'nuorder-consumer-secret'
         | 
| 95 | 
            +
            OAUTH_TOKEN = 'nuorder-oauth-token'
         | 
| 96 | 
            +
            OAUTH_TOKEN_SECRET = 'nuorder-token-secret'
         | 
| 97 | 
            +
            ```
         | 
| 98 | 
            +
             | 
| 99 | 
            +
            `rake` default task will run all the tests
         | 
    
        data/Rakefile
    ADDED
    
    
    
        data/lib/nuorder.rb
    ADDED
    
    | @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require 'nuorder/version'
         | 
| 2 | 
            +
            require 'nuorder/client'
         | 
| 3 | 
            +
            require 'nuorder/configurable'
         | 
| 4 | 
            +
            require 'nuorder/default'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            module Nuorder
         | 
| 7 | 
            +
              class ApiError < StandardError; end
         | 
| 8 | 
            +
              extend Nuorder::Configurable
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              class << self
         | 
| 11 | 
            +
                def client
         | 
| 12 | 
            +
                  @client = Nuorder::Client.new(options) unless defined?(@client) && @client.same_options?(options)
         | 
| 13 | 
            +
                  @client
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def respond_to_missing?(method_name, include_private = false)
         | 
| 17 | 
            +
                  client.respond_to?(method_name, include_private)
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                def method_missing(method_name, *args, &block)
         | 
| 21 | 
            +
                  client.send(method_name, *args, &block)
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
            Nuorder.setup
         | 
| @@ -0,0 +1,100 @@ | |
| 1 | 
            +
            require 'faraday'
         | 
| 2 | 
            +
            require 'excon'
         | 
| 3 | 
            +
            require 'faraday_middleware-multi_json'
         | 
| 4 | 
            +
            require 'nuorder/configurable'
         | 
| 5 | 
            +
            require 'nuorder/client/oauth'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            module Nuorder
         | 
| 8 | 
            +
              class Client
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                include Nuorder::Configurable
         | 
| 11 | 
            +
                include Nuorder::Client::Oauth
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                def initialize(options = {})
         | 
| 14 | 
            +
                  set_instance_variables(options)
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                def same_options?(opts)
         | 
| 18 | 
            +
                  opts.hash == options.hash
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                def api_initiate
         | 
| 22 | 
            +
                  addons = { 'application_name' => @app_name, 'oauth_callback' => @oauth_callback }
         | 
| 23 | 
            +
                  headers = oauth_headers('GET', '/api/initiate', addons)
         | 
| 24 | 
            +
                  response = connection.get '/api/initiate', {}, headers
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                  Nuorder.oauth_token = response.body['oauth_token']
         | 
| 27 | 
            +
                  Nuorder.oauth_token_secret = response.body['oauth_token_secret']
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  response
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                def get_oauth_token(oauth_verifier)
         | 
| 33 | 
            +
                  fail 'No oauth_verifier' unless oauth_verifier
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  headers = oauth_headers('GET', '/api/token', { 'oauth_verifier' => oauth_verifier })
         | 
| 36 | 
            +
                  response = connection.get '/api/token', {}, headers
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  Nuorder.oauth_token = response.body['oauth_token']
         | 
| 39 | 
            +
                  Nuorder.oauth_token_secret = response.body['oauth_token_secret']
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  response
         | 
| 42 | 
            +
                end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                def get(url, params: nil)
         | 
| 45 | 
            +
                  headers = oauth_headers('GET', url)
         | 
| 46 | 
            +
                  response = connection.get url, params, headers
         | 
| 47 | 
            +
                  validate_response(response)
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                def orders(status:)
         | 
| 51 | 
            +
                  get("/api/orders/#{status}/detail").body
         | 
| 52 | 
            +
                end
         | 
| 53 | 
            +
             | 
| 54 | 
            +
                def product(id:)
         | 
| 55 | 
            +
                  get("/api/product/#{id}").body
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                def orders_with_product_details(status:)
         | 
| 59 | 
            +
                  orders = orders(status: status)
         | 
| 60 | 
            +
                  orders.map! do |order|
         | 
| 61 | 
            +
                    add_product_details!(line_items: order['line_items'])
         | 
| 62 | 
            +
                    order
         | 
| 63 | 
            +
                  end
         | 
| 64 | 
            +
                end
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                private
         | 
| 67 | 
            +
             | 
| 68 | 
            +
                # Set instance variables passed in options, but fallback to module defaults
         | 
| 69 | 
            +
                def set_instance_variables(options)
         | 
| 70 | 
            +
                  Nuorder::Configurable.keys.each do |key|
         | 
| 71 | 
            +
                    instance_variable_set(:"@#{key}", options[key] || Nuorder.instance_variable_get(:"@#{key}"))
         | 
| 72 | 
            +
                  end
         | 
| 73 | 
            +
                end
         | 
| 74 | 
            +
             | 
| 75 | 
            +
                def connection
         | 
| 76 | 
            +
                  @connection ||= build_connection
         | 
| 77 | 
            +
                end
         | 
| 78 | 
            +
             | 
| 79 | 
            +
                def build_connection
         | 
| 80 | 
            +
                  Faraday.new(url: @api_endpoint) do |builder|
         | 
| 81 | 
            +
                    builder.response :multi_json
         | 
| 82 | 
            +
                    builder.adapter :excon, persistent: true
         | 
| 83 | 
            +
                  end
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                def validate_response(response)
         | 
| 87 | 
            +
                  return response if [200, 201].include?(response.status)
         | 
| 88 | 
            +
                  fail ApiError, "NuOrder API Error #{response.body['code']}. #{response.body['message']}"
         | 
| 89 | 
            +
                end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
                def add_product_details!(line_items:)
         | 
| 92 | 
            +
                  line_items.map! do |line_item|
         | 
| 93 | 
            +
                    product_id = line_item['product']['_id']
         | 
| 94 | 
            +
                    product_details = product(id: product_id)
         | 
| 95 | 
            +
                    line_item['product'].merge!(product_details)
         | 
| 96 | 
            +
                    line_item
         | 
| 97 | 
            +
                  end
         | 
| 98 | 
            +
                end
         | 
| 99 | 
            +
              end
         | 
| 100 | 
            +
            end
         | 
| @@ -0,0 +1,50 @@ | |
| 1 | 
            +
            module Nuorder
         | 
| 2 | 
            +
              class Client
         | 
| 3 | 
            +
                module Oauth
         | 
| 4 | 
            +
                  VERSION = '1.0'
         | 
| 5 | 
            +
                  SIGNATURE_METHOD = 'HMAC-SHA1'
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  def oauth_headers(method, url, addons = nil)
         | 
| 8 | 
            +
                    time = Time.now.to_i
         | 
| 9 | 
            +
                    nonce = SecureRandom.hex(8)
         | 
| 10 | 
            +
                    signature = build_signature(method, url, time, nonce, addons)
         | 
| 11 | 
            +
                    oauth_header = build_oauth(time, nonce, signature, addons)
         | 
| 12 | 
            +
                    {
         | 
| 13 | 
            +
                        'Authorization' => "oAuth #{oauth_header}",
         | 
| 14 | 
            +
                        'Accept' => 'application/json',
         | 
| 15 | 
            +
                        'Content-Type' => 'application/json'
         | 
| 16 | 
            +
                    }
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  private
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  def build_signature(method, url, time, nonce, addons)
         | 
| 22 | 
            +
                    base = "#{method}#{@api_endpoint}#{url}?"
         | 
| 23 | 
            +
                    base << "oauth_consumer_key=#{@oauth_consumer_key}"
         | 
| 24 | 
            +
                    base << "&oauth_token=#{@oauth_token}"
         | 
| 25 | 
            +
                    base << "&oauth_timestamp=#{time}"
         | 
| 26 | 
            +
                    base << "&oauth_nonce=#{nonce}"
         | 
| 27 | 
            +
                    base << "&oauth_version=#{VERSION}&oauth_signature_method=#{SIGNATURE_METHOD}"
         | 
| 28 | 
            +
                    base << "&oauth_verifier=#{addons['oauth_verifier']}" if addons && addons.include?('oauth_verifier')
         | 
| 29 | 
            +
                    base << "&oauth_callback=#{addons['oauth_callback']}" if addons && addons.include?('oauth_callback')
         | 
| 30 | 
            +
                    key = [@oauth_consumer_secret, @oauth_token_secret].join('&')
         | 
| 31 | 
            +
                    digest = OpenSSL::Digest.new('sha1')
         | 
| 32 | 
            +
                    OpenSSL::HMAC.hexdigest(digest, key, base)
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
                  def build_oauth(time, nonce, signature, addons)
         | 
| 36 | 
            +
                    oauth = {
         | 
| 37 | 
            +
                        'oauth_consumer_key' => @oauth_consumer_key,
         | 
| 38 | 
            +
                        'oauth_timestamp' => time,
         | 
| 39 | 
            +
                        'oauth_nonce' => nonce,
         | 
| 40 | 
            +
                        'oauth_version' => VERSION,
         | 
| 41 | 
            +
                        'oauth_signature_method' => SIGNATURE_METHOD,
         | 
| 42 | 
            +
                        'oauth_token' => @oauth_token,
         | 
| 43 | 
            +
                        'oauth_signature' => signature
         | 
| 44 | 
            +
                    }
         | 
| 45 | 
            +
                    oauth.merge!(addons) unless addons.nil?
         | 
| 46 | 
            +
                    oauth.map { |k, v| "#{k}=#{v}" }.join(',')
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
                end
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| @@ -0,0 +1,37 @@ | |
| 1 | 
            +
            module Nuorder
         | 
| 2 | 
            +
              module Configurable
         | 
| 3 | 
            +
                class << self
         | 
| 4 | 
            +
                  def keys
         | 
| 5 | 
            +
                    @keys ||= %i(
         | 
| 6 | 
            +
                      app_name
         | 
| 7 | 
            +
                      api_endpoint
         | 
| 8 | 
            +
                      oauth_callback
         | 
| 9 | 
            +
                      oauth_consumer_key
         | 
| 10 | 
            +
                      oauth_consumer_secret
         | 
| 11 | 
            +
                      oauth_token
         | 
| 12 | 
            +
                      oauth_token_secret
         | 
| 13 | 
            +
                    )
         | 
| 14 | 
            +
                  end
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
             | 
| 17 | 
            +
                attr_accessor *Nuorder::Configurable.keys
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                # Set configuration options using a block
         | 
| 20 | 
            +
                def configure
         | 
| 21 | 
            +
                  yield(self) if block_given?
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                # Reset configuration options to default values
         | 
| 25 | 
            +
                def reset!
         | 
| 26 | 
            +
                  Nuorder::Configurable.keys.each do |key|
         | 
| 27 | 
            +
                    instance_variable_set(:"@#{key}", Nuorder::Default.options[key])
         | 
| 28 | 
            +
                  end
         | 
| 29 | 
            +
                  self
         | 
| 30 | 
            +
                end
         | 
| 31 | 
            +
                alias_method :setup, :reset!
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                def options
         | 
| 34 | 
            +
                  Hash[Nuorder::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}]
         | 
| 35 | 
            +
                end
         | 
| 36 | 
            +
              end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            module Nuorder
         | 
| 2 | 
            +
              module Default
         | 
| 3 | 
            +
             | 
| 4 | 
            +
                # Default API endpoint
         | 
| 5 | 
            +
                API_ENDPOINT = 'http://buyer.nuorder.com'.freeze
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                # If no callback provided the value must be "oob"
         | 
| 8 | 
            +
                NO_CALLBACK = 'oob'.freeze
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                # Default App Name
         | 
| 11 | 
            +
                APP_NAME = 'Springboard Retail'.freeze
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                class << self
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  def options
         | 
| 16 | 
            +
                    Hash[Nuorder::Configurable.keys.map { |key| [key, default_value(key)] }]
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  def app_name
         | 
| 20 | 
            +
                    APP_NAME
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def api_endpoint
         | 
| 24 | 
            +
                    API_ENDPOINT
         | 
| 25 | 
            +
                  end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  def oauth_callback
         | 
| 28 | 
            +
                    NO_CALLBACK
         | 
| 29 | 
            +
                  end
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  private
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                  # Gets the default value if present or an empty string
         | 
| 34 | 
            +
                  def default_value(key)
         | 
| 35 | 
            +
                    self.respond_to?(key) ? send(key) : ''
         | 
| 36 | 
            +
                  end
         | 
| 37 | 
            +
                end
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
    
        data/nuorder.gemspec
    ADDED
    
    | @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            # coding: utf-8
         | 
| 2 | 
            +
            lib = File.expand_path('../lib', __FILE__)
         | 
| 3 | 
            +
            $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
         | 
| 4 | 
            +
            require 'nuorder/version'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Gem::Specification.new do |spec|
         | 
| 7 | 
            +
              spec.name          = "nuorder"
         | 
| 8 | 
            +
              spec.version       = Nuorder::VERSION
         | 
| 9 | 
            +
              spec.authors       = ["Springboard Retail"]
         | 
| 10 | 
            +
              spec.email         = ["jason.stotz@gmail.com"]
         | 
| 11 | 
            +
              spec.summary       = %q{Library that wraps up the communication with the API services from Nuorder.com}
         | 
| 12 | 
            +
              spec.homepage      = ""
         | 
| 13 | 
            +
              spec.license       = "MIT"
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              spec.files         = `git ls-files -z`.split("\x0")
         | 
| 16 | 
            +
              spec.executables   = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
         | 
| 17 | 
            +
              spec.test_files    = spec.files.grep(%r{^(test|spec|features)/})
         | 
| 18 | 
            +
              spec.require_paths = ["lib"]
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              spec.required_ruby_version = '~> 2.1'
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              spec.add_development_dependency 'bundler', '~> 1.7'
         | 
| 23 | 
            +
              spec.add_development_dependency 'rake', '~> 10.0'
         | 
| 24 | 
            +
              spec.add_development_dependency 'rspec','~> 3.2.0'
         | 
| 25 | 
            +
              spec.add_development_dependency 'byebug', '~> 3.5.1'
         | 
| 26 | 
            +
              spec.add_development_dependency 'vcr', '~> 2.9.3'
         | 
| 27 | 
            +
              spec.add_development_dependency 'dotenv', '~> 1.0.2'
         | 
| 28 | 
            +
             | 
| 29 | 
            +
              spec.add_runtime_dependency 'faraday', '~> 0.9.1'
         | 
| 30 | 
            +
              spec.add_runtime_dependency 'excon', '~> 0.45.3'
         | 
| 31 | 
            +
              spec.add_runtime_dependency 'faraday_middleware-multi_json', '~> 0.0.6'
         | 
| 32 | 
            +
            end
         | 
| @@ -0,0 +1,135 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Nuorder::Client do
         | 
| 4 | 
            +
              before do
         | 
| 5 | 
            +
                Nuorder.reset!
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              after do
         | 
| 9 | 
            +
                Nuorder.reset!
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              include_examples 'options client'
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              specify { expect { described_class.new }.not_to raise_error }
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              subject(:client) do
         | 
| 17 | 
            +
                described_class.new(options_client)
         | 
| 18 | 
            +
              end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              describe 'module configuration' do
         | 
| 21 | 
            +
                before do
         | 
| 22 | 
            +
                  Nuorder.reset!
         | 
| 23 | 
            +
                  Nuorder.configure do |config|
         | 
| 24 | 
            +
                    Nuorder::Configurable.keys.each do |key|
         | 
| 25 | 
            +
                      config.send("#{key}=", "Some #{key}")
         | 
| 26 | 
            +
                    end
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
                end
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                after do
         | 
| 31 | 
            +
                  Nuorder.reset!
         | 
| 32 | 
            +
                end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                it 'inherits the module configuration' do
         | 
| 35 | 
            +
                  client = Nuorder::Client.new
         | 
| 36 | 
            +
                  Nuorder::Configurable.keys.each do |key|
         | 
| 37 | 
            +
                    expect(client.instance_variable_get(:"@#{key}")).to eq("Some #{key}")
         | 
| 38 | 
            +
                  end
         | 
| 39 | 
            +
                end
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                describe 'with options' do
         | 
| 42 | 
            +
                  let (:opts) do
         | 
| 43 | 
            +
                    {
         | 
| 44 | 
            +
                        app_name: 'My APP',
         | 
| 45 | 
            +
                        oauth_callback: 'app.example.com/callback',
         | 
| 46 | 
            +
                        oauth_consumer_key: 'asdfa232042sdafal'
         | 
| 47 | 
            +
                    }
         | 
| 48 | 
            +
                  end
         | 
| 49 | 
            +
             | 
| 50 | 
            +
                  it 'overrides module configuration' do
         | 
| 51 | 
            +
                    client = Nuorder::Client.new(opts)
         | 
| 52 | 
            +
                    expect(client.app_name).to eq('My APP')
         | 
| 53 | 
            +
                    expect(client.oauth_callback).to eq('app.example.com/callback')
         | 
| 54 | 
            +
                    expect(client.oauth_consumer_key).to eq('asdfa232042sdafal')
         | 
| 55 | 
            +
                  end
         | 
| 56 | 
            +
                end
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
             | 
| 59 | 
            +
              describe '#api_initiate' do
         | 
| 60 | 
            +
                before do
         | 
| 61 | 
            +
                  Nuorder.configure do |config|
         | 
| 62 | 
            +
                    config.oauth_token = nil
         | 
| 63 | 
            +
                    config.oauth_token_secret = nil
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
                end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                it 'returns temp oauth_token and oauth_token_secret from API', :vcr do
         | 
| 68 | 
            +
                  client.api_initiate
         | 
| 69 | 
            +
             | 
| 70 | 
            +
                  expect(Nuorder.oauth_token).not_to be_nil
         | 
| 71 | 
            +
                  expect(Nuorder.oauth_token_secret).not_to be_nil
         | 
| 72 | 
            +
                end
         | 
| 73 | 
            +
              end
         | 
| 74 | 
            +
              
         | 
| 75 | 
            +
              describe '#get_oauth_token' do
         | 
| 76 | 
            +
                it 'returns real oauth_token and oauth_token_secret from API', :vcr do
         | 
| 77 | 
            +
                  oauth_verifier = 'aKRzurszYEA9mpun'
         | 
| 78 | 
            +
                  Nuorder.oauth_token = 'p5UzX46KqwdB5Bj3'
         | 
| 79 | 
            +
                  Nuorder.oauth_token_secret = 'YaRS2Vy9uSEDVhwu95NaCDPQ'
         | 
| 80 | 
            +
                  
         | 
| 81 | 
            +
                  client.get_oauth_token(oauth_verifier)
         | 
| 82 | 
            +
                  expect(Nuorder.oauth_token).not_to be_nil
         | 
| 83 | 
            +
                  expect(Nuorder.oauth_token_secret).not_to be_nil
         | 
| 84 | 
            +
                end
         | 
| 85 | 
            +
             | 
| 86 | 
            +
                context 'no oauth_verifier provided' do
         | 
| 87 | 
            +
                  specify { expect { client.get_oauth_token(nil) }.to raise_error('No oauth_verifier') }
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
              end
         | 
| 90 | 
            +
             | 
| 91 | 
            +
              describe '#get' do
         | 
| 92 | 
            +
                it 'raises error if NuOrder api returns error', :vcr do
         | 
| 93 | 
            +
                  expect { client.get("/api/product/541204aca01ceed9650486a2") }
         | 
| 94 | 
            +
                    .to raise_error(Nuorder::ApiError)
         | 
| 95 | 
            +
                end
         | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              describe '#orders_with_product_details' do
         | 
| 99 | 
            +
                let (:orders_dummy) do
         | 
| 100 | 
            +
                  [
         | 
| 101 | 
            +
                    {
         | 
| 102 | 
            +
                      'a' => 1,
         | 
| 103 | 
            +
                      'line_items' => [
         | 
| 104 | 
            +
                        {'product' => {'_id' => 1, 'b' => 2}},
         | 
| 105 | 
            +
                        {'product' => {'_id' => 2, 'b' => 3}},
         | 
| 106 | 
            +
                      ]
         | 
| 107 | 
            +
                    }
         | 
| 108 | 
            +
                  ]
         | 
| 109 | 
            +
                end
         | 
| 110 | 
            +
                let (:product_dummy) do
         | 
| 111 | 
            +
                  {'_id' => 1, 'b' => 4, 'c' => 5 }
         | 
| 112 | 
            +
                end
         | 
| 113 | 
            +
             | 
| 114 | 
            +
                before do
         | 
| 115 | 
            +
                  allow(client).to receive(:orders).and_return(orders_dummy)
         | 
| 116 | 
            +
                  allow(client).to receive(:product).and_return(product_dummy)
         | 
| 117 | 
            +
                  @orders = client.orders_with_product_details(status: 'processed')
         | 
| 118 | 
            +
                end
         | 
| 119 | 
            +
             | 
| 120 | 
            +
                it 'returns extra details of products' do
         | 
| 121 | 
            +
                  first_product = @orders.first['line_items'].first['product']
         | 
| 122 | 
            +
                  expect(first_product.key? 'c').to be true
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
              end
         | 
| 125 | 
            +
             | 
| 126 | 
            +
              describe '#oauth_headers' do
         | 
| 127 | 
            +
                let (:headers) { client.oauth_headers('GET', '/api/product/123') }
         | 
| 128 | 
            +
             | 
| 129 | 
            +
                specify { expect(headers).not_to be_nil }
         | 
| 130 | 
            +
             | 
| 131 | 
            +
                ['Authorization', 'Accept', 'Content-Type'].each do |header_key|
         | 
| 132 | 
            +
                  specify { expect(headers.key? header_key).to be true }
         | 
| 133 | 
            +
                end
         | 
| 134 | 
            +
              end
         | 
| 135 | 
            +
            end
         | 
| @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            require 'spec_helper'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            describe Nuorder do
         | 
| 4 | 
            +
              before do
         | 
| 5 | 
            +
                Nuorder.reset!
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              after do
         | 
| 9 | 
            +
                Nuorder.reset!
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              it 'sets defaults' do
         | 
| 13 | 
            +
                Nuorder::Configurable.keys.each do |key|
         | 
| 14 | 
            +
                  expect(Nuorder.instance_variable_get(:"@#{key}")).to eq(Nuorder::Default.options[key])
         | 
| 15 | 
            +
                end
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
             | 
| 18 | 
            +
              describe '.client' do
         | 
| 19 | 
            +
                it 'creates a Nuorder::Client' do
         | 
| 20 | 
            +
                  expect(Nuorder.client).to be_kind_of Nuorder::Client
         | 
| 21 | 
            +
                end
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                it 'caches the client when the same options are passed' do
         | 
| 24 | 
            +
                  expect(Nuorder.client).to eq(Nuorder.client)
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                it 'returns a fresh client when options are not the same' do
         | 
| 28 | 
            +
                  client = Nuorder.client
         | 
| 29 | 
            +
                  Nuorder.oauth_token = '87614b09dd141c22800f96f11737ade5226d7ba8'
         | 
| 30 | 
            +
                  client_two = Nuorder.client
         | 
| 31 | 
            +
                  client_three = Nuorder.client
         | 
| 32 | 
            +
                  expect(client).not_to eq(client_two)
         | 
| 33 | 
            +
                  expect(client_three).to eq(client_two)
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
              describe '.configure' do
         | 
| 38 | 
            +
                Nuorder::Configurable.keys.each do |key|
         | 
| 39 | 
            +
                  it "sets the #{key.to_s.gsub('_', ' ')}" do
         | 
| 40 | 
            +
                    Nuorder.configure do |config|
         | 
| 41 | 
            +
                      config.send("#{key}=", key)
         | 
| 42 | 
            +
                    end
         | 
| 43 | 
            +
                    expect(Nuorder.instance_variable_get(:"@#{key}")).to eq(key)
         | 
| 44 | 
            +
                  end
         | 
| 45 | 
            +
                end
         | 
| 46 | 
            +
              end
         | 
| 47 | 
            +
             | 
| 48 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    
| @@ -0,0 +1,12 @@ | |
| 1 | 
            +
            options = {
         | 
| 2 | 
            +
              app_name: 'TEST APP',
         | 
| 3 | 
            +
              api_endpoint: 'http://buyer.sandbox1.nuorder.com',
         | 
| 4 | 
            +
              oauth_consumer_key: ENV['OAUTH_CONSUMER_KEY'],
         | 
| 5 | 
            +
              oauth_consumer_secret: ENV['OAUTH_CONSUMER_SECRET'],
         | 
| 6 | 
            +
              oauth_token: ENV['OAUTH_TOKEN'],
         | 
| 7 | 
            +
              oauth_token_secret: ENV['OAUTH_TOKEN_SECRET']
         | 
| 8 | 
            +
            }
         | 
| 9 | 
            +
             | 
| 10 | 
            +
            shared_examples 'options client' do
         | 
| 11 | 
            +
              let!(:options_client) { options }
         | 
| 12 | 
            +
            end
         | 
    
        data/spec/support/vcr.rb
    ADDED
    
    | @@ -0,0 +1,16 @@ | |
| 1 | 
            +
            SENSITIVE_DATA = %w(
         | 
| 2 | 
            +
              OAUTH_CONSUMER_KEY
         | 
| 3 | 
            +
              OAUTH_CONSUMER_SECRET
         | 
| 4 | 
            +
              OAUTH_TOKEN
         | 
| 5 | 
            +
              OAUTH_TOKEN_SECRET
         | 
| 6 | 
            +
            )
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            VCR.configure do |config|
         | 
| 9 | 
            +
              config.cassette_library_dir = 'spec/vcr'
         | 
| 10 | 
            +
              config.hook_into :excon
         | 
| 11 | 
            +
              config.configure_rspec_metadata!
         | 
| 12 | 
            +
              
         | 
| 13 | 
            +
              SENSITIVE_DATA.each do |key|
         | 
| 14 | 
            +
                config.filter_sensitive_data(key) { ENV[key] }
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: http://buyer.sandbox1.nuorder.com/api/initiate
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: US-ASCII
         | 
| 8 | 
            +
                  string: ''
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  User-Agent:
         | 
| 11 | 
            +
                  - Faraday v0.9.1
         | 
| 12 | 
            +
                  Authorization:
         | 
| 13 | 
            +
                  - oAuth oauth_consumer_key=OAUTH_CONSUMER_KEY,oauth_timestamp=1424184346,oauth_nonce=e8a97b9c13ed4958,oauth_version=1.0,oauth_signature_method=HMAC-SHA1,oauth_token=,oauth_signature=3936cf91abc9b55ea8922ad5f9d62657a00cd23b,application_name=TEST-app,oauth_callback=oob
         | 
| 14 | 
            +
                  Accept:
         | 
| 15 | 
            +
                  - application/json
         | 
| 16 | 
            +
                  Content-Type:
         | 
| 17 | 
            +
                  - application/json
         | 
| 18 | 
            +
              response:
         | 
| 19 | 
            +
                status:
         | 
| 20 | 
            +
                  code: 200
         | 
| 21 | 
            +
                  message: 
         | 
| 22 | 
            +
                headers:
         | 
| 23 | 
            +
                  Server:
         | 
| 24 | 
            +
                  - nginx/1.4.6
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Tue, 17 Feb 2015 14:45:47 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json
         | 
| 29 | 
            +
                  Content-Length:
         | 
| 30 | 
            +
                  - '114'
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  X-Powered-By:
         | 
| 34 | 
            +
                  - Express
         | 
| 35 | 
            +
                  Request-Token:
         | 
| 36 | 
            +
                  - '1424184347570'
         | 
| 37 | 
            +
                  Cache-Control:
         | 
| 38 | 
            +
                  - private,max-age=0, must-revalidate
         | 
| 39 | 
            +
                  ETag:
         | 
| 40 | 
            +
                  - '"672815263"'
         | 
| 41 | 
            +
                body:
         | 
| 42 | 
            +
                  encoding: UTF-8
         | 
| 43 | 
            +
                  string: '{"oauth_token":"p5UzX46KqwdB5Bj3","oauth_token_secret":"YaRS2Vy9uSEDVhwu95NaCDPQ","oauth_callback_confirmed":true}'
         | 
| 44 | 
            +
                http_version: 
         | 
| 45 | 
            +
              recorded_at: Tue, 17 Feb 2015 14:45:47 GMT
         | 
| 46 | 
            +
            recorded_with: VCR 2.9.3
         | 
| @@ -0,0 +1,44 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: http://buyer.sandbox1.nuorder.com/api/product/541204aca01ceed9650486a2
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: US-ASCII
         | 
| 8 | 
            +
                  string: ''
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  User-Agent:
         | 
| 11 | 
            +
                  - Faraday v0.9.1
         | 
| 12 | 
            +
                  Authorization:
         | 
| 13 | 
            +
                  - oAuth oauth_consumer_key=OAUTH_CONSUMER_KEY,oauth_timestamp=1424367866,oauth_nonce=084a18900cd8fd50,oauth_version=1.0,oauth_signature_method=HMAC-SHA1,oauth_token=OAUTH_TOKEN,oauth_signature=6b72fa36e4b22f30378b91761f0e623b0c779e07
         | 
| 14 | 
            +
                  Accept:
         | 
| 15 | 
            +
                  - application/json
         | 
| 16 | 
            +
                  Content-Type:
         | 
| 17 | 
            +
                  - application/json
         | 
| 18 | 
            +
              response:
         | 
| 19 | 
            +
                status:
         | 
| 20 | 
            +
                  code: 404
         | 
| 21 | 
            +
                  message: 
         | 
| 22 | 
            +
                headers:
         | 
| 23 | 
            +
                  Server:
         | 
| 24 | 
            +
                  - nginx/1.4.6
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Thu, 19 Feb 2015 17:44:34 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json
         | 
| 29 | 
            +
                  Content-Length:
         | 
| 30 | 
            +
                  - '42'
         | 
| 31 | 
            +
                  X-Powered-By:
         | 
| 32 | 
            +
                  - Express
         | 
| 33 | 
            +
                  Request-Token:
         | 
| 34 | 
            +
                  - '1424367874986'
         | 
| 35 | 
            +
                  Cache-Control:
         | 
| 36 | 
            +
                  - private,max-age=0, must-revalidate
         | 
| 37 | 
            +
                  ETag:
         | 
| 38 | 
            +
                  - '"-1929168688"'
         | 
| 39 | 
            +
                body:
         | 
| 40 | 
            +
                  encoding: UTF-8
         | 
| 41 | 
            +
                  string: '{"code":404,"message":"product not found"}'
         | 
| 42 | 
            +
                http_version: 
         | 
| 43 | 
            +
              recorded_at: Thu, 19 Feb 2015 17:44:36 GMT
         | 
| 44 | 
            +
            recorded_with: VCR 2.9.3
         | 
| @@ -0,0 +1,46 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            http_interactions:
         | 
| 3 | 
            +
            - request:
         | 
| 4 | 
            +
                method: get
         | 
| 5 | 
            +
                uri: http://buyer.sandbox1.nuorder.com/api/token
         | 
| 6 | 
            +
                body:
         | 
| 7 | 
            +
                  encoding: US-ASCII
         | 
| 8 | 
            +
                  string: ''
         | 
| 9 | 
            +
                headers:
         | 
| 10 | 
            +
                  User-Agent:
         | 
| 11 | 
            +
                  - Faraday v0.9.1
         | 
| 12 | 
            +
                  Authorization:
         | 
| 13 | 
            +
                  - oAuth oauth_consumer_key=OAUTH_CONSUMER_KEY,oauth_timestamp=1424184425,oauth_nonce=c8b9cae479328dc1,oauth_version=1.0,oauth_signature_method=HMAC-SHA1,oauth_token=p5UzX46KqwdB5Bj3,oauth_signature=dee2482ebc5ab9f93bc0cb22413d287e3d0cf20a,oauth_verifier=aKRzurszYEA9mpun
         | 
| 14 | 
            +
                  Accept:
         | 
| 15 | 
            +
                  - application/json
         | 
| 16 | 
            +
                  Content-Type:
         | 
| 17 | 
            +
                  - application/json
         | 
| 18 | 
            +
              response:
         | 
| 19 | 
            +
                status:
         | 
| 20 | 
            +
                  code: 200
         | 
| 21 | 
            +
                  message: 
         | 
| 22 | 
            +
                headers:
         | 
| 23 | 
            +
                  Server:
         | 
| 24 | 
            +
                  - nginx/1.4.6
         | 
| 25 | 
            +
                  Date:
         | 
| 26 | 
            +
                  - Tue, 17 Feb 2015 14:47:06 GMT
         | 
| 27 | 
            +
                  Content-Type:
         | 
| 28 | 
            +
                  - application/json
         | 
| 29 | 
            +
                  Content-Length:
         | 
| 30 | 
            +
                  - '130'
         | 
| 31 | 
            +
                  Connection:
         | 
| 32 | 
            +
                  - keep-alive
         | 
| 33 | 
            +
                  X-Powered-By:
         | 
| 34 | 
            +
                  - Express
         | 
| 35 | 
            +
                  Request-Token:
         | 
| 36 | 
            +
                  - '1424184426181'
         | 
| 37 | 
            +
                  Cache-Control:
         | 
| 38 | 
            +
                  - private,max-age=0, must-revalidate
         | 
| 39 | 
            +
                  ETag:
         | 
| 40 | 
            +
                  - '"-798635993"'
         | 
| 41 | 
            +
                body:
         | 
| 42 | 
            +
                  encoding: UTF-8
         | 
| 43 | 
            +
                  string: '{"oauth_token":"QZfdcPVH8c3rVGMwPsKQHWtj","oauth_token_secret":"gSAme7S2juZFk4enTKgG5g5VAAcvKMmDyrrKxTKHj98GumtPSk8km5m99BMAhDKS"}'
         | 
| 44 | 
            +
                http_version: 
         | 
| 45 | 
            +
              recorded_at: Tue, 17 Feb 2015 14:47:06 GMT
         | 
| 46 | 
            +
            recorded_with: VCR 2.9.3
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,200 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: nuorder
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Springboard Retail
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2015-06-03 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies:
         | 
| 13 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 14 | 
            +
              name: bundler
         | 
| 15 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 | 
            +
                requirements:
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            +
                    version: '1.7'
         | 
| 20 | 
            +
              type: :development
         | 
| 21 | 
            +
              prerelease: false
         | 
| 22 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 | 
            +
                requirements:
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            +
                    version: '1.7'
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rake
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - "~>"
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '10.0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - "~>"
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '10.0'
         | 
| 41 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 42 | 
            +
              name: rspec
         | 
| 43 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 | 
            +
                requirements:
         | 
| 45 | 
            +
                - - "~>"
         | 
| 46 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 47 | 
            +
                    version: 3.2.0
         | 
| 48 | 
            +
              type: :development
         | 
| 49 | 
            +
              prerelease: false
         | 
| 50 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - "~>"
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: 3.2.0
         | 
| 55 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 56 | 
            +
              name: byebug
         | 
| 57 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 | 
            +
                requirements:
         | 
| 59 | 
            +
                - - "~>"
         | 
| 60 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 61 | 
            +
                    version: 3.5.1
         | 
| 62 | 
            +
              type: :development
         | 
| 63 | 
            +
              prerelease: false
         | 
| 64 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 | 
            +
                requirements:
         | 
| 66 | 
            +
                - - "~>"
         | 
| 67 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 68 | 
            +
                    version: 3.5.1
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: vcr
         | 
| 71 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                requirements:
         | 
| 73 | 
            +
                - - "~>"
         | 
| 74 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 75 | 
            +
                    version: 2.9.3
         | 
| 76 | 
            +
              type: :development
         | 
| 77 | 
            +
              prerelease: false
         | 
| 78 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 | 
            +
                requirements:
         | 
| 80 | 
            +
                - - "~>"
         | 
| 81 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 82 | 
            +
                    version: 2.9.3
         | 
| 83 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 84 | 
            +
              name: dotenv
         | 
| 85 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 | 
            +
                requirements:
         | 
| 87 | 
            +
                - - "~>"
         | 
| 88 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 89 | 
            +
                    version: 1.0.2
         | 
| 90 | 
            +
              type: :development
         | 
| 91 | 
            +
              prerelease: false
         | 
| 92 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 | 
            +
                requirements:
         | 
| 94 | 
            +
                - - "~>"
         | 
| 95 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 96 | 
            +
                    version: 1.0.2
         | 
| 97 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 98 | 
            +
              name: faraday
         | 
| 99 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 | 
            +
                requirements:
         | 
| 101 | 
            +
                - - "~>"
         | 
| 102 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 103 | 
            +
                    version: 0.9.1
         | 
| 104 | 
            +
              type: :runtime
         | 
| 105 | 
            +
              prerelease: false
         | 
| 106 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 | 
            +
                requirements:
         | 
| 108 | 
            +
                - - "~>"
         | 
| 109 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 110 | 
            +
                    version: 0.9.1
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: excon
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - "~>"
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: 0.45.3
         | 
| 118 | 
            +
              type: :runtime
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - "~>"
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: 0.45.3
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: faraday_middleware-multi_json
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - "~>"
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: 0.0.6
         | 
| 132 | 
            +
              type: :runtime
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - "~>"
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: 0.0.6
         | 
| 139 | 
            +
            description: 
         | 
| 140 | 
            +
            email:
         | 
| 141 | 
            +
            - jason.stotz@gmail.com
         | 
| 142 | 
            +
            executables: []
         | 
| 143 | 
            +
            extensions: []
         | 
| 144 | 
            +
            extra_rdoc_files: []
         | 
| 145 | 
            +
            files:
         | 
| 146 | 
            +
            - ".gitignore"
         | 
| 147 | 
            +
            - ".travis.yml"
         | 
| 148 | 
            +
            - CHANGELOG.md
         | 
| 149 | 
            +
            - Gemfile
         | 
| 150 | 
            +
            - LICENSE.txt
         | 
| 151 | 
            +
            - README.md
         | 
| 152 | 
            +
            - Rakefile
         | 
| 153 | 
            +
            - lib/nuorder.rb
         | 
| 154 | 
            +
            - lib/nuorder/client.rb
         | 
| 155 | 
            +
            - lib/nuorder/client/oauth.rb
         | 
| 156 | 
            +
            - lib/nuorder/configurable.rb
         | 
| 157 | 
            +
            - lib/nuorder/default.rb
         | 
| 158 | 
            +
            - lib/nuorder/version.rb
         | 
| 159 | 
            +
            - nuorder.gemspec
         | 
| 160 | 
            +
            - spec/nuorder/client_spec.rb
         | 
| 161 | 
            +
            - spec/nuorder_spec.rb
         | 
| 162 | 
            +
            - spec/spec_helper.rb
         | 
| 163 | 
            +
            - spec/support/shared_examples.rb
         | 
| 164 | 
            +
            - spec/support/vcr.rb
         | 
| 165 | 
            +
            - spec/vcr/Nuorder_Client/_api_initiate/returns_temp_oauth_token_and_oauth_token_secret_from_API.yml
         | 
| 166 | 
            +
            - spec/vcr/Nuorder_Client/_get/raises_error_if_NuOrder_api_returns_error.yml
         | 
| 167 | 
            +
            - spec/vcr/Nuorder_Client/_get_oauth_token/returns_real_oauth_token_and_oauth_token_secret_from_API.yml
         | 
| 168 | 
            +
            homepage: ''
         | 
| 169 | 
            +
            licenses:
         | 
| 170 | 
            +
            - MIT
         | 
| 171 | 
            +
            metadata: {}
         | 
| 172 | 
            +
            post_install_message: 
         | 
| 173 | 
            +
            rdoc_options: []
         | 
| 174 | 
            +
            require_paths:
         | 
| 175 | 
            +
            - lib
         | 
| 176 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 177 | 
            +
              requirements:
         | 
| 178 | 
            +
              - - "~>"
         | 
| 179 | 
            +
                - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                  version: '2.1'
         | 
| 181 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 182 | 
            +
              requirements:
         | 
| 183 | 
            +
              - - ">="
         | 
| 184 | 
            +
                - !ruby/object:Gem::Version
         | 
| 185 | 
            +
                  version: '0'
         | 
| 186 | 
            +
            requirements: []
         | 
| 187 | 
            +
            rubyforge_project: 
         | 
| 188 | 
            +
            rubygems_version: 2.2.2
         | 
| 189 | 
            +
            signing_key: 
         | 
| 190 | 
            +
            specification_version: 4
         | 
| 191 | 
            +
            summary: Library that wraps up the communication with the API services from Nuorder.com
         | 
| 192 | 
            +
            test_files:
         | 
| 193 | 
            +
            - spec/nuorder/client_spec.rb
         | 
| 194 | 
            +
            - spec/nuorder_spec.rb
         | 
| 195 | 
            +
            - spec/spec_helper.rb
         | 
| 196 | 
            +
            - spec/support/shared_examples.rb
         | 
| 197 | 
            +
            - spec/support/vcr.rb
         | 
| 198 | 
            +
            - spec/vcr/Nuorder_Client/_api_initiate/returns_temp_oauth_token_and_oauth_token_secret_from_API.yml
         | 
| 199 | 
            +
            - spec/vcr/Nuorder_Client/_get/raises_error_if_NuOrder_api_returns_error.yml
         | 
| 200 | 
            +
            - spec/vcr/Nuorder_Client/_get_oauth_token/returns_real_oauth_token_and_oauth_token_secret_from_API.yml
         |