Class: Urbanairship::Automations::Automation
- Inherits:
-
Object
- Object
- Urbanairship::Automations::Automation
- Defined in:
- lib/urbanairship/automations/automation.rb
Constant Summary
Constants included from Common
Instance Attribute Summary collapse
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#offset ⇒ Object
Returns the value of attribute offset.
-
#pipeline_id ⇒ Object
Returns the value of attribute pipeline_id.
-
#pipeline_object ⇒ Object
Returns the value of attribute pipeline_object.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
- #create_automation ⇒ Object
- #delete_automation ⇒ Object
- #format_url_with_params ⇒ Object
-
#initialize(client: required('client')) ⇒ Automation
constructor
A new instance of Automation.
- #list_automations ⇒ Object
- #list_deleted_automations ⇒ Object
- #lookup_automation ⇒ Object
- #update_automation ⇒ Object
- #validate_automation ⇒ Object
Methods included from Loggable
create_logger, logger, #logger
Methods included from Common
#apid_path, #channel_path, #compact_helper, #create_and_send_path, #custom_events_path, #device_token_path, #experiments_path, #lists_path, #named_users_path, #open_channel_path, #pipelines_path, #push_path, #reports_path, #required, #schedules_path, #segments_path, #tag_lists_path, #try_helper
Constructor Details
#initialize(client: required('client')) ⇒ Automation
Returns a new instance of Automation.
17 18 19 |
# File 'lib/urbanairship/automations/automation.rb', line 17 def initialize(client: required('client')) @client = client end |
Instance Attribute Details
#enabled ⇒ Object
Returns the value of attribute enabled.
10 11 12 |
# File 'lib/urbanairship/automations/automation.rb', line 10 def enabled @enabled end |
#limit ⇒ Object
Returns the value of attribute limit.
10 11 12 |
# File 'lib/urbanairship/automations/automation.rb', line 10 def limit @limit end |
#offset ⇒ Object
Returns the value of attribute offset.
10 11 12 |
# File 'lib/urbanairship/automations/automation.rb', line 10 def offset @offset end |
#pipeline_id ⇒ Object
Returns the value of attribute pipeline_id.
10 11 12 |
# File 'lib/urbanairship/automations/automation.rb', line 10 def pipeline_id @pipeline_id end |
#pipeline_object ⇒ Object
Returns the value of attribute pipeline_object.
10 11 12 |
# File 'lib/urbanairship/automations/automation.rb', line 10 def pipeline_object @pipeline_object end |
#start ⇒ Object
Returns the value of attribute start.
10 11 12 |
# File 'lib/urbanairship/automations/automation.rb', line 10 def start @start end |
Instance Method Details
#create_automation ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# 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 ⇒ Object
84 85 86 87 88 89 90 91 92 |
# 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 ⇒ Object
94 95 96 97 98 99 100 101 102 |
# 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 ⇒ Object
32 33 34 35 36 37 38 39 |
# 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 ⇒ Object
41 42 43 44 45 46 47 48 |
# 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 ⇒ Object
61 62 63 64 65 66 67 68 69 |
# 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 ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 |
# 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 ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# 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 |