Class: MailUp::Console::Group

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, api) ⇒ Group

Returns a new instance of Group.



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

def initialize(id, api)
  @api = api
  @id = id
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



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

def api
  @api
end

Instance Method Details

#add_recipient(recipient, params = {}) ⇒ Object

Import a recipient to the specified group(synchronous import).

Parameters:

Options Hash (params):

  • :ConfirmEmail (Boolean)

    Confirmed opt-in option. Default false.

See Also:



19
20
21
# File 'lib/mailup/console/group.rb', line 19

def add_recipient(recipient, params = {})
  @api.post("#{@api.path}/Group/#{@id}/Recipient", body: recipient, params: params)
end

#add_recipients(recipients, params = {}) ⇒ Object

Async Import recipients to the specified group.

Parameters:

Options Hash (params):

  • :ConfirmEmail (Boolean)

    Confirmed opt-in option. Default false.

See Also:



31
32
33
# File 'lib/mailup/console/group.rb', line 31

def add_recipients(recipients, params = {})
  @api.post("#{@api.path}/Group/#{@id}/Recipients", body: recipients, params: params)
end

#recipients(params = {}) ⇒ JSON

Retrieve the recipients in the specified group.

Examples:


recipients = mailup.console.group(5).recipients
recipients['TotalElementsCount']
=> 125
recipients['Items'].first['Name']
=> "Joe Public"

Parameters:

  • params (Hash) (defaults to: {})

    Optional params or filters:

Options Hash (params):

  • :pageNumber (Integer)

    The page number to return.

  • :pageSize (Integer)

    The number of results to per page.

  • :filterby (String)

    A filtering expression.

  • :orderby (String)

    The sorting condition for the results.

Returns:

  • (JSON)

    Results and data including:

    • IsPaginated [Boolean]

    • Items [Array<Hash>]

    • PageNumber [Integer]

    • PageSize [Integer]

    • Skipped [Integer]

    • TotalElementsCount [Integer]

See Also:



61
62
63
# File 'lib/mailup/console/group.rb', line 61

def recipients(params = {})
  @api.get("#{@api.path}/Group/#{@id}/Recipients", params: params)
end

#send_message(message_id) ⇒ JSON

Send email message to all recipient in group.

Examples:


send = mailup.console.group(5).send_message(1340)
send['Sent']
=> 1794

Parameters:

  • message_id (Integer)

    of the message.

Returns:

  • (JSON)

    A Send object with the following attributes:

    • idMessage [Integer]

    • Sent [Integer]

    • UnprocessedRecipients [Array]

    • InvalidRecipients [Array]

See Also:



117
118
119
# File 'lib/mailup/console/group.rb', line 117

def send_message(message_id)
  @api.post("#{@api.path}/Group/#{@id}/Email/#{message_id}/Send")
end

#subscribe(recipient_id) ⇒ Boolean

Subscribe the recipient with the related id to the specified group.

Examples:


susbcribe = mailup.console.group(5).subscribe(126)
=> true

Parameters:

  • recipient_id (Integer)

    The ID of the recipient.

Returns:

  • (Boolean)

    ‘true` if successful.

See Also:



78
79
80
# File 'lib/mailup/console/group.rb', line 78

def subscribe(recipient_id)
  @api.post("#{@api.path}/Group/#{@id}/Subscribe/#{recipient_id}")
end

#unsubscribe(recipient_id) ⇒ Boolean

Unsubscribe the recipient with the related id from the specified group.

Examples:


unsusbcribe = mailup.console.group(5).unsubscribe(126)
=> true

Parameters:

  • recipient_id (Integer)

    The ID of the recipient.

Returns:

  • (Boolean)

    ‘true` if successful.

See Also:



95
96
97
# File 'lib/mailup/console/group.rb', line 95

def unsubscribe(recipient_id)
  @api.delete("#{@api.path}/Group/#{@id}/Unsubscribe/#{recipient_id}")
end