Class: StarkInfra::IndividualIdentity

Inherits:
StarkCore::Utils::Resource
  • Object
show all
Defined in:
lib/individualidentity/individualidentity.rb,
lib/individualidentity/log.rb

Overview

# IndividualIdentity object

An IndividualDocument represents an individual to be validated. It can have several individual documents attached to it, which are used to validate the identity of the individual. Once an individual identity is created, individual documents must be attached to it using the created method of the individual document resource. When all the required individual documents are attached to an individual identity it can be sent to validation by patching its status to processing.

When you initialize a IndividualIdentity, the entity will not be automatically created in the Stark Infra API. The ‘create’ function sends the objects to the Stark Infra API and returns the list of created objects.

## Parameters (required):

  • name [string]: individual’s full name. ex: “Edward Stark”.

  • tax_id [string]: individual’s tax ID (CPF). ex: “594.739.480-42”

## Parameters (optional):

  • tags [list of strings, default nil]: list of strings for reference when searching for IndividualIdentities. ex: [“employees”, “monthly”]

## Attributes (return-only):

  • id [string]: unique id returned when the IndividualIdentity is created. ex: “5656565656565656”

  • status [string]: current status of the IndividualIdentity. Options: “created”, “canceled”, “processing”, “failed”, “success”

  • created [DateTime]: creation datetime for the IndividualIdentity. ex: DateTime.new(2020, 3, 10, 10, 30, 0, 0)

Defined Under Namespace

Classes: Log

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, tax_id:, tags: nil, id: nil, status: nil, created: nil) ⇒ IndividualIdentity

Returns a new instance of IndividualIdentity.



33
34
35
36
37
38
39
40
# File 'lib/individualidentity/individualidentity.rb', line 33

def initialize(name:, tax_id:, tags: nil, id: nil, status: nil, created: nil)
  super(id)
  @name = name
  @tax_id = tax_id
  @tags = tags
  @status = status
  @created = StarkCore::Utils::Checks.check_datetime(created)
end

Instance Attribute Details

#createdObject (readonly)

Returns the value of attribute created.



32
33
34
# File 'lib/individualidentity/individualidentity.rb', line 32

def created
  @created
end

#idObject (readonly)

Returns the value of attribute id.



32
33
34
# File 'lib/individualidentity/individualidentity.rb', line 32

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



32
33
34
# File 'lib/individualidentity/individualidentity.rb', line 32

def name
  @name
end

#statusObject (readonly)

Returns the value of attribute status.



32
33
34
# File 'lib/individualidentity/individualidentity.rb', line 32

def status
  @status
end

#tagsObject (readonly)

Returns the value of attribute tags.



32
33
34
# File 'lib/individualidentity/individualidentity.rb', line 32

def tags
  @tags
end

#tax_idObject (readonly)

Returns the value of attribute tax_id.



32
33
34
# File 'lib/individualidentity/individualidentity.rb', line 32

def tax_id
  @tax_id
end

Class Method Details

.cancel(id, user: nil) ⇒ Object

# Cancel an IndividualIdentity entity

Cancel an IndividualIdentity entity previously created in the Stark Infra API

## Parameters (required):

  • id [string]: IndividualIdentity unique id. ex: ‘5656565656565656’

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call

## Return:

  • canceled IndividualIdentity object



172
173
174
# File 'lib/individualidentity/individualidentity.rb', line 172

def self.cancel(id, user: nil)
  StarkInfra::Utils::Rest.delete_id(id: id, user: user, **resource)
end

.create(identities, user: nil) ⇒ Object

# Create IndividualIdentities

Send a list of IndividualIdentity objects for creation at the Stark Infra API

## Parameters (required):

  • identities [list of IndividualIdentity objects]: list of IndividualIdentity objects to be created in the API.

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call

## Return:

  • list of IndividualIdentity objects with updated attributes



54
55
56
# File 'lib/individualidentity/individualidentity.rb', line 54

def self.create(identities, user: nil)
  StarkInfra::Utils::Rest.post(entities: identities, user: user, **resource)
end

.get(uuid, user: nil) ⇒ Object

# Retrieve a specific IndividualIdentity

Receive a single IndividualIdentity object previously created in the Stark Infra API by its id

## Parameters (required):

  • id [string]: object unique id. ex: “5656565656565656”

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call

## Return:

  • IndividualIdentity object with updated attributes



70
71
72
# File 'lib/individualidentity/individualidentity.rb', line 70

def self.get(uuid, user: nil)
  StarkInfra::Utils::Rest.get_id(id: uuid, user: user, **resource)
end

.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) ⇒ Object

# Retrieve paged IndividualIdentities

Receive a list of up to 100 IndividualIdentity objects previously created in the Stark Infra API and the cursor to the next page. Use this function instead of query if you want to manually page your requests.

## Parameters (optional):

  • cursor [string, default nil]: cursor returned on the previous page function call

  • limit [integer, default 100]: maximum number of objects to be retrieved. Max = 100. ex 35

  • after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)

  • before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)

  • status [list of strings, default nil]: filter for status of retrieved objects. ex: [“created”, “canceled”, “processing”, “failed”, “success”]

  • tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]

  • ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [“5656565656565656”, “4545454545454545”]

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call

## Return:

  • list of IndividualIdentity objects with updated attributes

  • cursor to retrieve the next page of IndividualIdentity objects



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/individualidentity/individualidentity.rb', line 122

def self.page(cursor: nil, limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
  after = StarkCore::Utils::Checks.check_date(after)
  before = StarkCore::Utils::Checks.check_date(before)
  StarkInfra::Utils::Rest.get_page(
    cursor: cursor,
    limit: limit,
    after: after,
    before: before,
    status: status,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end

.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil) ⇒ Object

# Retrieve IndividualIdentities

Receive a generator of IndividualIdentity objects previously created in the Stark Infra API

## Parameters (optional):

  • limit [integer, default nil]: maximum number of objects to be retrieved. Unlimited if nil. ex: 35

  • after [Date or string, default nil]: date filter for objects created only after specified date. ex: Date.new(2020, 3, 10)

  • before [Date or string, default nil]: date filter for objects created only before specified date. ex: Date.new(2020, 3, 10)

  • status [list of strings, default nil]: filter for status of retrieved objects. ex: [“created”, “canceled”, “processing”, “failed”, “success”]

  • tags [list of strings, default nil]: tags to filter retrieved objects. ex: [‘tony’, ‘stark’]

  • ids [list of strings, default nil]: list of ids to filter retrieved objects. ex: [“5656565656565656”, “4545454545454545”]

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if StarkInfra.user was set before function call

## Return:

  • generator of IndividualIdentity objects with updated attributes



89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/individualidentity/individualidentity.rb', line 89

def self.query(limit: nil, after: nil, before: nil, status: nil, tags: nil, ids: nil, user: nil)
  after = StarkCore::Utils::Checks.check_date(after)
  before = StarkCore::Utils::Checks.check_date(before)
  StarkInfra::Utils::Rest.get_stream(
    limit: limit,
    after: after,
    before: before,
    status: status,
    tags: tags,
    ids: ids,
    user: user,
    **resource
  )
end

.resourceObject



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
# File 'lib/individualidentity/individualidentity.rb', line 176

def self.resource
  {
    resource_name: 'IndividualIdentity',
    resource_maker: proc { |json|
      IndividualIdentity.new(
        name: json['name'],
        tax_id: json['tax_id'],
        tags: json['tags'],
        id: json['id'],
        status: json['status'],
        created: json['created']
      )
    }
  }
end

.update(id, status:, user: nil) ⇒ Object

# Update IndividualIdentity entity

Update an IndividualIdentity by passing id.

## Parameters (required):

  • id [string]: IndividualIdentity unique id. ex: ‘5656565656565656’

  • status [string]: You may send IndividualDocuments to validation by passing ‘processing’ in the status

## Parameters (optional):

  • user [Organization/Project object, default nil]: Organization or Project object. Not necessary if starkinfra.user was set before function call

## Return:

  • target IndividualIdentity with updated attributes



151
152
153
154
155
156
157
158
# File 'lib/individualidentity/individualidentity.rb', line 151

def self.update(id, status:, user: nil)
  StarkInfra::Utils::Rest.patch_id(
    id: id,
    status: status,
    user: user,
    **resource
  )
end