class Urbanairship::Automations::Automation

Attributes

enabled[RW]
limit[RW]
offset[RW]
pipeline_id[RW]
pipeline_object[RW]
start[RW]

Public Class Methods

new(client: required('client')) click to toggle source
# File lib/urbanairship/automations/automation.rb, line 17
def initialize(client: required('client'))
     @client = client
end

Public Instance Methods

create_automation() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 21
def create_automation
    response = @client.send_request(
        method: 'POST',
        body: JSON.dump(pipeline_object),
        path: pipelines_path,
        content_type: 'application/json'
    )
    logger.info("Created Automation")
    response
end
delete_automation() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 84
def delete_automation
    fail ArgumentError, 'pipeline_id must be set to delete individual automation' if @pipeline_id.nil?
    response = @client.send_request(
        method: 'DELETE',
        path: pipelines_path(pipeline_id)
    )
    logger.info("Deleting automation with id #{pipeline_id}")
    response
end
format_url_with_params() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 94
def format_url_with_params
    params = []
    params << ['limit', limit] if limit
    params << ['enabled', enabled] if enabled
    params << ['offset', offset] if offset
    params << ['start', start] if start
    query = URI.encode_www_form(params)
    '?' + query
end
list_automations() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 32
def list_automations
    response = @client.send_request(
        method: 'GET',
        path: pipelines_path(format_url_with_params)
    )
    logger.info("Looking up automations for project")
    response
end
list_deleted_automations() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 41
def list_deleted_automations
    response = @client.send_request(
        method: 'GET',
        path: pipelines_path('deleted' + format_url_with_params)
    )
    logger.info("Looking up deleted automations for project")
    response
end
lookup_automation() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 61
def lookup_automation
    fail ArgumentError, 'pipeline_id must be set to lookup individual automation' if @pipeline_id.nil?
    response = @client.send_request(
        method: 'GET',
        path: pipelines_path(pipeline_id)
    )
    logger.info("Looking up automation with id #{pipeline_id}")
    response
end
update_automation() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 71
def update_automation
    fail ArgumentError, 'pipeline_id must be set to update individual automation' if @pipeline_id.nil?

    response = @client.send_request(
        method: 'PUT',
        body: JSON.dump(pipeline_object),
        path: pipelines_path(pipeline_id),
        content_type: 'application/json'
    )
    logger.info("Validating Automation")
    response
end
validate_automation() click to toggle source
# File lib/urbanairship/automations/automation.rb, line 50
def validate_automation
    response = @client.send_request(
        method: 'POST',
        body: JSON.dump(pipeline_object),
        path: pipelines_path('validate'),
        content_type: 'application/json'
    )
    logger.info("Validating Automation")
    response
end