lib/mailup/console/list.rb in mailup-1.1.0 vs lib/mailup/console/list.rb in mailup-1.2.0

- old
+ new

@@ -2,12 +2,12 @@ module Console class List attr_accessor :api def initialize(id, api) - @api = api - @id = id + @api = api + @id = id end # Retrieve groups for the specified list # # @param [Hash] params Optional params or filters: @@ -23,11 +23,11 @@ # * PageSize [Integer] # * Skipped [Integer] # * TotalElementsCount [Integer] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetConsoleGroupsByList - # + # # @example # # list = mailup.console.list(2) # groups = list.groups # groups['TotalElementsCount'] @@ -36,11 +36,11 @@ # groups = mailup.console.list(2).groups(pageNumber: 0, pageSize: 1) # def groups(params = {}) @api.get("#{@api.path}/List/#{@id}/Groups", params: params) end - + # Create a new group for the specified list. # # @param [Hash] group A hash of group attributes. # @option group [String] :Name of the group (required). # @option group [String] :Notes to associate with the group (required). @@ -52,11 +52,11 @@ # * Name [String] # * Notes [String] # * Deletable [Boolean] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateGroup - # + # # @example # # group = { # Name: "New Group", # Notes: "Created with mailup-rest gem", @@ -67,11 +67,11 @@ # => 18 # def add_group(group) @api.post("#{@api.path}/List/#{@id}/Group", body: group) end - + # Update a group for the specified list. # # @param [Hash] group A hash of group attributes. # @option group [String] :Name of the group (required). # @option group [String] :Notes to associate with the group (required). @@ -83,11 +83,11 @@ # * Name [String] # * Notes [String] # * Deletable [Boolean] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateGroup - # + # # @example # # group = { # Name: "Updated Group", # Notes: "Updated with mailup-rest gem", @@ -98,11 +98,11 @@ # => "Updated Title" # def update_group(group_id, group) @api.put("#{@api.path}/List/#{@id}/Group/#{group_id}", body: group) end - + # Delete a group from the specified list. # # @param [Integer] group_id The ID of the group to delete. # # @return [Boolean] `true` if successful @@ -134,11 +134,11 @@ # * PageSize [Integer] # * Skipped [Integer] # * TotalElementsCount [Integer] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetConsoleGroupsByRecipient - # + # # @example # # groups = mailup.console.list(2).recipient_groups(5) # groups['TotalElementsCount'] # => 3 @@ -148,11 +148,11 @@ # groups = mailup.console.list(2).recipient_groups(5, pageNumber: 0, pageSize: 1) # def recipient_groups(recipient_id, params = {}) @api.get("#{@api.path}/List/#{@id}/Recipient/#{recipient_id}/Groups", params: params) end - + # Retrieve pending recipients in the specified list. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -166,11 +166,11 @@ # * PageSize [Integer] # * Skipped [Integer] # * TotalElementsCount [Integer] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetPendingRecipientsByList - # + # # @example # # pending = mailup.console.list(2).pending # pending['TotalElementsCount'] # => 3 @@ -180,11 +180,11 @@ # pending = mailup.console.list(2).pending(pageNumber: 0, pageSize: 1) # def pending(params = {}) @api.get("#{@api.path}/List/#{@id}/Recipients/Pending", params: params) end - + # Retrieve subscribed recipients in the specified list. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -198,11 +198,11 @@ # * PageSize [Integer] # * Skipped [Integer] # * TotalElementsCount [Integer] # # @see http://help.mailup.com/display/mailupapi/Admin+Console+Methods#AdminConsoleMethods-GetSubscribedRecipientsByList - # + # # @example # # subscribed = mailup.console.list(2).subscribed # subscribed['TotalElementsCount'] # => 10 @@ -212,11 +212,11 @@ # subscribed = mailup.console.list(2).subscribed(pageNumber: 0, pageSize: 1) # def subscribed(params = {}) @api.get("#{@api.path}/List/#{@id}/Recipients/Subscribed", params: params) end - + # Retrieve unsubscribed recipients in the specified list. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -230,11 +230,11 @@ # * PageSize [Integer] # * Skipped [Integer] # * TotalElementsCount [Integer] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-GetUnsubscribedRecipientsByList - # + # # @example # # unsubscribed = mailup.console.list(2).unsusbcribed # unsubscribed['TotalElementsCount'] # => 10 @@ -244,29 +244,55 @@ # unsubscribed = mailup.console.list(2).unsusbcribed(pageNumber: 0, pageSize: 1) # def unsubscribed(params = {}) @api.get("#{@api.path}/List/#{@id}/Recipients/Unsubscribed", params: params) end - + + # Import a single recipient to a list(synchronous import). + # + # @param [Hash] recipients An array of Recipients. + # * idRecipient [Integer] (optional) + # * Name [String] + # * Email [String] + # * MobilePrefix [String] + # * MobileNumber [String] + # * Fields [Array] + # + # @param [Hash] params Optional params or filters: + # @option params [Boolean] :ConfirmEmail Confirmed opt-in option. Default false. + # @option params [String] :importType By setting as 'asOptout' allows you to "import as unsubscribed" a list of specified recipients. + # + # @return [Integer] The number of imported recipients. + # + # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AsyncImportRecipientsToList + # + def import_recipient(recipient, params = {}) + @api.post("#{@api.path}/List/#{@id}/Recipient", {params: params, body: recipient}) + end + # Import multiple recipients to a list. # # @param [Array<Hash>] recipients An array of Recipients. # * idRecipient [Integer] (optional) # * Name [String] # * Email [String] # * MobilePrefix [String] # * MobileNumber [String] # * Fields [Array] # + # @param [Hash] params Optional params or filters: + # @option params [Boolean] :ConfirmEmail Confirmed opt-in option. Default false. + # @option params [String] :importType By setting as 'asOptout' allows you to "import as unsubscribed" a list of specified recipients. + # # @return [Integer] The number of imported recipients. # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AsyncImportRecipientsToList # - def import_recipients(recipients) - @api.post("#{@api.path}/List/#{@id}/Recipients", body: recipients) + def import_recipients(recipients, params = {}) + @api.post("#{@api.path}/List/#{@id}/Recipients", {params: params, body: recipients}) end - + # Subscribe a recipient from the specified list. # # @param [Integer] recipient_id The ID of the recipient. # # @return [Boolean] `true` if successful. @@ -279,11 +305,11 @@ # => true # def subscribe(recipient_id) @api.post("#{@api.path}/List/#{@id}/Subscribe/#{recipient_id}") end - + # Unsubscribe a recipient in the specified list. # # @param [Integer] recipient_id The ID of the recipient. # # @return [Boolean] `true` if successful. @@ -296,11 +322,11 @@ # => true # def unsubscribe(recipient_id) @api.delete("#{@api.path}/List/#{@id}/Unsubscribe/#{recipient_id}") end - + # Get the enabled tag list for the specified list id. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -327,30 +353,30 @@ # def tags(params = {}) @api.get("#{@api.path}/List/#{@id}/Tags", params: params) end alias_method :enabled_tags, :tags - + # Add a new tag in the specified list. # # @param [String] name The name of the tag to create. # # @return [JSON] The created Tag with the following attributes: # * Id [Integer] # * Name [String] # * Enabled [Boolean] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateTag - # + # # @example # # new_tag = mailup.console.list(2).add_tag("My New Tag") # def add_tag(tag) @api.post("#{@api.path}/List/#{@id}/Tag", body: tag) end - + # Update a tag in the specified list. # # @param [Hash] tag A hash of tag attributes: # @option tag [String] :Name of the tag (required). # @option tag [Boolean] :Enabled true if tag is enabled. @@ -374,11 +400,11 @@ # => false # def update_tag(tag_id, tag) @api.put("#{@api.path}/List/#{@id}/Tag/#{tag_id}", body: tag) end - + # Delete a tag from the specified list. # # @param [Integer] idTag The ID of the tag to delete. # # @return [Boolean] `true` if successful. @@ -391,11 +417,11 @@ # => true # def delete_tag(tag_id) @api.delete("#{@api.path}/List/#{@id}/Tag/#{tag_id}") end - + # Get the attachment list for the specific message. # # @param [Integer] message_id The ID of the message. # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. @@ -417,11 +443,11 @@ # => 3 # def attachments(message_id, params = {}) @api.get("#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment", params: params) end - + # Add an attachment to the specified message. # # @param [Integer] message_id The ID of the message. # @param [Integer] slot The slot for the attachment. # @param [Hash] attachment A hash of recipient attributes: @@ -432,11 +458,11 @@ # * Slot [Integer] # * Name [String] # * Path [String] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AddMessageAttachments - # + # # @example # # attachment = { # Name: "PDF Attachment", # Path: "https://abc123.mailup.com/attachments/..." @@ -446,11 +472,11 @@ # => "PDF Attachment" # def add_attachment(message_id, slot, attachment) @api.post("#{@api.path}/List/#{@id}/Email/#{message_id}/Attachment/#{slot}", body: attachment) end - + # Delete an attachment from the specified message. # # @param [Integer] message_id The ID of the message. # @param [Integer] slot The slot of the attachment. # @@ -464,11 +490,11 @@ # => true # def delete_attachment(message_id, slot) @api.delete("#{@api.path}/List/#{@id}/Email/#{message_id}/#{slot}") end - + # Get all the images for the specified list. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -486,21 +512,21 @@ # => 3 # def images(params = {}) @api.get("#{@api.path}/List/#{@id}/Images", params: params) end - + # Add a new image to the specified mailing list. # # @param [Hash] image A hash of Image attributes. # @option image [String] Name of the image (required). # @option image [String] Data Base64 data for the image (required). # # @return [String] the created Image URL. # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-AddListImage - # + # # @example # # image = { # Name: "New Image", # Data: "..." @@ -509,32 +535,32 @@ # => "https://mailup.com/images/..." # def add_image(image) @api.post("#{@api.path}/List/#{@id}/Images", body: image) end - + # Create an email message in the specified list id from template. # # @param [Integer] template_id The ID of the template. # # @return [JSON] The created Message with the following attributes: # * idList [Integer] # * idMessage [Integer] # * Subject [String] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateEmailMessageFromTemplate - # + # # @example # # new_message = mailup.console.list(2).add_message_from_template(5) # new_message['Subject'] # => "Subject From Template" # def add_message_from_template(template_id) @api.post("#{@api.path}/List/#{@id}/Email/Template/#{template_id}") end - + # Create an email message in the specified list id. # # @param [Hash] message A hash of Message attributes: # @option message [String] :Subject of the message (required). # @option message [String] :Content of the message (required). @@ -548,21 +574,21 @@ # * idList [Integer] # * idMessage [Integer] # * Subject [String] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-CreateEmailMessage - # + # # @example # # new_message = mailup.console.list(2).add_message(message) # new_message['Subject'] # => "Message Subject" # def add_message(message) @api.post("#{@api.path}/List/#{@id}/Email", body: message) end - + # Modify an email message in the specified list id. # # @param [Integer] message_id The ID of the message. # @param [Hash] message A hash of message attributes: # @option message [String] :Subject of the message (required). @@ -577,39 +603,39 @@ # * idList [Integer] # * idMessage [Integer] # * Subject [String] # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateEmailMessage - # + # # @example # # update = mailup.console.list(2).update_message(5, message) # update['Subject'] # => "Updated Subject" # def update_message(message_id, message) @api.put("#{@api.path}/List/#{@id}/Email/#{message_id}", body: message) end - + # Modify the email message online visibility. # # @param [Integer] message_id The ID of the message. # @param [Boolean] visibility The visibility of the message. # # @return [Boolean] `true` if successful. # # @see http://help.mailup.com/display/mailupapi/Console+methods+v1.1#Consolemethodsv1.1-UpdateOnlineEmailMessageVisibility - # + # # @example # # update = mailup.console.list(2).update_message_visibility(5, true) # => true # def update_message_visibility(message_id, visibility) @api.put("#{@api.path}/List/#{@id}/Email/#{message_id}/Online/Visibility", body: visibility) end - + # Delete an email message from the specified list id. # # @param [Integer] message_id The ID of the message. # # @return [Boolean] `true` if successful. @@ -622,11 +648,11 @@ # => true # def delete_message(message_id) @api.delete("#{@api.path}/List/#{@id}/Email/#{message_id}") end - + # Retrieve the email message details by specified id. # # @param [Integer] message_id The ID of the message. # # @return [JSON] The Message with the following attributes: @@ -649,11 +675,11 @@ # => "Message Subject" # def message_details(message_id) @api.get("#{@api.path}/List/#{@id}/Email/#{message_id}") end - + # Retrieve email messages (cloned and uncloned) for this list. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -681,11 +707,11 @@ # => 2 # def emails(params = {}) @api.get("#{@api.path}/List/#{@id}/Emails", params: params) end - + # Retrieve the email messages visible online through the website by the specified list id. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -746,11 +772,11 @@ # => 1 # def archived_emails(params = {}) @api.get("#{@api.path}/List/#{@id}/Archived/Emails", params: params) end - + # Get email message send history. # # @param [Integer] message_id The ID of the message. # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. @@ -775,14 +801,16 @@ # => 10 # def send_history(message_id, params = {}) @api.get("#{@api.path}/List/#{@id}/Email/#{message_id}/SendHistory", params: params) end - + # Send an email message to the recipients in the specified list. # # @param [Integer] message_id The ID of the list. + # @param [Hash] params Optional params or filters: + # @option params [String] :datetime date/time for a deferred sending(should be UTC). # # @return [JSON] A Send object with the following attributes: # * idMessage [Integer] # * Sent [Integer] # * UnprocessedRecipients [Array] @@ -794,14 +822,14 @@ # # send = mailup.console.list(2).send_message(5) # send['Sent'] # => 1794 # - def send_message(message_id) - @api.post("#{@api.path}/List/#{@id}/Email/#{message_id}/Send") + def send_message(message_id, params = {}) + @api.post("#{@api.path}/List/#{@id}/Email/#{message_id}/Send", params: params) end - + # Retrieve the list of the current defined message templates in the specified list. # # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. # @option params [Integer] :pageSize The number of results to per page. @@ -827,11 +855,11 @@ # => 278 # def templates(params = {}) @api.get("#{@api.path}/List/#{@id}/Templates", params: params) end - + # Retrieve the details for the specified message template in the specified list. # # @param [Integer] template_id The ID of the template. # @param [Hash] params Optional params or filters: # @option params [Integer] :pageNumber The page number to return. @@ -855,9 +883,9 @@ # => 15 # def template_details(template_id) @api.get("#{@api.path}/List/#{@id}/Templates/#{template_id}") end - + end end end \ No newline at end of file