Sha256: 559f3fd5e4ac1f641be202392f7de2cb89973cde1e4434c54792387ee4118741

Contents?: true

Size: 1.44 KB

Versions: 2

Compression:

Stored size: 1.44 KB

Contents

module Passworks

  # Client is the HTTP API Wrapper to comunicate with the Passworks API
  #
  class Client

    include Passworks::Configuration
    include Passworks::Request

    def initialize(params={})
      Configuration::VALID_CONFIG_KEYS.each do |key|
        self.instance_variable_set(:"@#{key}", params[key])
      end
    end

    # Check if the current {Client} instance options are equal to the passed ones
    # @param options [Hash] options
    # @return [Boolean]
    def same_options?(options)
      self.options == options
    end

    # @!method assets
    #   Allows to to access the Assets API
    #   @return [Passworks::RequestProxy]
    # @!method boarding_passes
    #   Allows to to access the Boarding Pass API
    #   @return [Passworks::RequestProxy]
    # @!method store_cards
    #   Allows to to access the Store Cards API
    #   @return [Passworks::RequestProxy]
    # @!method coupons
    #   Allows to to access the Coupons API
    #   @return [Passworks::RequestProxy]
    # @!method generics
    #   Allows to to access the Generic API
    #   @return [Passworks::RequestProxy]

    %w(assets boarding_passes store_cards coupons generics).each do |collection_name|
      define_method(collection_name) do
        Passworks::RequestProxy.new(self, collection_name, nil)
      end
    end

    def inspect
      inspected = super
      inspected.gsub!(/\@api_secret=(.+)/){ "@api_secret=\"**********\"" }
      inspected
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
passworks-0.0.2 lib/passworks/client.rb
passworks-0.0.1 lib/passworks/client.rb