Class: Knockapi::Resources::Schedules

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

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:



153
154
155
156
# File 'lib/knockapi/resources/schedules.rb', line 153

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

Instance Attribute Details

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



7
8
9
# File 'lib/knockapi/resources/schedules.rb', line 7

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](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the ‘actor`, `recipient`, and `tenant` fields.

Parameters:

Returns:

See Also:



41
42
43
44
45
46
47
48
49
50
# File 'lib/knockapi/resources/schedules.rb', line 41

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:



139
140
141
142
143
144
145
146
147
148
# File 'lib/knockapi/resources/schedules.rb', line 139

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:



115
116
117
118
119
120
121
122
123
124
125
# File 'lib/knockapi/resources/schedules.rb', line 115

def list(params)
  parsed, options = Knockapi::ScheduleListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "v1/schedules",
    query: parsed,
    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](/managing-recipients/identifying-recipients#inline-identifying-recipients) for the ‘actor`, `recipient`, and `tenant` fields.

Parameters:

Returns:

See Also:



82
83
84
85
86
87
88
89
90
91
# File 'lib/knockapi/resources/schedules.rb', line 82

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