Class: Knockapi::Resources::Schedules

Inherits:
Object
  • Object
show all
Defined in:
lib/knockapi/resources/schedules.rb,
lib/knockapi/resources/schedules/bulk.rb,
sig/knockapi/resources/schedules.rbs,
sig/knockapi/resources/schedules/bulk.rbs

Overview

A schedule is a per-recipient, timezone-aware configuration for when to invoke a workflow.

Defined Under Namespace

Classes: Bulk

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Schedules

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Schedules.

Parameters:



158
159
160
161
# File 'lib/knockapi/resources/schedules.rb', line 158

def initialize(client:)
  @client = client
  @bulk = Knockapi::Resources::Schedules::Bulk.new(client: client)
end

Instance Attribute Details

#bulkKnockapi::Resources::Schedules::Bulk (readonly)

A bulk operation is a set of changes applied across zero or more records triggered via a call to the Knock API and performed asynchronously.



11
12
13
# File 'lib/knockapi/resources/schedules.rb', line 11

def bulk
  @bulk
end

Instance Method Details

#create(recipients:, workflow:, actor: nil, data: nil, ending_at: nil, repeats: nil, scheduled_at: nil, tenant: nil, request_options: {}) ⇒ Array<Knockapi::Models::Schedule>

Some parameter documentations has been truncated, see Models::ScheduleCreateParams for more details.

Creates one or more schedules for a workflow with the specified recipients, timing, and data. Schedules can be one-time or recurring. This endpoint also handles inline identifications for the actor, recipient, and tenant fields.

Parameters:

Returns:

See Also:



45
46
47
48
49
50
51
52
53
54
# File 'lib/knockapi/resources/schedules.rb', line 45

def create(params)
  parsed, options = Knockapi::ScheduleCreateParams.dump_request(params)
  @client.request(
    method: :post,
    path: "v1/schedules",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Schedule],
    options: options
  )
end

#delete(schedule_ids:, request_options: {}) ⇒ Array<Knockapi::Models::Schedule>

Permanently deletes one or more schedules identified by the provided schedule IDs. This operation cannot be undone.

Parameters:

Returns:

See Also:



144
145
146
147
148
149
150
151
152
153
# File 'lib/knockapi/resources/schedules.rb', line 144

def delete(params)
  parsed, options = Knockapi::ScheduleDeleteParams.dump_request(params)
  @client.request(
    method: :delete,
    path: "v1/schedules",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Schedule],
    options: options
  )
end

#list(workflow:, after: nil, before: nil, page_size: nil, recipients: nil, tenant: nil, request_options: {}) ⇒ Knockapi::Internal::EntriesCursor<Knockapi::Models::Schedule>

Returns a paginated list of schedules for the current environment, filtered by workflow and optionally by recipients and tenant.

Parameters:

  • workflow (String)

    Filter by workflow key.

  • after (String)

    The cursor to fetch entries after.

  • before (String)

    The cursor to fetch entries before.

  • page_size (Integer)

    The number of items per page (defaults to 50).

  • recipients (Array<String, Knockapi::Models::RecipientReference::ObjectReference>)

    Filter by recipient references.

  • tenant (String)

    Filter by tenant ID.

  • request_options (Knockapi::RequestOptions, Hash{Symbol=>Object}, nil)

Returns:

See Also:



119
120
121
122
123
124
125
126
127
128
129
130
# File 'lib/knockapi/resources/schedules.rb', line 119

def list(params)
  parsed, options = Knockapi::ScheduleListParams.dump_request(params)
  query = Knockapi::Internal::Util.encode_query_params(parsed)
  @client.request(
    method: :get,
    path: "v1/schedules",
    query: query,
    page: Knockapi::Internal::EntriesCursor,
    model: Knockapi::Schedule,
    options: options
  )
end

#update(schedule_ids:, actor: nil, data: nil, ending_at: nil, repeats: nil, scheduled_at: nil, tenant: nil, request_options: {}) ⇒ Array<Knockapi::Models::Schedule>

Some parameter documentations has been truncated, see Models::ScheduleUpdateParams for more details.

Updates one or more existing schedules with new timing, data, or other properties. All specified schedule IDs will be updated with the same values. This endpoint also handles inline identifications for the actor, recipient, and tenant fields.

Parameters:

Returns:

See Also:



86
87
88
89
90
91
92
93
94
95
# File 'lib/knockapi/resources/schedules.rb', line 86

def update(params)
  parsed, options = Knockapi::ScheduleUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: "v1/schedules",
    body: parsed,
    model: Knockapi::Internal::Type::ArrayOf[Knockapi::Schedule],
    options: options
  )
end