customerio 5.2.0 → 5.3.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.markdown +5 -0
 - data/README.md +30 -1
 - data/customerio.gemspec +1 -1
 - data/lib/customerio/client.rb +18 -1
 - data/lib/customerio/version.rb +1 -1
 - data/spec/client_spec.rb +35 -1
 - metadata +3 -3
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: d03e20b960d7934a624f045a54d3d367d35822bbe9cd7f3c39374716256e15a5
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: fe48ba820bb31d76d86d66dadc3dcf63dc7dc89d88b25c3b836a631a356e4fb9
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: be98051f37025cd4cf23693790663e908f6a4718ed195653fe66931c84f072fdb555ccecbe18d0d587a3ad4297fe48d84677c074edbcf1c821849cfda41fe471
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: a77fed86492d234f04a062fa2a0acb3c287b9f8d53601ddfcf033f0563069c705b21dc04ae8912ca22023542e198ca1980360e4885a36517b3d049e58d4e6ad7
         
     | 
    
        data/CHANGELOG.markdown
    CHANGED
    
    | 
         @@ -1,3 +1,8 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ## Customerio 5.3.0 - December 8, 2023
         
     | 
| 
      
 2 
     | 
    
         
            +
            ### Changed
         
     | 
| 
      
 3 
     | 
    
         
            +
            - The `identify` method has been updated to allow the customer ID to be specified separately from the attributes, using the `customer_id` attribute. This allows a person to be updated by identifying them by e.g.: their email address. Thanks to trwalzer, jrbeck and jeremyw for the original changes that this is based on.
         
     | 
| 
      
 4 
     | 
    
         
            +
            - It is no longer possible to set the `customer_id` attribute on a person. This is a side-effect of the changes to the `identify` method.
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       1 
6 
     | 
    
         
             
            ## Customerio 5.2.0 - December 8, 2023
         
     | 
| 
       2 
7 
     | 
    
         
             
            ### Changed
         
     | 
| 
       3 
8 
     | 
    
         
             
            - The `identify` method will now automatically use the `cio_id` attribute as the customer ID when calling the track service. This allows a customer to be updated using `identify` to modify the `id` and `email` attributes.
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -95,7 +95,7 @@ $customerio.identify( 
     | 
|
| 
       95 
95 
     | 
    
         
             
            )
         
     | 
| 
       96 
96 
     | 
    
         
             
            ```
         
     | 
| 
       97 
97 
     | 
    
         | 
| 
       98 
     | 
    
         
            -
            ### Updating customers
         
     | 
| 
      
 98 
     | 
    
         
            +
            ### Updating customers: Changing identifiers
         
     | 
| 
       99 
99 
     | 
    
         | 
| 
       100 
100 
     | 
    
         
             
            You can use the identify operation to update customers.
         
     | 
| 
       101 
101 
     | 
    
         
             
            If you need to change the `id` or `email` identifiers for a customer,
         
     | 
| 
         @@ -113,6 +113,35 @@ $customerio.identify( 
     | 
|
| 
       113 
113 
     | 
    
         
             
            )
         
     | 
| 
       114 
114 
     | 
    
         
             
            ```
         
     | 
| 
       115 
115 
     | 
    
         | 
| 
      
 116 
     | 
    
         
            +
            This method requires either the `id` or `cio_id` for the person. It does not work with email addresses.
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
            You can also use this method to make other updates to the person using the `cio_id`.
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            ### Updating customers: Using email address
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
            If you need to identify a person using their email address, then you can do so
         
     | 
| 
      
 123 
     | 
    
         
            +
            by passing in a customer ID to the `identify` method. This allows you to specify
         
     | 
| 
      
 124 
     | 
    
         
            +
            a customer ID that is different than the one used in the `id` attribute. E.g.:
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 127 
     | 
    
         
            +
            # Arguments
         
     | 
| 
      
 128 
     | 
    
         
            +
            # customer_id (required) - the customer ID to use for this customer, may be an id, email address, or the cio_id.
         
     | 
| 
      
 129 
     | 
    
         
            +
            #                         This will be used to construct the URL but not sent in the body attributes.
         
     | 
| 
      
 130 
     | 
    
         
            +
            # attributes (required) - a hash of information about the customer. You can pass any
         
     | 
| 
      
 131 
     | 
    
         
            +
            #                         information that would be useful in your triggers. You
         
     | 
| 
      
 132 
     | 
    
         
            +
            #                         must at least pass in an id, email, and created_at timestamp.
         
     | 
| 
      
 133 
     | 
    
         
            +
             
     | 
| 
      
 134 
     | 
    
         
            +
            $customerio.identify(
         
     | 
| 
      
 135 
     | 
    
         
            +
              :customer_id => "bob@example.com",
         
     | 
| 
      
 136 
     | 
    
         
            +
              :location => "Australia"
         
     | 
| 
      
 137 
     | 
    
         
            +
            )
         
     | 
| 
      
 138 
     | 
    
         
            +
            ```
         
     | 
| 
      
 139 
     | 
    
         
            +
             
     | 
| 
      
 140 
     | 
    
         
            +
            Note:
         
     | 
| 
      
 141 
     | 
    
         
            +
             
     | 
| 
      
 142 
     | 
    
         
            +
             * If you want to use the `cio_id` in the `customer_id` field of `identify_customer_id`, you will need to prefix it with `"cio_"`. E.g.: `"cio_f000000d"` for a `cio_id` of `f000000d`.
         
     | 
| 
      
 143 
     | 
    
         
            +
             * The `identify` method can identify the person using one of `customer_id`, `cio_id` or `id`. The order of precedence is `customer_id` > `cio_id` > `id`.
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
       116 
145 
     | 
    
         
             
            ### Deleting customers
         
     | 
| 
       117 
146 
     | 
    
         | 
| 
       118 
147 
     | 
    
         
             
            Deleting a customer will remove them, and all their information from
         
     | 
    
        data/customerio.gemspec
    CHANGED
    
    | 
         @@ -6,7 +6,7 @@ Gem::Specification.new do |gem| 
     | 
|
| 
       6 
6 
     | 
    
         
             
              gem.email         = ["john@customer.io"]
         
     | 
| 
       7 
7 
     | 
    
         
             
              gem.description   = "A ruby client for the Customer.io event API."
         
     | 
| 
       8 
8 
     | 
    
         
             
              gem.summary       = "A ruby client for the Customer.io event API."
         
     | 
| 
       9 
     | 
    
         
            -
              gem.homepage      = " 
     | 
| 
      
 9 
     | 
    
         
            +
              gem.homepage      = "https://customer.io"
         
     | 
| 
       10 
10 
     | 
    
         
             
              gem.license       = "MIT"
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              gem.files         = `git ls-files`.split($\)
         
     | 
    
        data/lib/customerio/client.rb
    CHANGED
    
    | 
         @@ -151,16 +151,33 @@ module Customerio 
     | 
|
| 
       151 
151 
     | 
    
         | 
| 
       152 
152 
     | 
    
         
             
                def create_or_update(attributes = {})
         
     | 
| 
       153 
153 
     | 
    
         
             
                  attributes = Hash[attributes.map { |(k,v)| [ k.to_sym, v ] }]
         
     | 
| 
       154 
     | 
    
         
            -
                  if is_empty?(attributes[:id]) && is_empty?(attributes[:cio_id])
         
     | 
| 
      
 154 
     | 
    
         
            +
                  if is_empty?(attributes[:id]) && is_empty?(attributes[:cio_id]) && is_empty?(attributes[:customer_id])
         
     | 
| 
       155 
155 
     | 
    
         
             
                    raise MissingIdAttributeError.new("Must provide a customer id")
         
     | 
| 
       156 
156 
     | 
    
         
             
                  end
         
     | 
| 
       157 
157 
     | 
    
         | 
| 
       158 
158 
     | 
    
         
             
                  # Use cio_id as the identifier, if present,
         
     | 
| 
       159 
159 
     | 
    
         
             
                  # to allow the id and email identifiers to be updated.
         
     | 
| 
      
 160 
     | 
    
         
            +
                  # The person is identified by a customer ID, which is included
         
     | 
| 
      
 161 
     | 
    
         
            +
                  # in the path to the Track v1 API. Choose the ID in this order
         
     | 
| 
      
 162 
     | 
    
         
            +
                  # from highest to lowest precedence:
         
     | 
| 
      
 163 
     | 
    
         
            +
                  #
         
     | 
| 
      
 164 
     | 
    
         
            +
                  # 1. customer_id: "id", an email address, or "cio_id" value.
         
     | 
| 
      
 165 
     | 
    
         
            +
                  #    Any "cio_id" values need to be prefixed "cio_"
         
     | 
| 
      
 166 
     | 
    
         
            +
                  #    so that the Track v1 API knows it's a cio_id.
         
     | 
| 
      
 167 
     | 
    
         
            +
                  #
         
     | 
| 
      
 168 
     | 
    
         
            +
                  # 2. cio_id: The cio_id value (no prefix required).
         
     | 
| 
      
 169 
     | 
    
         
            +
                  #
         
     | 
| 
      
 170 
     | 
    
         
            +
                  # 3. id: The id value.
         
     | 
| 
       160 
171 
     | 
    
         
             
                  customer_id = attributes[:id]
         
     | 
| 
       161 
172 
     | 
    
         
             
                  if !is_empty?(attributes[:cio_id])
         
     | 
| 
       162 
173 
     | 
    
         
             
                    customer_id = "cio_" + attributes[:cio_id]
         
     | 
| 
       163 
174 
     | 
    
         
             
                  end
         
     | 
| 
      
 175 
     | 
    
         
            +
                  if !is_empty?(attributes[:customer_id])
         
     | 
| 
      
 176 
     | 
    
         
            +
                    customer_id = attributes[:customer_id]
         
     | 
| 
      
 177 
     | 
    
         
            +
                  end
         
     | 
| 
      
 178 
     | 
    
         
            +
                  # customer_id is not an attribute, so remove it.
         
     | 
| 
      
 179 
     | 
    
         
            +
                  attributes.delete(:customer_id)
         
     | 
| 
      
 180 
     | 
    
         
            +
             
     | 
| 
       164 
181 
     | 
    
         
             
                  url = customer_path(customer_id)
         
     | 
| 
       165 
182 
     | 
    
         
             
                  @client.request_and_verify_response(:put, url, attributes)
         
     | 
| 
       166 
183 
     | 
    
         
             
                end
         
     | 
    
        data/lib/customerio/version.rb
    CHANGED
    
    
    
        data/spec/client_spec.rb
    CHANGED
    
    | 
         @@ -173,6 +173,7 @@ describe Customerio::Client do 
     | 
|
| 
       173 
173 
     | 
    
         
             
                  lambda { client.identify(email: "customer@example.com") }.should raise_error(Customerio::Client::MissingIdAttributeError)
         
     | 
| 
       174 
174 
     | 
    
         
             
                  lambda { client.identify(id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError)
         
     | 
| 
       175 
175 
     | 
    
         
             
                  lambda { client.identify(cio_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError)
         
     | 
| 
      
 176 
     | 
    
         
            +
                  lambda { client.identify(customer_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError)
         
     | 
| 
       176 
177 
     | 
    
         
             
                end
         
     | 
| 
       177 
178 
     | 
    
         | 
| 
       178 
179 
     | 
    
         
             
                it 'should not raise errors when attribute keys are strings' do
         
     | 
| 
         @@ -223,6 +224,39 @@ describe Customerio::Client do 
     | 
|
| 
       223 
224 
     | 
    
         
             
                    location: "here"
         
     | 
| 
       224 
225 
     | 
    
         
             
                  })
         
     | 
| 
       225 
226 
     | 
    
         
             
                end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
                it "uses provided id rather than id" do
         
     | 
| 
      
 229 
     | 
    
         
            +
                  stub_request(:put, api_uri('/api/v1/customers/1234')).
         
     | 
| 
      
 230 
     | 
    
         
            +
                    with(body: json(id: "5")).
         
     | 
| 
      
 231 
     | 
    
         
            +
                    to_return(status: 200, body: "", headers: {})
         
     | 
| 
      
 232 
     | 
    
         
            +
             
     | 
| 
      
 233 
     | 
    
         
            +
                  client.identify(
         
     | 
| 
      
 234 
     | 
    
         
            +
                    customer_id: "1234",
         
     | 
| 
      
 235 
     | 
    
         
            +
                    id: "5"
         
     | 
| 
      
 236 
     | 
    
         
            +
                  )
         
     | 
| 
      
 237 
     | 
    
         
            +
                end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
                it "uses provided cio_id rather than id" do
         
     | 
| 
      
 240 
     | 
    
         
            +
                  stub_request(:put, api_uri('/api/v1/customers/cio_5')).
         
     | 
| 
      
 241 
     | 
    
         
            +
                    with(body: json(id: "5")).
         
     | 
| 
      
 242 
     | 
    
         
            +
                    to_return(status: 200, body: "", headers: {})
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
                  client.identify(
         
     | 
| 
      
 245 
     | 
    
         
            +
                    customer_id: "cio_5",
         
     | 
| 
      
 246 
     | 
    
         
            +
                    id: "5"
         
     | 
| 
      
 247 
     | 
    
         
            +
                  )
         
     | 
| 
      
 248 
     | 
    
         
            +
                end
         
     | 
| 
      
 249 
     | 
    
         
            +
             
     | 
| 
      
 250 
     | 
    
         
            +
                it "uses provided email rather than id" do
         
     | 
| 
      
 251 
     | 
    
         
            +
                  stub_request(:put, api_uri('/api/v1/customers/customer@example.com')).
         
     | 
| 
      
 252 
     | 
    
         
            +
                    with(body: json(id: "5")).
         
     | 
| 
      
 253 
     | 
    
         
            +
                    to_return(status: 200, body: "", headers: {})
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
                  client.identify(
         
     | 
| 
      
 256 
     | 
    
         
            +
                    customer_id: "customer@example.com",
         
     | 
| 
      
 257 
     | 
    
         
            +
                    id: "5"
         
     | 
| 
      
 258 
     | 
    
         
            +
                  )
         
     | 
| 
      
 259 
     | 
    
         
            +
                end
         
     | 
| 
       226 
260 
     | 
    
         
             
              end
         
     | 
| 
       227 
261 
     | 
    
         | 
| 
       228 
262 
     | 
    
         
             
              describe "#delete" do
         
     | 
| 
         @@ -650,7 +684,7 @@ describe Customerio::Client do 
     | 
|
| 
       650 
684 
     | 
    
         
             
                  }.to raise_error(Customerio::Client::ParamError, 'timestamp must be a valid timestamp')
         
     | 
| 
       651 
685 
     | 
    
         
             
                end
         
     | 
| 
       652 
686 
     | 
    
         
             
              end
         
     | 
| 
       653 
     | 
    
         
            -
             
     | 
| 
      
 687 
     | 
    
         
            +
             
     | 
| 
       654 
688 
     | 
    
         
             
              describe "#merge_customers" do
         
     | 
| 
       655 
689 
     | 
    
         
             
                before(:each) do
         
     | 
| 
       656 
690 
     | 
    
         
             
                  @client = Customerio::Client.new("SITE_ID", "API_KEY", :json => true)
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: customerio
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 5. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 5.3.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - John Allison
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2023-12- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2023-12-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: multi_json
         
     | 
| 
         @@ -123,7 +123,7 @@ files: 
     | 
|
| 
       123 
123 
     | 
    
         
             
            - spec/base_client_spec.rb
         
     | 
| 
       124 
124 
     | 
    
         
             
            - spec/client_spec.rb
         
     | 
| 
       125 
125 
     | 
    
         
             
            - spec/spec_helper.rb
         
     | 
| 
       126 
     | 
    
         
            -
            homepage:  
     | 
| 
      
 126 
     | 
    
         
            +
            homepage: https://customer.io
         
     | 
| 
       127 
127 
     | 
    
         
             
            licenses:
         
     | 
| 
       128 
128 
     | 
    
         
             
            - MIT
         
     | 
| 
       129 
129 
     | 
    
         
             
            metadata: {}
         
     |