Class: Intrinsic::AsyncEventTypesClient

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:) ⇒ AsyncEventTypesClient

Parameters:



54
55
56
57
# File 'lib/intrinsic/event_types/client.rb', line 54

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

Instance Attribute Details

#request_clientObject (readonly)

Returns the value of attribute request_client.



50
51
52
# File 'lib/intrinsic/event_types/client.rb', line 50

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:



79
80
81
82
83
84
85
86
87
88
89
# File 'lib/intrinsic/event_types/client.rb', line 79

def create_event_type(name:, fields:, request_options: nil)
  Async do
    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
end

#get_event_types(request_options: nil) ⇒ ListEventTypesResponse

Parameters:

Returns:



61
62
63
64
65
66
67
68
69
70
# File 'lib/intrinsic/event_types/client.rb', line 61

def get_event_types(request_options: nil)
  Async do
    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
end