Class: SignalApi::CouponGroup
- Inherits:
-
SignalHttpApi
- Object
- SignalHttpApi
- SignalApi::CouponGroup
- Defined in:
- lib/signal_api/coupon_group.rb
Overview
manage a copuon group using signals api
Class Method Summary collapse
-
.consume_coupon(coupon_group_tag, mobile_phone) ⇒ Object
Consume a coupon.
Class Method Details
.consume_coupon(coupon_group_tag, mobile_phone) ⇒ Object
Consume a coupon
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/signal_api/coupon_group.rb', line 12 def self.consume_coupon(coupon_group_tag, mobile_phone) validate_consume_coupon_parameters(coupon_group_tag, mobile_phone) SignalApi.logger.info "Attempting to consume coupon from group #{coupon_group_tag} #{mobile_phone}" xml = Builder::XmlMarkup.new xml.request do xml.user do xml.tag!('mobile_phone',mobile_phone) end xml.tag!('coupon_group', coupon_group_tag) end with_retries do response = get('/api/coupon_groups/consume_coupon.xml', :body => xml.target!, :format => :xml, :headers => common_headers) if response.code == 200 response.parsed_response['coupon_code'] else handle_api_failure(response) end end end |