Skip to content

Commit

Permalink
replaced calls to the deprecated URI.encode with ERB::Util.url_encode
Browse files Browse the repository at this point in the history
  • Loading branch information
kgillison authored and lkulig committed Jun 14, 2021
1 parent 9493871 commit 158088b
Show file tree
Hide file tree
Showing 14 changed files with 80 additions and 80 deletions.
10 changes: 5 additions & 5 deletions lib/voucherify/service/campaigns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@ def create(campaign)
end

def get(campaign_name)
@client.get("/campaigns/#{URI.encode(campaign_name)}")
@client.get("/campaigns/#{ERB::Util.url_encode(campaign_name)}")
end

def delete(campaign_name, params = {})
@client.delete("/campaigns/#{URI.encode(campaign_name)}", {:force => (!!(params['force'] || params[:force])).to_s})
@client.delete("/campaigns/#{ERB::Util.url_encode(campaign_name)}", {:force => (!!(params['force'] || params[:force])).to_s})
nil
end

def add_voucher(campaign_name, params = {})
code = params['code'] || params[:code]
url = "/campaigns/#{URI.encode(campaign_name)}/vouchers"
url += "/#{URI.encode(code)}" if code
url = "/campaigns/#{ERB::Util.url_encode(campaign_name)}/vouchers"
url += "/#{ERB::Util.url_encode(code)}" if code
params.delete 'code'
params.delete :code
@client.post(url, params.to_json)
end

def import_vouchers(campaign_name, vouchers)
@client.post("/campaigns/#{URI.encode(campaign_name)}/import", vouchers.to_json)
@client.post("/campaigns/#{ERB::Util.url_encode(campaign_name)}/import", vouchers.to_json)
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/voucherify/service/customers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ def create(customer)
end

def get(customer_id)
@client.get("/customers/#{URI.encode(customer_id)}")
@client.get("/customers/#{ERB::Util.url_encode(customer_id)}")
end

def update(customer)
@client.put("/customers/#{URI.encode(customer['id'] || customer[:id])}", customer.to_json)
@client.put("/customers/#{ERB::Util.url_encode(customer['id'] || customer[:id])}", customer.to_json)
end

def delete(customer_id)
@client.delete("/customers/#{URI.encode(customer_id)}")
@client.delete("/customers/#{ERB::Util.url_encode(customer_id)}")
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/voucherify/service/distributions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ def create_export(export)
end

def get_export(id)
@client.get("/exports/#{URI.encode(id)}")
@client.get("/exports/#{ERB::Util.url_encode(id)}")
end

def delete_export(id)
@client.delete("/exports/#{URI.encode(id)}")
@client.delete("/exports/#{ERB::Util.url_encode(id)}")
end

def list_publications(params = {})
Expand All @@ -39,7 +39,7 @@ def list_publications(params = {})
def create_publication(params)
@client.post('/publications', params.to_json)
end

end
end
end
38 changes: 19 additions & 19 deletions lib/voucherify/service/loyalties.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ def create(loyalty)
end

def update(loyalty_id, loyalty)
@client.put("/loyalties/#{URI.encode(loyalty_id)}", loyalty.to_json)
@client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}", loyalty.to_json)
end

def get(loyalty_id)
@client.get("/loyalties/#{URI.encode(loyalty_id)}")
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}")
end

def delete(loyalty_id, query = {})
@client.delete("/loyalties/#{URI.encode(loyalty_id)}", query)
@client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}", query)
nil
end
end
Expand All @@ -51,23 +51,23 @@ def initialize(client)
end

def list(loyalty_id, query = {})
@client.get("/loyalties/#{URI.encode(loyalty_id)}/earning-rules", query)
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules", query)
end

def create(loyalty_id, earning_rules)
payload = earning_rules
if earning_rules.is_a? Hash
payload = [ earning_rules ]
end
@client.post("/loyalties/#{URI.encode(loyalty_id)}/earning-rules", payload.to_json)
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules", payload.to_json)
end

def update(loyalty_id, earning_rule_id, earning_rule)
@client.put("/loyalties/#{URI.encode(loyalty_id)}/earning-rules/#{URI.encode(earning_rule_id)}", earning_rule.to_json)
@client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules/#{ERB::Util.url_encode(earning_rule_id)}", earning_rule.to_json)
end

def delete(loyalty_id, earning_rule_id)
@client.delete("/loyalties/#{URI.encode(loyalty_id)}/earning-rules/#{URI.encode(earning_rule_id)}")
@client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/earning-rules/#{ERB::Util.url_encode(earning_rule_id)}")
nil
end
end
Expand All @@ -80,23 +80,23 @@ def initialize(client)
end

def list(loyalty_id, query = {})
@client.get("/loyalties/#{URI.encode(loyalty_id)}/rewards", query)
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", query)
end

def create(loyalty_id, assignments)
payload = assignments
if assignments.is_a? Hash
payload = [ assignments ]
end
@client.post("/loyalties/#{URI.encode(loyalty_id)}/rewards", payload.to_json)
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards", payload.to_json)
end

def update(loyalty_id, assignment_id, assignment)
@client.put("/loyalties/#{URI.encode(loyalty_id)}/rewards/#{URI.encode(assignment_id)}", assignment.to_json)
@client.put("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json)
end

def delete(loyalty_id, assignment_id)
@client.delete("/loyalties/#{URI.encode(loyalty_id)}/rewards/#{URI.encode(assignment_id)}")
@client.delete("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/rewards/#{ERB::Util.url_encode(assignment_id)}")
nil
end
end
Expand All @@ -108,24 +108,24 @@ def initialize(client)
@client = client
end

def list(loyalty_id, query = {})
@client.get("/loyalties/#{URI.encode(loyalty_id)}/members", query)
def list(loyalty_id, query = {})
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members", query)
end

def add(loyalty_id, member)
@client.post("/loyalties/#{URI.encode(loyalty_id)}/members", member.to_json)
def add(loyalty_id, member)
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members", member.to_json)
end

def get(loyalty_id, member_id)
@client.get("/loyalties/#{URI.encode(loyalty_id)}/members/#{URI.encode(member_id)}")
def get(loyalty_id, member_id)
@client.get("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}")
end

def add_balance(loyalty_id, member_id, payload)
@client.post("/loyalties/#{URI.encode(loyalty_id)}/members/#{URI.encode(member_id)}/balance", payload.to_json)
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}/balance", payload.to_json)
end

def redeem_reward(loyalty_id, member_id, payload)
@client.post("/loyalties/#{URI.encode(loyalty_id)}/members/#{URI.encode(member_id)}/redemption", payload.to_json)
@client.post("/loyalties/#{ERB::Util.url_encode(loyalty_id)}/members/#{ERB::Util.url_encode(member_id)}/redemption", payload.to_json)
end
end

Expand Down
4 changes: 2 additions & 2 deletions lib/voucherify/service/orders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def create(order)
end

def get(order_id)
@client.get("/orders/#{URI.encode(order_id)}")
@client.get("/orders/#{ERB::Util.url_encode(order_id)}")
end

def update(order_id, order)
@client.put("/orders/#{URI.encode(order_id)}", order.to_json)
@client.put("/orders/#{ERB::Util.url_encode(order_id)}", order.to_json)
end

def list(query = {})
Expand Down
16 changes: 8 additions & 8 deletions lib/voucherify/service/products.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,39 +14,39 @@ def create(product)
end

def get(product_id)
@client.get("/products/#{URI.encode(product_id)}")
@client.get("/products/#{ERB::Util.url_encode(product_id)}")
end

def update(product)
@client.put("/products/#{URI.encode(product['id'] || product[:id])}", product.to_json)
@client.put("/products/#{ERB::Util.url_encode(product['id'] || product[:id])}", product.to_json)
end

def delete(product_id)
@client.delete("/products/#{URI.encode(product_id)}")
@client.delete("/products/#{ERB::Util.url_encode(product_id)}")
end

def list(query = {})
@client.get('/products', query)
end

def create_sku(product_id, sku)
@client.post("/products/#{URI.encode(product_id)}/skus", sku.to_json)
@client.post("/products/#{ERB::Util.url_encode(product_id)}/skus", sku.to_json)
end

def get_sku(product_id, sku_id)
@client.get("/products/#{URI.encode(product_id)}/skus/#{URI.encode(sku_id)}")
@client.get("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}")
end

def update_sku(product_id, sku)
@client.put("/products/#{URI.encode(product_id)}/skus/#{URI.encode(sku['id'] || sku[:id])}", sku.to_json)
@client.put("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku['id'] || sku[:id])}", sku.to_json)
end

def delete_sku(product_id, sku_id)
@client.delete("/products/#{URI.encode(product_id)}/skus/#{URI.encode(sku_id)}")
@client.delete("/products/#{ERB::Util.url_encode(product_id)}/skus/#{ERB::Util.url_encode(sku_id)}")
end

def list_skus(product_id)
@client.get("/products/#{URI.encode(product_id)}/skus")
@client.get("/products/#{ERB::Util.url_encode(product_id)}/skus")
end
end
end
Expand Down
10 changes: 5 additions & 5 deletions lib/voucherify/service/promotions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,23 @@ def initialize(client)
end

def list(promotion_id)
@client.get("/promotions/#{URI.encode(promotion_id)}/tiers")
@client.get("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers")
end

def create(promotion_id, promotion_tier)
@client.post("/promotions/#{URI.encode(promotion_id)}/tiers", promotion_tier.to_json)
@client.post("/promotions/#{ERB::Util.url_encode(promotion_id)}/tiers", promotion_tier.to_json)
end

def redeem(promotions_tier_id, redemption_context)
@client.post("/promotions/tiers/#{URI.encode(promotions_tier_id)}/redemption", redemption_context.to_json)
@client.post("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}/redemption", redemption_context.to_json)
end

def update(promotions_tier)
@client.put("/promotions/tiers/#{URI.encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json)
@client.put("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier['id'] || promotions_tier[:id])}", promotions_tier.to_json)
end

def delete(promotions_tier_id)
@client.delete("/promotions/tiers/#{URI.encode(promotions_tier_id)}")
@client.delete("/promotions/tiers/#{ERB::Util.url_encode(promotions_tier_id)}")
nil
end

Expand Down
10 changes: 5 additions & 5 deletions lib/voucherify/service/redemptions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ def initialize(client)

def redeem(code, params = {})
if code.is_a? Hash
endpoint = "/promotions/tiers/#{URI.encode(code[:id] || code['id'])}/redemption"
endpoint = "/promotions/tiers/#{ERB::Util.url_encode(code[:id] || code['id'])}/redemption"
else
endpoint = "/vouchers/#{URI.encode(code)}/redemption"
endpoint = "/vouchers/#{ERB::Util.url_encode(code)}/redemption"
end
@client.post(endpoint, params.to_json)
end
Expand All @@ -23,19 +23,19 @@ def list(query = {})
end

def get_for_voucher(code)
@client.get("/vouchers/#{URI.encode(code)}/redemption")
@client.get("/vouchers/#{ERB::Util.url_encode(code)}/redemption")
end

def rollback(redemption_id, payload = {})
reason = payload['reason'] || payload[:reason]
params = reason ? {:reason => reason} : {}
payload.delete 'reason'
payload.delete :reason
@client.post("/redemptions/#{URI.encode(redemption_id)}/rollback", payload.to_json, params)
@client.post("/redemptions/#{ERB::Util.url_encode(redemption_id)}/rollback", payload.to_json, params)
end

def get_redemption(redemption_id)
@client.get("/redemptions/#{URI.encode(redemption_id)}")
@client.get("/redemptions/#{ERB::Util.url_encode(redemption_id)}")
end
end
end
Expand Down
14 changes: 7 additions & 7 deletions lib/voucherify/service/rewards.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ def create(reward)
end

def get(reward_id)
@client.get("/rewards/#{URI.encode(reward_id)}")
@client.get("/rewards/#{ERB::Util.url_encode(reward_id)}")
end

def update(reward_id, reward)
@client.put("/rewards/#{URI.encode(reward_id)}", reward.to_json)
@client.put("/rewards/#{ERB::Util.url_encode(reward_id)}", reward.to_json)
end

def list(query = {})
@client.get("/rewards", query)
end

def delete(reward_id)
@client.delete("/rewards/#{URI.encode(reward_id)}")
@client.delete("/rewards/#{ERB::Util.url_encode(reward_id)}")
nil
end
end
Expand All @@ -43,19 +43,19 @@ def initialize(client)
end

def list(reward_id, query = {})
@client.get("/rewards/#{URI.encode(reward_id)}/assignments", query)
@client.get("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments", query)
end

def create(reward_id, assignment)
@client.post("/rewards/#{URI.encode(reward_id)}/assignments", assignment.to_json)
@client.post("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments", assignment.to_json)
end

def update(reward_id, assignment_id, assignment)
@client.put("/rewards/#{URI.encode(reward_id)}/assignments/#{URI.encode(assignment_id)}", assignment.to_json)
@client.put("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}", assignment.to_json)
end

def delete(reward_id, assignment_id)
@client.delete("/rewards/#{URI.encode(reward_id)}/assignments/#{URI.encode(assignment_id)}")
@client.delete("/rewards/#{ERB::Util.url_encode(reward_id)}/assignments/#{ERB::Util.url_encode(assignment_id)}")
nil
end
end
Expand Down
4 changes: 2 additions & 2 deletions lib/voucherify/service/segments.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def create(segment)
end

def get(id)
@client.get("/segments/#{URI.encode(id)}")
@client.get("/segments/#{ERB::Util.url_encode(id)}")
end

def delete(id)
@client.delete("/segments/#{URI.encode(id)}")
@client.delete("/segments/#{ERB::Util.url_encode(id)}")
end
end
end
Expand Down
Loading

0 comments on commit 158088b

Please sign in to comment.