Class: Intrinsic::EventTypesClient

Inherits:
Object
  • Object
show all
Defined in:
lib/intrinsic/event_types/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request_client:) ⇒ EventTypesClient

Parameters:



15
16
17
18
# File 'lib/intrinsic/event_types/client.rb', line 15

def initialize(request_client:)
  # @type [RequestClient]
  @request_client = request_client
end

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



11
12
13
# File 'lib/intrinsic/event_types/client.rb', line 11

def request_client
  @request_client
end

Instance Method Details

#create_event_type(name:, fields:, request_options: nil) ⇒ EventTypeObject

Parameters:

  • name (String)

    Name of the event type to create.

  • fields (Array<Hash>)

    Fields of the event typeRequest of type Array<EventTypeField>, as a Hash

    • :field_name (String)

    • :type (EVENT_TYPE_FIELD_TYPE)

    • :optional (Boolean)

  • request_options (RequestOptions) (defaults to: nil)

Returns:



38
39
40
41
42
43
44
45
46
# File 'lib/intrinsic/event_types/client.rb', line 38

def create_event_type(name:, fields:, request_options: nil)
  response = @request_client.conn.post("/api/v2/event-types") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
    req.body = { **(request_options&.additional_body_parameters || {}), name: name, fields: fields }.compact
  end
  EventTypeObject.from_json(json_object: response.body)
end

#get_event_types(request_options: nil) ⇒ ListEventTypesResponse

Parameters:

Returns:



22
23
24
25
26
27
28
29
# File 'lib/intrinsic/event_types/client.rb', line 22

def get_event_types(request_options: nil)
  response = @request_client.conn.get("/api/v2/event-types") do |req|
    req.options.timeout = request_options.timeout_in_seconds unless request_options&.timeout_in_seconds.nil?
    req.headers["X-API-Key"] = request_options.api_key unless request_options&.api_key.nil?
    req.headers = { **req.headers, **(request_options&.additional_headers || {}) }.compact
  end
  ListEventTypesResponse.from_json(json_object: response.body)
end