urbanairship 6.0.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +5 -0
- data/README.rst +91 -35
- data/lib/urbanairship/ab_tests/ab_test.rb +6 -6
- data/lib/urbanairship/automations/automation.rb +7 -7
- data/lib/urbanairship/client.rb +12 -3
- data/lib/urbanairship/common.rb +79 -60
- data/lib/urbanairship/custom_events/custom_event.rb +1 -1
- data/lib/urbanairship/devices/channel_tags.rb +2 -2
- data/lib/urbanairship/devices/channel_uninstall.rb +2 -2
- data/lib/urbanairship/devices/create_and_send.rb +3 -3
- data/lib/urbanairship/devices/devicelist.rb +7 -7
- data/lib/urbanairship/devices/email.rb +5 -5
- data/lib/urbanairship/devices/named_user.rb +6 -6
- data/lib/urbanairship/devices/open_channel.rb +3 -3
- data/lib/urbanairship/devices/segment.rb +6 -8
- data/lib/urbanairship/devices/sms.rb +5 -5
- data/lib/urbanairship/devices/static_lists.rb +7 -7
- data/lib/urbanairship/push/location.rb +17 -17
- data/lib/urbanairship/push/push.rb +4 -4
- data/lib/urbanairship/reports/response_statistics.rb +42 -31
- data/lib/urbanairship/version.rb +1 -1
- metadata +2 -2
| @@ -52,7 +52,7 @@ module Urbanairship | |
| 52 52 | 
             
                    response = @client.send_request(
         | 
| 53 53 | 
             
                      method: 'POST',
         | 
| 54 54 | 
             
                      body: JSON.dump(payload),
         | 
| 55 | 
            -
                       | 
| 55 | 
            +
                      path: push_path,
         | 
| 56 56 | 
             
                      content_type: 'application/json'
         | 
| 57 57 | 
             
                    )
         | 
| 58 58 | 
             
                    pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s)
         | 
| @@ -93,7 +93,7 @@ module Urbanairship | |
| 93 93 | 
             
                    response = @client.send_request(
         | 
| 94 94 | 
             
                      method: 'POST',
         | 
| 95 95 | 
             
                      body: JSON.dump(payload),
         | 
| 96 | 
            -
                       | 
| 96 | 
            +
                      path: schedules_path,
         | 
| 97 97 | 
             
                      content_type: 'application/json'
         | 
| 98 98 | 
             
                    )
         | 
| 99 99 | 
             
                    pr = PushResponse.new(http_response_body: response['body'], http_response_code: response['code'].to_s)
         | 
| @@ -170,7 +170,7 @@ module Urbanairship | |
| 170 170 | 
             
                       'schedule_id must be a string' unless schedule_id.is_a? String
         | 
| 171 171 | 
             
                    resp = @client.send_request(
         | 
| 172 172 | 
             
                      method: 'GET',
         | 
| 173 | 
            -
                       | 
| 173 | 
            +
                      path: schedules_path(schedule_id)
         | 
| 174 174 | 
             
                    )
         | 
| 175 175 | 
             
                    logger.info("Retrieved info for schedule_id #{schedule_id}")
         | 
| 176 176 | 
             
                    resp
         | 
| @@ -181,7 +181,7 @@ module Urbanairship | |
| 181 181 | 
             
                class ScheduledPushList < Urbanairship::Common::PageIterator
         | 
| 182 182 | 
             
                  def initialize(client: required('client'))
         | 
| 183 183 | 
             
                    super(client: client)
         | 
| 184 | 
            -
                    @ | 
| 184 | 
            +
                    @next_page_path = schedules_path
         | 
| 185 185 | 
             
                    @data_attribute = 'schedules'
         | 
| 186 186 | 
             
                  end
         | 
| 187 187 | 
             
                end
         | 
| @@ -4,22 +4,33 @@ require 'time' | |
| 4 4 | 
             
            module Urbanairship
         | 
| 5 5 | 
             
              module Reports
         | 
| 6 6 | 
             
                class Helper
         | 
| 7 | 
            -
                  def  | 
| 8 | 
            -
                     | 
| 9 | 
            -
             | 
| 10 | 
            -
                    precision_array = %w(HOURLY DAILY MONTHLY)
         | 
| 11 | 
            -
                    fail ArgumentError,
         | 
| 12 | 
            -
                         "Precision must be 'HOURLY', 'DAILY', or 'MONTHLY'" unless precision_array.include?(precision)
         | 
| 7 | 
            +
                  def get_period_params(start_date, end_date, precision)
         | 
| 8 | 
            +
                    validates_parameters_presence!(start_date, end_date, precision)
         | 
| 9 | 
            +
                    validates_precision_format!(precision)
         | 
| 13 10 |  | 
| 14 11 | 
             
                    begin
         | 
| 15 | 
            -
                      start_parsed = Time.parse(start_date)
         | 
| 16 | 
            -
                      end_parsed = Time.parse(end_date)
         | 
| 12 | 
            +
                      start_parsed = Time.parse(start_date).iso8601
         | 
| 13 | 
            +
                      end_parsed = Time.parse(end_date).iso8601
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                      "?start=#{start_parsed}&end=#{end_parsed}&precision=#{precision}"
         | 
| 17 16 | 
             
                    rescue ArgumentError
         | 
| 18 | 
            -
                      fail ArgumentError,
         | 
| 19 | 
            -
                         'start_date and end_date must be valid date strings'
         | 
| 17 | 
            +
                      fail ArgumentError, 'start_date and end_date must be valid date strings'
         | 
| 20 18 | 
             
                    end
         | 
| 21 | 
            -
             | 
| 22 | 
            -
             | 
| 19 | 
            +
                  end
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  private
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  def validates_parameters_presence!(start_date, end_date, precision)
         | 
| 24 | 
            +
                    return unless [start_date, end_date, precision].any?(&:nil?)
         | 
| 25 | 
            +
             | 
| 26 | 
            +
                    fail ArgumentError, 'the parameters cannot be set to nil'
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  AUTHORIZED_PRECISIONS = %w(HOURLY DAILY MONTHLY)
         | 
| 30 | 
            +
                  def validates_precision_format!(precision)
         | 
| 31 | 
            +
                    return if AUTHORIZED_PRECISIONS.include?(precision)
         | 
| 32 | 
            +
             | 
| 33 | 
            +
                    fail ArgumentError, 'Precision must be "HOURLY", "DAILY", or "MONTHLY"'
         | 
| 23 34 | 
             
                  end
         | 
| 24 35 | 
             
                end
         | 
| 25 36 |  | 
| @@ -35,8 +46,8 @@ module Urbanairship | |
| 35 46 | 
             
                    fail ArgumentError,
         | 
| 36 47 | 
             
                       'push_id cannot be nil' if push_id.nil?
         | 
| 37 48 |  | 
| 38 | 
            -
                     | 
| 39 | 
            -
                    response = @client.send_request(method: 'GET',  | 
| 49 | 
            +
                    path = reports_path('responses/' + push_id)
         | 
| 50 | 
            +
                    response = @client.send_request(method: 'GET', path: path)
         | 
| 40 51 | 
             
                    logger.info("Retrieved info on push_id: #{push_id}")
         | 
| 41 52 | 
             
                    response
         | 
| 42 53 | 
             
                  end
         | 
| @@ -60,10 +71,10 @@ module Urbanairship | |
| 60 71 | 
             
                      fail ArgumentError,
         | 
| 61 72 | 
             
                           'start_date and end_date must be valid date strings'
         | 
| 62 73 | 
             
                    end
         | 
| 63 | 
            -
                     | 
| 64 | 
            -
                     | 
| 65 | 
            -
                     | 
| 66 | 
            -
                    @ | 
| 74 | 
            +
                    path = reports_path('responses/list?start=' + start_parsed.iso8601 + '&end=' + end_parsed.iso8601)
         | 
| 75 | 
            +
                    path += '&limit' + limit.to_s unless limit.nil?
         | 
| 76 | 
            +
                    path += '&push_id_start&' + push_id_start unless push_id_start.nil?
         | 
| 77 | 
            +
                    @next_page_path = path
         | 
| 67 78 | 
             
                    @data_attribute = 'pushes'
         | 
| 68 79 | 
             
                  end
         | 
| 69 80 | 
             
                end
         | 
| @@ -87,7 +98,7 @@ module Urbanairship | |
| 87 98 | 
             
                    end
         | 
| 88 99 | 
             
                    response = @client.send_request(
         | 
| 89 100 | 
             
                      method: 'GET',
         | 
| 90 | 
            -
                       | 
| 101 | 
            +
                      path: reports_path('devices/?date=' + date_parsed.iso8601)
         | 
| 91 102 | 
             
                    )
         | 
| 92 103 | 
             
                    logger.info("Retrieved device report for date #{date}")
         | 
| 93 104 | 
             
                    response
         | 
| @@ -98,8 +109,8 @@ module Urbanairship | |
| 98 109 | 
             
                  def initialize(client: required('client'), start_date: required('start_date'),
         | 
| 99 110 | 
             
                                 end_date: required('end_date'), precision: required('precision'))
         | 
| 100 111 | 
             
                    super(client: client)
         | 
| 101 | 
            -
                     | 
| 102 | 
            -
                    @ | 
| 112 | 
            +
                    period_params = Helper.new.get_period_params(start_date, end_date, precision)
         | 
| 113 | 
            +
                    @next_page_path = reports_path('optins/' + period_params)
         | 
| 103 114 | 
             
                    @data_attribute = 'optins'
         | 
| 104 115 | 
             
                  end
         | 
| 105 116 | 
             
                end
         | 
| @@ -108,8 +119,8 @@ module Urbanairship | |
| 108 119 | 
             
                  def initialize(client: required('client'), start_date: required('start_date'),
         | 
| 109 120 | 
             
                                 end_date: required('end_date'), precision: required('precision'))
         | 
| 110 121 | 
             
                    super(client: client)
         | 
| 111 | 
            -
                     | 
| 112 | 
            -
                    @ | 
| 122 | 
            +
                    period_params = Helper.new.get_period_params(start_date, end_date, precision)
         | 
| 123 | 
            +
                    @next_page_path = reports_path('optouts/' + period_params)
         | 
| 113 124 | 
             
                    @data_attribute = 'optouts'
         | 
| 114 125 | 
             
                  end
         | 
| 115 126 | 
             
                end
         | 
| @@ -118,8 +129,8 @@ module Urbanairship | |
| 118 129 | 
             
                  def initialize(client: required('client'), start_date: required('start_date'),
         | 
| 119 130 | 
             
                                 end_date: required('end_date'), precision: required('precision'))
         | 
| 120 131 | 
             
                    super(client: client)
         | 
| 121 | 
            -
                     | 
| 122 | 
            -
                    @ | 
| 132 | 
            +
                    period_params = Helper.new.get_period_params(start_date, end_date, precision)
         | 
| 133 | 
            +
                    @next_page_path = reports_path('sends/' + period_params)
         | 
| 123 134 | 
             
                    @data_attribute = 'sends'
         | 
| 124 135 | 
             
                  end
         | 
| 125 136 | 
             
                end
         | 
| @@ -128,8 +139,8 @@ module Urbanairship | |
| 128 139 | 
             
                  def initialize(client: required('client'), start_date: required('start_date'),
         | 
| 129 140 | 
             
                                 end_date: required('end_date'), precision: required('precision'))
         | 
| 130 141 | 
             
                    super(client: client)
         | 
| 131 | 
            -
                     | 
| 132 | 
            -
                    @ | 
| 142 | 
            +
                    period_params = Helper.new.get_period_params(start_date, end_date, precision)
         | 
| 143 | 
            +
                    @next_page_path = reports_path('responses/' + period_params)
         | 
| 133 144 | 
             
                    @data_attribute = 'responses'
         | 
| 134 145 | 
             
                  end
         | 
| 135 146 | 
             
                end
         | 
| @@ -138,8 +149,8 @@ module Urbanairship | |
| 138 149 | 
             
                  def initialize(client: required('client'), start_date: required('start_date'),
         | 
| 139 150 | 
             
                                 end_date: required('end_date'), precision: required('precision'))
         | 
| 140 151 | 
             
                    super(client: client)
         | 
| 141 | 
            -
                     | 
| 142 | 
            -
                    @ | 
| 152 | 
            +
                    period_params = Helper.new.get_period_params(start_date, end_date, precision)
         | 
| 153 | 
            +
                    @next_page_path = reports_path('opens/' + period_params)
         | 
| 143 154 | 
             
                    @data_attribute = 'opens'
         | 
| 144 155 | 
             
                  end
         | 
| 145 156 | 
             
                end
         | 
| @@ -148,8 +159,8 @@ module Urbanairship | |
| 148 159 | 
             
                  def initialize(client: required('client'), start_date: required('start_date'),
         | 
| 149 160 | 
             
                                 end_date: required('end_date'), precision: required('precision'))
         | 
| 150 161 | 
             
                    super(client: client)
         | 
| 151 | 
            -
                     | 
| 152 | 
            -
                    @ | 
| 162 | 
            +
                    period_params = Helper.new.get_period_params(start_date, end_date, precision)
         | 
| 163 | 
            +
                    @next_page_path = reports_path('timeinapp/' + period_params)
         | 
| 153 164 | 
             
                    @data_attribute = 'timeinapp'
         | 
| 154 165 | 
             
                  end
         | 
| 155 166 | 
             
                end
         | 
    
        data/lib/urbanairship/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: urbanairship
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version:  | 
| 4 | 
            +
              version: 7.0.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Airship
         | 
| 8 8 | 
             
            autorequire:
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2021-03- | 
| 11 | 
            +
            date: 2021-03-22 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rest-client
         |