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
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/schematic/events/client.rb', line 174 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
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/schematic/events/client.rb', line 27 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
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
# File 'lib/schematic/events/client.rb', line 210 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
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/schematic/events/client.rb', line 71 def get_event_summaries(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) 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) 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
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/schematic/events/client.rb', line 244 def get_segment_integration_status(request_options: {}, **_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
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
# File 'lib/schematic/events/client.rb', line 129 def list_events(request_options: {}, **params) params = Schematic::Internal::Types::Utils.normalize_keys(params) 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["idempotency_key"] = params[:idempotency_key] if params.key?(:idempotency_key) 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) 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 |