Class: Trycourier::Resources::Users::Tokens

Inherits:
Object
  • Object
show all
Defined in:
lib/trycourier/resources/users/tokens.rb

Instance Method Summary collapse

Constructor Details

#initialize(client:) ⇒ Tokens

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

Parameters:



177
178
179
# File 'lib/trycourier/resources/users/tokens.rb', line 177

def initialize(client:)
  @client = client
end

Instance Method Details

#add_multiple(user_id, request_options: {}) ⇒ nil

Adds multiple tokens to a user and overwrites matching existing tokens.

Parameters:

  • user_id (String)

    The user’s ID. This can be any uniquely identifiable string.

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

Returns:

  • (nil)

See Also:



122
123
124
125
126
127
128
129
# File 'lib/trycourier/resources/users/tokens.rb', line 122

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

#add_single(path_token, user_id: , provider_key: , body_token: nil, device: nil, expiry_date: nil, properties: nil, tracking: nil, request_options: {}) ⇒ nil

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

Adds a single token to a user and overwrites a matching existing token.

Parameters:

  • path_token (String)

    Path param: The full token string.

  • user_id (String)

    Path param: The user’s ID. This can be any uniquely identifiable string.

  • provider_key (Symbol, Trycourier::Models::Users::UserToken::ProviderKey)

    Body param:

  • body_token (String, nil)

    Body param: Full body of the token. Must match token in URL.

  • device (Trycourier::Models::Users::UserToken::Device, nil)

    Body param: Information about the device the token is associated with.

  • expiry_date (String, Boolean, nil)

    Body param: ISO 8601 formatted date the token expires. Defaults to 2 months. Set

  • properties (Object)

    Body param: Properties sent to the provider along with the token

  • tracking (Trycourier::Models::Users::UserToken::Tracking, nil)

    Body param: Information about the device the token is associated with.

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

Returns:

  • (nil)

See Also:



159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/trycourier/resources/users/tokens.rb', line 159

def add_single(path_token, params)
  parsed, options = Trycourier::Users::TokenAddSingleParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :put,
    path: ["users/%1$s/tokens/%2$s", user_id, path_token],
    body: parsed,
    model: NilClass,
    options: options
  )
end

#delete(token, user_id: , request_options: {}) ⇒ nil

Delete User Token

Parameters:

  • token (String)

    The full token string.

  • user_id (String)

    The user’s ID. This can be any uniquely identifiable string.

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

Returns:

  • (nil)

See Also:



97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/trycourier/resources/users/tokens.rb', line 97

def delete(token, params)
  parsed, options = Trycourier::Users::TokenDeleteParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :delete,
    path: ["users/%1$s/tokens/%2$s", user_id, token],
    model: NilClass,
    options: options
  )
end

#list(user_id, request_options: {}) ⇒ Array<Trycourier::Models::Users::UserToken>

Gets all tokens available for a :user_id

Parameters:

  • user_id (String)

    The user’s ID. This can be any uniquely identifiable string.

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

Returns:

See Also:



75
76
77
78
79
80
81
82
# File 'lib/trycourier/resources/users/tokens.rb', line 75

def list(user_id, params = {})
  @client.request(
    method: :get,
    path: ["users/%1$s/tokens", user_id],
    model: Trycourier::Internal::Type::ArrayOf[Trycourier::Users::UserToken],
    options: params[:request_options]
  )
end

#retrieve(token, user_id: , request_options: {}) ⇒ Trycourier::Models::Users::TokenRetrieveResponse

Get single token available for a ‘:token`

Parameters:

  • token (String)

    The full token string.

  • user_id (String)

    The user’s ID. This can be any uniquely identifiable string.

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

Returns:

See Also:



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/trycourier/resources/users/tokens.rb', line 20

def retrieve(token, params)
  parsed, options = Trycourier::Users::TokenRetrieveParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :get,
    path: ["users/%1$s/tokens/%2$s", user_id, token],
    model: Trycourier::Models::Users::TokenRetrieveResponse,
    options: options
  )
end

#update(token, user_id: , patch: , request_options: {}) ⇒ nil

Apply a JSON Patch (RFC 6902) to the specified token.

Parameters:

Returns:

  • (nil)

See Also:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/trycourier/resources/users/tokens.rb', line 49

def update(token, params)
  parsed, options = Trycourier::Users::TokenUpdateParams.dump_request(params)
  user_id =
    parsed.delete(:user_id) do
      raise ArgumentError.new("missing required path argument #{_1}")
    end
  @client.request(
    method: :patch,
    path: ["users/%1$s/tokens/%2$s", user_id, token],
    body: parsed,
    model: NilClass,
    options: options
  )
end