Class: NewStoreApi::EventsController

Inherits:
BaseController show all
Defined in:
lib/new_store_api/controllers/events_controller.rb

Overview

EventsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent

Constructor Details

This class inherits a constructor from NewStoreApi::BaseController

Instance Method Details

#create_event(event_name, team, service, entity_id, tenant, idempotency_key, body, correlation_ids: nil) ⇒ Object

🚧 BETA: This endpoint is in beta and may change.
See API Lifecycle Documentation for details.
â„šī¸ Rate Limit: This endpoint is rate limited to 100 requests per second.
publish (e.g. order.created). allowlist. event is about. deduplication. 40 MiB. keys: `order_id`, `customer_id`.

Parameters:

  • event_name (String)

    Required parameter: Name of the event to

  • team (String)

    Required parameter: Publishing team — must be in the

  • service (String)

    Required parameter: Publishing service name.

  • entity_id (String)

    Required parameter: ID of the domain entity the

  • tenant (String)

    Required parameter: Tenant identifier.

  • idempotency_key (String)

    Required parameter: Unique key for

  • body (Object)

    Required parameter: Event payload — JSON object, max

  • correlation_ids (String) (defaults to: nil)

    Optional parameter: JSON object — accepted

Returns:

  • (Object)

    Response from the API call.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/new_store_api/controllers/events_controller.rb', line 39

def create_event(event_name,
                 team,
                 service,
                 entity_id,
                 tenant,
                 idempotency_key,
                 body,
                 correlation_ids: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/event-stream/events/{event_name}',
                                 Server::API)
               .template_param(new_parameter(event_name, key: 'event_name')
                                .should_encode(true))
               .header_param(new_parameter(team, key: 'Team'))
               .header_param(new_parameter(service, key: 'Service'))
               .header_param(new_parameter(entity_id, key: 'Entity-Id'))
               .header_param(new_parameter(tenant, key: 'Tenant'))
               .header_param(new_parameter(idempotency_key, key: 'Idempotency-Key'))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body))
               .header_param(new_parameter(correlation_ids, key: 'Correlation-Ids'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(APIHelper.method(:json_serialize))
               .auth(Single.new('oauth')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:json_deserialize)))
    .execute
end