class MailUp::Console::Recipient

Attributes

api[RW]

Public Class Methods

new(api) click to toggle source
# File lib/mailup/console/recipient.rb, line 6
def initialize(api)
    @api = api
end

Public Instance Methods

fields(params = {}) click to toggle source

Retrieve recipient dynamic field definitions.

@return [JSON] Results and data including:

* IsPaginated [Boolean]
* Items [Array<Hash>]
* PageNumber [Integer]
* PageSize [Integer]
* Skipped [Integer]
* TotalElementsCount [Integer]

@see help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetDynamicFields

@example

fields = mailup.console.recipient.fields
fields.size
=> 10
fields['Items'].first['Description']
=> "Field description..."
# File lib/mailup/console/recipient.rb, line 64
def fields(params = {})
  @api.get("#{@api.path}/Recipient/DynamicFields", params: params)
end
update(recipient) click to toggle source

Update a recipient with the specified details into address book.

@param [Hash] recipient A hash of recipient attributes: @option recipient [String] :Name of the recipient (required). @option recipient [String] :Email of the recipient (required). @option recipient [String] :MobilePrefix of the recipient. @option recipient [String] :MobileNumber of the recipient. @option recipient [Array] :Fields to include.

@return [JSON] The updated Recipient object with the following attributes:

* idRecipient [Integer]
* Name [String]
* Email [String]
* MobilePrefix [String]
* MobileNumber [String]
* Fields [Array]

@see help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateRecipientDetail

@example

recipient = {
  idRecipient: "1234"
  Name: "Joe Public",
  Email: "joe@public.com"
}
updated_recipient = mailup.console.recipient.update(recipient)
updated_recipient['Name']
=> "Joe Public"
# File lib/mailup/console/recipient.rb, line 40
def update(recipient)
  @api.put("#{@api.path}/Recipient/Detail", body: recipient)
end