Class: TicketEvolution::Endpoint
- Includes:
- RequestHandler, SingularClass
- Defined in:
- lib/ticket_evolution/core/endpoint.rb,
lib/ticket_evolution/core/endpoint/request_handler.rb
Direct Known Subclasses
Accounts, Accounts::Transactions, AddressCheck, Affiliates, Brokerages, Categories, Cities, Clients, Clients::Addresses, Clients::CreditCards, Clients::EmailAddresses, Clients::PhoneNumbers, Commissions, Commissions::CommissionPayments, Companies, Configurations, Credentials, CreditMemos, CreditMemos::CreditMemoPayments, CustomPages, Events, FilteredTickets, Offices, Offices::CreditCards, Orders, Orders::Items, Payments, Performers, PromotionCodes, QueuedOrders, Quotes, RateOptions, Reports, Search, Searches, Settings, Shipments, TicketGroups, TicketGroups::TicketHolds, TrackDetails, Transactions, Users, Venues
Defined Under Namespace
Modules: RequestHandler
Constant Summary
Constants included from RequestHandler
Instance Method Summary collapse
- #base_path ⇒ Object
- #connection ⇒ Object
- #endpoint_name ⇒ Object
- #has_connection? ⇒ Boolean
-
#id ⇒ Object
Ruby 1.8.7 / REE compatibility.
-
#initialize(options = nil) ⇒ Endpoint
constructor
A new instance of Endpoint.
- #method_missing(method, *args) ⇒ Object
Methods included from SingularClass
Methods included from RequestHandler
#build_request, #collection_handler, #naturalize_response, #raw_handler, #request, #upload_history_handler
Constructor Details
#initialize(options = nil) ⇒ Endpoint
Returns a new instance of Endpoint.
6 7 8 9 10 11 12 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 6 def initialize( = nil) raise EndpointConfigurationError, "#{self.class.to_s} instances require a hash as their first parameter" unless .is_a? Hash raise EndpointConfigurationError, "The options hash must include a parent key / value pair" unless [:parent].present? raise EndpointConfigurationError, "#{self.class.to_s} instances require a parent which inherits from TicketEvolution::Base" unless [:parent].kind_of? TicketEvolution::Base @options = .with_indifferent_access raise EndpointConfigurationError, "The parent passed in the options hash must be a TicketEvolution::Connection object or have one in it's parent chain" unless has_connection? end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
40 41 42 43 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 40 def method_missing(method, *args) name = method.to_s @options.keys.include?(name) ? @options[name] : super end |
Instance Method Details
#base_path ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 14 def base_path [].tap do |parts| parts << parent.base_path if parent.kind_of? TicketEvolution::Endpoint parts << "/"+endpoint_name parts << "/#{self.id}" if self.id.present? end.join end |
#connection ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 22 def connection if self.parent.is_a? TicketEvolution::Connection self.parent elsif self.parent.kind_of? TicketEvolution::Endpoint self.parent.connection else nil end end |
#endpoint_name ⇒ Object
36 37 38 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 36 def endpoint_name self.class.name.demodulize.underscore end |
#has_connection? ⇒ Boolean
32 33 34 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 32 def has_connection? connection.present? end |
#id ⇒ Object
Ruby 1.8.7 / REE compatibility
46 47 48 |
# File 'lib/ticket_evolution/core/endpoint.rb', line 46 def id @options[:id] end |