Class: Schematic::Events::Client
- Inherits:
-
Object
- Object
- Schematic::Events::Client
- Defined in:
- lib/schematic/events/client.rb
Instance Method Summary collapse
- #create_event(request_options: {}, **params) ⇒ Schematic::Events::Types::CreateEventResponse
- #create_event_batch(request_options: {}, **params) ⇒ Schematic::Events::Types::CreateEventBatchResponse
- #get_event(request_options: {}, **params) ⇒ Schematic::Events::Types::GetEventResponse
- #get_event_summaries(request_options: {}, **params) ⇒ Schematic::Events::Types::GetEventSummariesResponse
- #get_segment_integration_status(request_options: {}, **params) ⇒ Schematic::Events::Types::GetSegmentIntegrationStatusResponse
- #initialize(client:) ⇒ void constructor
- #list_events(request_options: {}, **params) ⇒ Schematic::Events::Types::ListEventsResponse
Constructor Details
#initialize(client:) ⇒ void
9 10 11 |
# File 'lib/schematic/events/client.rb', line 9 def initialize(client:) @client = client end |
Instance Method Details
#create_event(request_options: {}, **params) ⇒ Schematic::Events::Types::CreateEventResponse
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/schematic/events/client.rb', line 148 def create_event(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "events", body: Schematic::Types::CreateEventRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Events::Types::CreateEventResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#create_event_batch(request_options: {}, **params) ⇒ Schematic::Events::Types::CreateEventBatchResponse
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/schematic/events/client.rb', line 22 def create_event_batch(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "POST", path: "event-batch", body: Schematic::Events::Types::CreateEventBatchRequestBody.new(params).to_h, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Events::Types::CreateEventBatchResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_event(request_options: {}, **params) ⇒ Schematic::Events::Types::GetEventResponse
181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
# File 'lib/schematic/events/client.rb', line 181 def get_event(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "events/#{URI.encode_uri_component(params[:event_id].to_s)}", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Events::Types::GetEventResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_event_summaries(request_options: {}, **params) ⇒ Schematic::Events::Types::GetEventSummariesResponse
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/schematic/events/client.rb', line 58 def get_event_summaries(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[q event_subtypes limit offset] query_params = {} query_params["q"] = params[:q] if params.key?(:q) query_params["event_subtypes"] = params[:event_subtypes] if params.key?(:event_subtypes) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) params.except(*query_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "event-types", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Events::Types::GetEventSummariesResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#get_segment_integration_status(request_options: {}, **params) ⇒ Schematic::Events::Types::GetSegmentIntegrationStatusResponse
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/schematic/events/client.rb', line 212 def get_segment_integration_status(request_options: {}, **params) Schematic::Internal::Types::Utils.normalize_keys(params) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "segment-integration", request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Events::Types::GetSegmentIntegrationStatusResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |
#list_events(request_options: {}, **params) ⇒ Schematic::Events::Types::ListEventsResponse
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/schematic/events/client.rb', line 105 def list_events(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) query_param_names = %i[company_id event_subtype event_types flag_id user_id limit offset] query_params = {} query_params["company_id"] = params[:company_id] if params.key?(:company_id) query_params["event_subtype"] = params[:event_subtype] if params.key?(:event_subtype) query_params["event_types"] = params[:event_types] if params.key?(:event_types) query_params["flag_id"] = params[:flag_id] if params.key?(:flag_id) query_params["user_id"] = params[:user_id] if params.key?(:user_id) query_params["limit"] = params[:limit] if params.key?(:limit) query_params["offset"] = params[:offset] if params.key?(:offset) params.except(*query_param_names) request = Schematic::Internal::JSON::Request.new( base_url: [:base_url], method: "GET", path: "events", query: query_params, request_options: ) begin response = @client.send(request) rescue Net::HTTPRequestTimeout raise Schematic::Errors::TimeoutError end code = response.code.to_i if code.between?(200, 299) Schematic::Events::Types::ListEventsResponse.load(response.body) else error_class = Schematic::Errors::ResponseError.subclass_for_code(code) raise error_class.new(response.body, code: code) end end |