Class: Reach::REST::Api::Authentix::ConfigurationItemList

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

Instance Method Summary collapse

Constructor Details

#initialize(version) ⇒ ConfigurationItemList

Initialize the ConfigurationItemList

Parameters:

  • version (Version)

    Version that contains the resource



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

def initialize(version)
    super(version)
    # Path Solution
    @solution = {  }
    @uri = "/authentix/v1/configurations"
    
end

Instance Method Details

#create(service_name: nil, code_length: :unset, allow_custom_code: :unset, used_for_digital_payment: :unset, default_expiry_time: :unset, default_max_trials: :unset, default_max_controls: :unset, smtp_setting_id: :unset, email_template_id: :unset, sms_template_id: :unset) ⇒ ConfigurationItemInstance

Create the ConfigurationItemInstance

Parameters:

  • service_name (String) (defaults to: nil)

    The name of the authentication service attached to this configuration. It can be up to 40 characters long.

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

    The length of the code to be generated. It must be a value between 4 and 10, inclusive. If not specified, the default value is 5.

  • allow_custom_code (Boolean) (defaults to: :unset)

    A flag indicating if the configuration should allow sending custom and non-generated code.

  • used_for_digital_payment (Boolean) (defaults to: :unset)

    A flag indicating if the configuration is used to authenticate digital payments. In such a case, additional information such as the amount and the payee of the financial transaction should be sent to when starting the authentication.

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

    It represents how long, in minutes, an authentication process will remained in the ‘awaiting` status before moving to `expired` in the case no valid matching is performed in between. It also means that the code sent for the autentication remains the same during its validity period until the autentication is successful. In other words, if another authentication request is asked within that period, the same code will be sent. If not specified, the default value is 15 minutes. It must be any value between 1 and 1440 which represents 24 hours.

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

    It represents the maximum number of trials per authentication. The default value is 5.

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

    It represents the maximum number of code controls per authentication. It must be between 1 and 6 inclusive. The default value is 3.

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

    This is the ID of the SMTP settings used by this configuration. It is mandatory to provide this parameter in order to send the authentication code via email. An SMTPSetting can be created via the web application in an easy way.

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

    This is the ID of the default email template to use for sending authenetication codes via email. If not provided, the message used will be: “‘ $SERVICE_NAME: your authentication code is $CODE. “`

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

    This is the ID of the default sms template to use for sending authenetication codes via sms. If not provided, the message used will be: “‘ $SERVICE_NAME: your authentication code is $CODE. “`

Returns:



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
76
77
78
79
80
81
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 46

def create(
    service_name: nil, 
    code_length: :unset, 
    allow_custom_code: :unset, 
    used_for_digital_payment: :unset, 
    default_expiry_time: :unset, 
    default_max_trials: :unset, 
    default_max_controls: :unset, 
    smtp_setting_id: :unset, 
    email_template_id: :unset, 
    sms_template_id: :unset
)

    baseParams = {
    }
    data = Reach::Values.of(baseParams.merge({                        
        'serviceName' => service_name,
        'codeLength' => code_length,
        'allowCustomCode' => allow_custom_code,
        'usedForDigitalPayment' => used_for_digital_payment,
        'defaultExpiryTime' => default_expiry_time,
        'defaultMaxTrials' => default_max_trials,
        'defaultMaxControls' => default_max_controls,
        'smtpSettingId' => smtp_setting_id,
        'emailTemplateId' => email_template_id,
        'smsTemplateId' => sms_template_id,
    }))

    
    
    payload = @version.create('POST', @uri, data: data)
    ConfigurationItemInstance.new(
        @version,
        payload,
    )
end

#eachObject

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



126
127
128
129
130
131
132
133
134
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 126

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 ConfigurationItemInstance records from the API. Request is executed immediately.

Parameters:

  • target_url (String)

    API-generated URL for the requested results page

Returns:

  • (Page)

    Page of ConfigurationItemInstance



160
161
162
163
164
165
166
167
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 160

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

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

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



95
96
97
98
99
100
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 95

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 ConfigurationItemInstance 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 ConfigurationItemInstance



142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 142

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)

    ConfigurationItemPage.new(baseUrl, @version, response, @solution)
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



113
114
115
116
117
118
119
120
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 113

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



172
173
174
# File 'lib/reach-ruby/rest/api/authentix/configuration_item.rb', line 172

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