class Gyft::Client::Partner

Public Class Methods

new(client) click to toggle source
# File lib/gyft/client/partner.rb, line 2
def initialize client
  @client = client
end

Public Instance Methods

gift_card_direct(params = {}) click to toggle source
# File lib/gyft/client/partner.rb, line 10
def gift_card_direct params = {}
  params = symbolize(params)
  options = extract(params, :to_email, :shop_card_id)
  options = merge(options, params, :reseller_reference, :notes, :first_name, :last_name, :gender, :birthday)

  transaction = @client.post("/partner/purchase/gift_card_direct", options)
  
  transaction[:client] = @client
  Gyft::Transaction.new(transaction)
end
purchase() click to toggle source
# File lib/gyft/client/partner.rb, line 6
def purchase
  self
end

Private Instance Methods

extract(params, *args) click to toggle source
# File lib/gyft/client/partner.rb, line 27
def extract params, *args
  options = {}
  args.each do |arg|
    options[arg] = params.fetch(arg)
  end
  options
end
merge(options, params, *args) click to toggle source
# File lib/gyft/client/partner.rb, line 35
def merge options, params, *args
  args.each do |arg|
    options[arg] = params[arg] if params[arg]
  end
  options
end
symbolize(params) click to toggle source
# File lib/gyft/client/partner.rb, line 23
def symbolize params
  params.inject({}){|hash,(k,v)| hash[k.to_sym] = v; hash}
end