Class: EventTypeApi
- Inherits:
-
Object
- Object
- EventTypeApi
- Includes:
- Validation
- Defined in:
- lib/tacklebox/apis/event_type_api.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
Returns the value of attribute base_url.
-
#http_client ⇒ Object
Returns the value of attribute http_client.
Instance Method Summary collapse
- #create_event_type(service_id, event_type_data) ⇒ Object
- #delete_event_type(service_id, event_type_id) ⇒ Object
- #get_event_type(service_id, event_type_id) ⇒ Object
-
#initialize(config) ⇒ EventTypeApi
constructor
A new instance of EventTypeApi.
- #list_event_types(service_id) ⇒ Object
Methods included from Validation
#is_valid_data, #is_valid_event_data, #is_valid_id, #is_valid_name, #is_valid_subscription_data
Constructor Details
#initialize(config) ⇒ EventTypeApi
Returns a new instance of EventTypeApi.
10 11 12 13 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 10 def initialize(config) self.base_url = config[:base_url] self.http_client = HttpClient.new(config[:api_key]) end |
Instance Attribute Details
#base_url ⇒ Object
Returns the value of attribute base_url.
8 9 10 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 8 def base_url @base_url end |
#http_client ⇒ Object
Returns the value of attribute http_client.
8 9 10 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 8 def http_client @http_client end |
Instance Method Details
#create_event_type(service_id, event_type_data) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 28 def create_event_type(service_id, event_type_data) if !self.is_valid_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The create_event_types method must be invoked with a non-empty string service_id argument." ) elsif !self.is_valid_data(event_type_data) return new_error( ERROR_TYPES['missing_parameter'], "The create_event_types method must be invoked with an event_type_data object that contains a non-empty string name property." ) end path = "services/#{service_id}/event_types" request = HttpRequest.new("POST", @base_url, path, event_type_data) @http_client.send(request) end |
#delete_event_type(service_id, event_type_id) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 46 def delete_event_type(service_id, event_type_id) if !self.is_valid_service_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The delete_event_type method must be invoked with a non-empty string service_id argument." ) elsif !self.event_type_id(event_type_id) return new_error( ERROR_TYPES['missing_parameter'], "The delete_event_type method must be invoked with a non-empty string event_type_id argument." ) end path = "services/#{service_id}/event_types/#{event_type_id}" request = HttpRequest.new("DELETE", @base_url, path) @http_client.send(request) end |
#get_event_type(service_id, event_type_id) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 64 def get_event_type(service_id, event_type_id) if !self.is_valid_service_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The get_event_type method must be invoked with a non-empty string service_id argument." ) elsif !self.event_type_id(event_type_id) return new_error( ERROR_TYPES['missing_parameter'], "The get_event_type method must be invoked with a non-empty string event_type_id argument." ) end path = "services/#{service_id}/event_types/#{event_type_id}" request = HttpRequest.new("GET", @base_url, path) @http_client.send(request) end |
#list_event_types(service_id) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/tacklebox/apis/event_type_api.rb', line 15 def list_event_types(service_id) if !self.is_valid_id(service_id) return new_error( ERROR_TYPES['missing_parameter'], "The list_event_types method must be invoked with a non-empty string service_id argument." ) end path = "services/#{service_id}/event_types" request = HttpRequest.new("GET", @base_url, path) @http_client.send(request) end |