class Voucherify::Service::LoyaltyRewards

Attributes

client[R]

Public Class Methods

new(client) click to toggle source
# File lib/voucherify/service/loyalties.rb, line 78
def initialize(client)
  @client = client
end

Public Instance Methods

create(loyalty_id, assignments) click to toggle source
# File lib/voucherify/service/loyalties.rb, line 86
def create(loyalty_id, assignments)
  payload = assignments
  if assignments.is_a? Hash
    payload = [ assignments ]
  end
  @client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", payload.to_json)
end
delete(loyalty_id, assignment_id) click to toggle source
# File lib/voucherify/service/loyalties.rb, line 98
def delete(loyalty_id, assignment_id)
  @client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}")
  nil
end
list(loyalty_id, query = {}) click to toggle source
# File lib/voucherify/service/loyalties.rb, line 82
def list(loyalty_id, query = {})
  @client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", query)
end
update(loyalty_id, assignment_id, assignment) click to toggle source
# File lib/voucherify/service/loyalties.rb, line 94
def update(loyalty_id, assignment_id, assignment)
  @client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json)
end