Sha256: 6c1f3658a36fc456562e3c4567fdc2e4c3b1af48ef9192820b7700b49c231396

Contents?: true

Size: 1.16 KB

Versions: 4

Compression:

Stored size: 1.16 KB

Contents

require 'insales_api/resource/countable'
require 'insales_api/resource/paginated'
require 'insales_api/resource/with_updated_since'
require 'insales_api/active_resource_proxy'

module InsalesApi
  class Base < ActiveResource::Base
    extend Resource::Countable
    extend Resource::Paginated

    self.include_root_in_json = false
    self.headers['User-Agent'] = %W(
      InsalesApi/#{InsalesApi::VERSION}
      ActiveResource/#{ActiveResource::VERSION::STRING}
      Ruby/#{RUBY_VERSION}
    ).join(' ')
    self.format = :xml
    self.prefix = '/admin/'

    class << self
      def configure(api_key, domain, password)
        self.user     = api_key
        self.site     = "http://#{domain}"
        self.password = password
        self
      end

      def dump_config
        {
          user:     self.user,
          site:     self.site,
          password: self.password,
        }
      end

      def restore_config(options)
        self.user     = options[:user]
        self.site     = options[:site]
        self.password = options[:password]
        true
      end

      def for_account(account)
        ActiveResourceProxy.new(account, self)
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
insales_api-0.1.3 lib/insales_api/base.rb
insales_api-0.1.2 lib/insales_api/base.rb
insales_api-0.1.1 lib/insales_api/base.rb
insales_api-0.1.0 lib/insales_api/base.rb