Class: Recomiendo::Reward

Inherits:
Object
  • Object
show all
Defined in:
lib/recomiendo/reward.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ Reward

Returns a new instance of Reward.



3
4
5
# File 'lib/recomiendo/reward.rb', line 3

def initialize(client)
  @client = client
end

Instance Method Details

#all(params = {}) ⇒ Object



7
8
9
# File 'lib/recomiendo/reward.rb', line 7

def all(params={})
  @client.get('/rewards', params).parsed_response
end

#create(params = {}) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/recomiendo/reward.rb', line 11

def create(params={})
  if params.class != String and params.class != Integer
    params[:earned_on] ||= Time.now.strftime('%F')
    params[:payable_on] ||= (Time.now + 2592000).strftime('%F')

    @client.post('/rewards', params).parsed_response
  end
end

#delete(params = {}) ⇒ Object



20
21
22
23
24
25
26
27
# File 'lib/recomiendo/reward.rb', line 20

def delete(params={})
  #begin
    if params.has_key?(:reward_id)
      @client.delete("/rewards/#{params[:reward_id]}").parsed_response
    else
      puts "Insufficient parameters: reward_id"
    end
end

#update(params = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/recomiendo/reward.rb', line 29

def update(params={})
  if params.has_key?(:reward_id)
    @client.put("/rewards/#{params[:reward_id]}", params).parsed_response
  else
    puts "Insufficient parameters: reward_id"
  end
end