Class: MailUp::Console::Recipient

Inherits:
Object
  • Object
show all
Defined in:
lib/mailup/console/recipient.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api) ⇒ Recipient

Returns a new instance of Recipient.



6
7
8
# File 'lib/mailup/console/recipient.rb', line 6

def initialize(api)
    @api = api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



4
5
6
# File 'lib/mailup/console/recipient.rb', line 4

def api
  @api
end

Instance Method Details

#fields(params = {}) ⇒ JSON

Retrieve recipient dynamic field definitions.

Examples:


fields = mailup.console.recipient.fields
fields.size
=> 10
fields['Items'].first['Description']
=> "Field description..."

Returns:

  • (JSON)

    Results and data including:

    • IsPaginated [Boolean]

    • Items [Array<Hash>]

    • PageNumber [Integer]

    • PageSize [Integer]

    • Skipped [Integer]

    • TotalElementsCount [Integer]

See Also:



64
65
66
# File 'lib/mailup/console/recipient.rb', line 64

def fields(params = {})
  @api.get("#{@api.path}/Recipient/DynamicFields", params: params)
end

#update(recipient) ⇒ JSON

Update a recipient with the specified details into address book.

Examples:


recipient = {
  idRecipient: "1234"
  Name: "Joe Public",
  Email: "[email protected]"
}
updated_recipient = mailup.console.recipient.update(recipient)
updated_recipient['Name']
=> "Joe Public"

Parameters:

  • recipient (Hash)

    A hash of recipient attributes:

Options Hash (recipient):

  • :Name (String)

    of the recipient (required).

  • :Email (String)

    of the recipient (required).

  • :MobilePrefix (String)

    of the recipient.

  • :MobileNumber (String)

    of the recipient.

  • :Fields (Array)

    to include.

Returns:

  • (JSON)

    The updated Recipient object with the following attributes:

    • idRecipient [Integer]

    • Name [String]

    • Email [String]

    • MobilePrefix [String]

    • MobileNumber [String]

    • Fields [Array]

See Also:



40
41
42
# File 'lib/mailup/console/recipient.rb', line 40

def update(recipient)
  @api.put("#{@api.path}/Recipient/Detail", body: recipient)
end