Class: Trycourier::Resources::Lists

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/resources/lists.rb,
lib/trycourier/resources/lists/subscriptions.rb

Defined Under Namespace

Classes: Subscriptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Lists

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 Lists.

Parameters:



125
126
127
128
# File 'lib/trycourier/resources/lists.rb', line 125

def initialize(client:)
  @client = client
  @subscriptions = Trycourier::Resources::Lists::Subscriptions.new(client: client)
end

Instance Attribute Details

#subscriptionsTrycourier::Resources::Lists::Subscriptions (readonly)



7
8
9
# File 'lib/trycourier/resources/lists.rb', line 7

def subscriptions
  @subscriptions
end

Instance Method Details

#delete(list_id, request_options: {}) ⇒ nil

Delete a list by list ID.

Parameters:

  • list_id (String)

    A unique identifier representing the list you wish to retrieve.

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

Returns:

  • (nil)

See Also:



93
94
95
96
97
98
99
100
# File 'lib/trycourier/resources/lists.rb', line 93

def delete(list_id, params = {})
  @client.request(
    method: :delete,
    path: ["lists/%1$s", list_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#list(cursor: nil, pattern: nil, request_options: {}) ⇒ Trycourier::Models::ListListResponse

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

Returns all of the lists, with the ability to filter based on a pattern.

Parameters:

  • cursor (String, nil)

    A unique identifier that allows for fetching the next page of lists.

  • pattern (String, nil)

    “A pattern used to filter the list items returned. Pattern types supported: exac

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

Returns:

See Also:



71
72
73
74
75
76
77
78
79
80
# File 'lib/trycourier/resources/lists.rb', line 71

def list(params = {})
  parsed, options = Trycourier::ListListParams.dump_request(params)
  @client.request(
    method: :get,
    path: "lists",
    query: parsed,
    model: Trycourier::Models::ListListResponse,
    options: options
  )
end

#restore(list_id, request_options: {}) ⇒ nil

Restore a previously deleted list.

Parameters:

  • list_id (String)

    A unique identifier representing the list you wish to retrieve.

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

Returns:

  • (nil)

See Also:



113
114
115
116
117
118
119
120
# File 'lib/trycourier/resources/lists.rb', line 113

def restore(list_id, params = {})
  @client.request(
    method: :put,
    path: ["lists/%1$s/restore", list_id],
    model: NilClass,
    options: params[:request_options]
  )
end

#retrieve(list_id, request_options: {}) ⇒ Trycourier::Models::SubscriptionList

Returns a list based on the list ID provided.

Parameters:

  • list_id (String)

    A unique identifier representing the list you wish to retrieve.

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

Returns:

See Also:



20
21
22
23
24
25
26
27
# File 'lib/trycourier/resources/lists.rb', line 20

def retrieve(list_id, params = {})
  @client.request(
    method: :get,
    path: ["lists/%1$s", list_id],
    model: Trycourier::SubscriptionList,
    options: params[:request_options]
  )
end

#update(list_id, name: , preferences: nil, request_options: {}) ⇒ nil

Create or replace an existing list with the supplied values.

Parameters:

Returns:

  • (nil)

See Also:



44
45
46
47
48
49
50
51
52
53
# File 'lib/trycourier/resources/lists.rb', line 44

def update(list_id, params)
  parsed, options = Trycourier::ListUpdateParams.dump_request(params)
  @client.request(
    method: :put,
    path: ["lists/%1$s", list_id],
    body: parsed,
    model: NilClass,
    options: options
  )
end