Class: Reach::REST::Api::Authentix::ConfigurationItemContext::AuthenticationItemList

Inherits:
ListResource
  • Object
show all
Defined in:
lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb

Instance Method Summary collapse

Constructor Details

#initialize(version, configuration_id: nil) ⇒ AuthenticationItemList

Initialize the AuthenticationItemList

Parameters:

  • version (Version)

    Version that contains the resource



28
29
30
31
32
33
34
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 28

def initialize(version, configuration_id: nil)
    super(version)
    # Path Solution
    @solution = { configuration_id: configuration_id }
    @uri = "/authentix/v1/configurations/#{@solution[:configuration_id]}/authentications"
    
end

Instance Method Details

#eachObject

When passed a block, yields AuthenticationItemInstance records from the API. This operation lazily loads records as efficiently as possible until the limit is reached.



120
121
122
123
124
125
126
127
128
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 120

def each
    limits = @version.read_limits

    page = self.page(page_size: limits[:page_size], )

    @version.stream(page,
        limit: limits[:limit],
        page_limit: limits[:page_limit]).each {|x| yield x}
end

#get_page(target_url) ⇒ Page

Retrieve a single page of AuthenticationItemInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of AuthenticationItemInstance



154
155
156
157
158
159
160
161
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 154

def get_page(target_url)
    baseUrl = @version.url_without_pagination_info(target_url)
    response = @version.domain.request(
        'GET',
        target_url
    )
AuthenticationItemPage.new(baseUrl, @version, response, @solution)
end

#list(limit: nil, page_size: nil) ⇒ Array

Lists AuthenticationItemInstance records from the API as a list. Unlike stream(), this operation is eager and will load ‘limit` records into memory before returning.

Parameters:

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Array)

    Array of up to limit results



89
90
91
92
93
94
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 89

def list(limit: nil, page_size: nil)
    self.stream(
        limit: limit,
        page_size: page_size
    ).entries
end

#page(page_token: :unset, page_number: :unset, page_size: :unset) ⇒ Page

Retrieve a single page of AuthenticationItemInstance records from the API. Request is executed immediately.

Parameters:

  • page_number (Integer) (defaults to: :unset)

    Page Number, this value is simply for client state

  • page_size (Integer) (defaults to: :unset)

    Number of records to return, defaults to 20

Returns:

  • (Page)

    Page of AuthenticationItemInstance



136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 136

def page(page_token: :unset, page_number: :unset, page_size: :unset)
    params = Reach::Values.of({
        
        'page' => page_number,
        'pageSize' => page_size,
    })

    baseUrl = @version.url_without_pagination_info(@version.absolute_url(@uri), params)
    response = @version.page('GET', @uri, params: params)

    AuthenticationItemPage.new(baseUrl, @version, response, @solution)
end

#start(dest: nil, channel: nil, service_name: :unset, custom_code: :unset, payment_info: :unset, template_id: :unset, template_data_map: :unset) ⇒ AuthenticationItemInstance

Start the AuthenticationItemInstance

Parameters:

  • dest (String) (defaults to: nil)

    The phone number or email where to send the authentication code. Phone numbers must be in E.164 format.

  • channel (String) (defaults to: nil)

    The channel by which the authentication code is sent.

  • service_name (String) (defaults to: :unset)

    a service name overwriting the one defined in the configuration.

  • custom_code (String) (defaults to: :unset)

    the pre-generated code to be sent. Its length should be between 4 and 10 inclusive.

  • payment_info (String) (defaults to: :unset)

    Information related to the digital payment to authenticate. It is required when ‘usedForDigitalPayment` is true. It is ignored otherwise. It is a stringfied JSON map where keys are `payee`, `amount`, and `currency` and the associated values are respectively the payee, the amount, and the currency of a financial transaction.

  • template_id (String) (defaults to: :unset)

    This is the ID of the message template to use for sending the authenetication code. It could be an sms or email template depending on the channel being used. It overwirites the template ID defined in the configuration if any.

  • template_data_map (String) (defaults to: :unset)

    A stringfied JSON map where keys are message template parameters and the values are the parameter values to be used when sending the authentication code. It may also be used to provide additional parameters for sending email based authentications such as the email used for sending the code.

Returns:



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 45

def start(
    dest: nil, 
    channel: nil, 
    service_name: :unset, 
    custom_code: :unset, 
    payment_info: :unset, 
    template_id: :unset, 
    template_data_map: :unset
)

    baseParams = {
    }
    data = Reach::Values.of(baseParams.merge({                        
        'dest' => dest,
        'channel' => channel,
        'serviceName' => service_name,
        'customCode' => custom_code,
        'paymentInfo' => payment_info,
        'templateId' => template_id,
        'templateDataMap' => template_data_map,
    }))

    
    
    payload = @version.start('POST', @uri, data: data)
    AuthenticationItemInstance.new(
        @version,
        payload,
        configuration_id: @solution[:configuration_id],
    )
end

#stream(limit: nil, page_size: nil) ⇒ Enumerable

Streams Instance records from the API as an Enumerable. This operation lazily loads records as efficiently as possible until the limit is reached.

Parameters:

  • limit (Integer) (defaults to: nil)

    Upper limit for the number of records to return. stream() guarantees to never return more than limit. Default is no limit

  • page_size (Integer) (defaults to: nil)

    Number of records to fetch per request, when not set will use the default value of 50 records. If no page_size is defined but a limit is defined, stream() will attempt to read the limit with the most efficient page size, i.e. min(limit, 1000)

Returns:

  • (Enumerable)

    Enumerable that will yield up to limit results



107
108
109
110
111
112
113
114
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 107

def stream(limit: nil, page_size: nil)
    limits = @version.read_limits(limit, page_size)

    page = self.page(
        page_size: limits[:page_size], )

    @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
end

#to_sObject

Provide a user friendly representation



166
167
168
# File 'lib/reach-ruby/rest/api/authentix/configuration_item/authentication_item.rb', line 166

def to_s
    '#<Reach.Api.Authentix.AuthenticationItemList>'
end