Class: Centaman::Service
Overview
:nodoc:
Direct Known Subclasses
AddOn, AuthenticateMember, BookingTime, BookingType, Capacity, CostRate, CouponCheck, CreateCustomer, CreateMember, CreatePrimaryMember, CreateSecondaryMembers, CreateUdf, Extra, GeneralAdmissionTicket, GiftTicket, HoldTicket, Member, MembershipType, PurchaseMembership, PurchaseTicket, TicketType, UpdateMember
Defined Under Namespace
Classes: AddOn, AuthenticateMember, BookingTime, BookingType, Capacity, CostRate, CouponCheck, CreateCustomer, CreateMember, CreatePrimaryMember, CreateRetailCustomer, CreateSecondaryMembers, CreateUdf, Extra, GeneralAdmissionTicket, GiftTicket, HoldTicket, Member, MembershipType, PurchaseMembership, PurchaseTicket, TicketType, UpdateMember
Constant Summary
Constants inherited from Wrapper
Instance Attribute Summary
Attributes inherited from Wrapper
#api_password, #api_token, #api_url, #api_username, #proxie_host, #proxie_password, #proxie_port, #proxie_user
Instance Method Summary collapse
- #after_init(args) ⇒ Object
- #after_post(response) ⇒ Object
- #fetch_all ⇒ Object
- #post ⇒ Object
- #put ⇒ Object
Methods inherited from Wrapper
#generate_token, #headers, #initialize, #options, #options_hash, #payload, #payload_key, #proxy_hash, #wrap_request_in_case_of_timeout
Constructor Details
This class inherits a constructor from Centaman::Wrapper
Instance Method Details
#after_init(args) ⇒ Object
4 5 6 |
# File 'lib/centaman/service.rb', line 4 def after_init(args) # overwritten by subclasses end |
#after_post(response) ⇒ Object
41 42 43 |
# File 'lib/centaman/service.rb', line 41 def after_post(response) build_object(response) end |
#fetch_all ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/centaman/service.rb', line 8 def fetch_all @get_request ||= begin req = Proc.new do self.class.get("#{api_url}#{endpoint}", payload(:get)) end resp = wrap_request_in_case_of_timeout(req, timeout_time: 20) raise resp['Message'] if resp && resp.is_a?(Hash) # raise Exceptions::CentamanError.new(resp) unless resp && resp.success? resp end end |
#post ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/centaman/service.rb', line 21 def post @post_request ||= begin req = Proc.new do self.class.post("#{api_url}#{endpoint}", payload(:post)) end resp = wrap_request_in_case_of_timeout(req) self.respond_to?(:build_object) ? after_post(resp) : resp end end |
#put ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/centaman/service.rb', line 31 def put @put_request ||= begin req = Proc.new do self.class.put("#{api_url}#{endpoint}", payload(:put)) end resp = wrap_request_in_case_of_timeout(req) self.respond_to?(:build_object) ? after_post(resp) : resp end end |