Sha256: a75a180152aeb079e2ab269ef0c18c6442f0cf0863f2f1487c69d400a5b1b6a0

Contents?: true

Size: 767 Bytes

Versions: 2

Compression:

Stored size: 767 Bytes

Contents

module Organizai
  class Api
    
    attr_reader :token
    
    def initialize(token=nil,secret=nil)
      @token = OAuth::Token.new(token,secret)
      raise "You must install the initializer before using Organizaí. Run 'rails g organizai:install'." unless Organizai.configured?
    end
    
    def user(action,*options)
      existing_actions = [:create]
      raise "Undefined api call '#{action.to_s}' for user." unless existing_actions.include?(action)
      Organizai::User.send(action, *options)
    end
    
    def coupon(action,*options)
      existing_actions = [:create]
      raise "Undefined api call '#{action.to_s}' for coupon." unless existing_actions.include?(action)
      Organizai::Coupon.send(action, @token, *options)
    end
    
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
organizai-0.1.1 lib/organizai/api.rb
organizai-0.1.0 lib/organizai/api.rb