Class: IubendaApi::ConsentSolution::Clients::Subject

Inherits:
ApiStruct::Client
  • Object
show all
Defined in:
lib/iubenda_api/consent_solution/clients/subject.rb

Overview

Endpoint wrapper class for Iubenda Subjects HTTP APIs

Instance Method Summary collapse

Instance Method Details

#createDry::Monads::Result::Success, Dry::Monads::Result::Failure #create(options) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

Calls POST /subjects

Examples:

IubendaApi::ConsentSolution::Clients::Subject.new.create(id: 'testsubject', email: '[email protected]', first_name: "John", last_name: "Doe", verified: false) # -> Dry::Monads::Result::Success({:id=>"testsubject", :timestamp=>"2019-11-05T11:33:20.039Z"})
IubendaApi::ConsentSolution::Clients::Subject.new.create(id: 'testsubject', email: '[email protected]', first_name: "John", last_name: "Doe", verified: false) # -> Dry::Monads::Result::Failure(#<ApiStruct::Errors::Client:0x007f7f699fc3c0 @status=#<HTTP::Response::Status 403 Forbidden>, @body={:message=>"Invalid authentication credentials"}>)

Overloads:

  • #create(options) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

    Parameters:

    • options (Hash)

      options to send as subject attributes.

    Options Hash (options):

    • :id (String)

      auto-filled if not provided

    • :email (String)

      Optional

    • :first_name (String)

      Optional

    • :last_name (String)

      Optional

    • :full_name (String)

      Optional

    • :verified (Boolean)

      Optional, Reserved field used to signal whether a subject is verified, for instance via the double opt-in method

Returns:

  • (Dry::Monads::Result::Success)

    if success

  • (Dry::Monads::Result::Failure)

    if failed

See Also:



67
68
69
# File 'lib/iubenda_api/consent_solution/clients/subject.rb', line 67

def create(options = {})
  post(json: options)
end

#listDry::Monads::Result::Success, Dry::Monads::Result::Failure #list(options) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

Calls GET /subjects

Examples:

IubendaApi::ConsentSolution::Clients::Subject.new.list(limit: 1) # -> Dry::Monads::Result::Success([{:id=>"testsubject", :email=>"[email protected]", :first_name=>"John", :last_name=>"Doe", :verified=>false, :owner_id=>"1", :preferences=> {}, :timestamp=>"2019-11-04T17:30:58+00:00"}])
IubendaApi::ConsentSolution::Clients::Subject.new.list(limit: 1) # -> Dry::Monads::Result::Failure(#<ApiStruct::Errors::Client:0x007f7f699fc3c0 @status=#<HTTP::Response::Status 403 Forbidden>, @body={:message=>"Invalid authentication credentials"}>)

Overloads:

  • #list(options) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

    Parameters:

    • options (Hash)

      options to send as query parameters.

    Options Hash (options):

    • :id (String)

      Filter by id. It must exactly match. Default null

    • :email_exact (String)

      Filter by email. It must exactly match. (Case sensitive)

    • :email (String)

      Filter by email. It tries to match parts of the provided email split by dots and spaces. Ex. providing “@test.com” will match all the subjects with an email containing “@test” or containing “com” (case insensitive).

    • :first_name (String)

      Filter by first name. It must exactly match (case sensitive).

    • :last_name (String)

      Filter by last name. It must exactly match (case sensitive).

    • :full_name (String)

      Filter by full name. It tries to match parts of the provided full name split by dots and spaces. Ex. “test hello” will match all the subjects with a full name containing “test” or containing “hello” (case insensitive).

    • :from_time (String)

      Filter by subjects timestamp. Returns all subjects from that time onward (inclusive). Valid formats: 2018-02-22 00:40:00 UTC, 2018-02-22T00:40:00Z (ISO 8601), 1519260000 (unix timestamp in seconds).

    • :to_time (String)

      Filter by subjects timestamp. Returns all subjects from that time backward (inclusive). Valid formats: 2018-02-22 00:40:00 UTC, 2018-02-22T00:40:00Z (ISO 8601), 1519260000 (unix timestamp in seconds).

    • :verified (Boolean)

      Filter by verified status. Possible values: true, false.

    • :fulltext (String)

      Filters for results with the value provided being contained in either id, first_name, last_name, full_name, email.

    • :starting_after (String)

      Cursor which indicates after which Subject the results should be returned (cursor excluded).

    • :limit (Numeric)

      Number indicating the number of results returned. Min: 1, Max: 100.

Returns:

  • (Dry::Monads::Result::Success)

    if success

  • (Dry::Monads::Result::Failure)

    if failed

See Also:



46
47
48
# File 'lib/iubenda_api/consent_solution/clients/subject.rb', line 46

def list(options = {})
  get(params: options)
end

#show(id) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

Calls GET /subjects/:id

Examples:

IubendaApi::ConsentSolution::Clients::Subject.new.get('testsubject') # -> Dry::Monads::Result::Success({:id=>"testsubject", :email=>"[email protected]", :first_name=>"John", :last_name=>"Doe", :verified=>false, :owner_id=>"1", :preferences=> {}, :timestamp=>"2019-11-04T17:30:58+00:00"})
IubendaApi::ConsentSolution::Clients::Subject.new.get('notfound') # -> Dry::Monads::Result::Failure(#<ApiStruct::Errors::Client:0x007ff1544606c0 @status=#<HTTP::Response::Status 404 Not Found>, @body={:status=>"not_found"}>)

Parameters:

  • id (String)

    the id of the subject

Returns:

  • (Dry::Monads::Result::Success)

    if success

  • (Dry::Monads::Result::Failure)

    if failed

See Also:



19
20
21
# File 'lib/iubenda_api/consent_solution/clients/subject.rb', line 19

def show(id)
  get(id)
end

#update(id) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure #update(id, options) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

Calls PUT /subjects/:id

Examples:

IubendaApi::ConsentSolution::Clients::Subject.new.update('testsubject', email: '[email protected]') # -> Dry::Monads::Result::Success({:id=>"testsubject", :timestamp=>"2019-11-05T11:33:20.000+00:00"})
IubendaApi::ConsentSolution::Clients::Subject.new.update('testsubject', email: '[email protected]') # -> Dry::Monads::Result::Failure(#<ApiStruct::Errors::Client:0x007f7f699fc3c0 @status=#<HTTP::Response::Status 403 Forbidden>, @body={:message=>"Invalid authentication credentials"}>)

Overloads:

  • #update(id, options) ⇒ Dry::Monads::Result::Success, Dry::Monads::Result::Failure

    Parameters:

    • options (Hash)

      options to send as subject attributes.

    Options Hash (options):

    • :email (String)

      Optional

    • :first_name (String)

      Optional

    • :last_name (String)

      Optional

    • :full_name (String)

      Optional

    • :verified (Boolean)

      Optional, Reserved field used to signal whether a subject is verified, for instance via the double opt-in method

Returns:

  • (Dry::Monads::Result::Success)

    if success

  • (Dry::Monads::Result::Failure)

    if failed

See Also:



87
88
89
# File 'lib/iubenda_api/consent_solution/clients/subject.rb', line 87

def update(id, options = {})
  put(id, json: options)
end