-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the support for :customer_id into the base identify method
- Loading branch information
1 parent
6362c80
commit a1f7832
Showing
3 changed files
with
28 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -120,7 +120,7 @@ You can also use this method to make other updates to the person using the `cio_ | |
### Updating customers: Using email address | ||
|
||
If you need to identify a person using their email address, then you can do so | ||
by using the `identify_customer_id` method. This allows you to specify | ||
by passing in a customer ID to the `identify` method. This allows you to specify | ||
a customer ID that is different than the one used in the `id` attribute. E.g.: | ||
|
||
```ruby | ||
|
@@ -131,17 +131,16 @@ a customer ID that is different than the one used in the `id` attribute. E.g.: | |
# information that would be useful in your triggers. You | ||
# must at least pass in an id, email, and created_at timestamp. | ||
|
||
$customerio.identify_customer_id( | ||
$customerio.identify( | ||
:customer_id => "[email protected]", | ||
:id => 5, | ||
:email => "[email protected]", | ||
:created_at => customer.created_at.to_i, | ||
:first_name => "Bob", | ||
:plan => "basic" | ||
:location => "Australia" | ||
) | ||
``` | ||
|
||
Note: 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`. | ||
Note: | ||
|
||
* 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`. | ||
* 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`. | ||
|
||
### Deleting customers | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -173,6 +173,7 @@ def json(data) | |
lambda { client.identify(email: "[email protected]") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
lambda { client.identify(id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
lambda { client.identify(cio_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
lambda { client.identify(customer_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
end | ||
|
||
it 'should not raise errors when attribute keys are strings' do | ||
|
@@ -223,15 +224,13 @@ def json(data) | |
location: "here" | ||
}) | ||
end | ||
end | ||
|
||
describe "#identify_customer_id" do | ||
it "uses provided id rather than id" do | ||
stub_request(:put, api_uri('/api/v1/customers/1234')). | ||
with(body: json(id: "5")). | ||
to_return(status: 200, body: "", headers: {}) | ||
|
||
client.identify_customer_id( | ||
client.identify( | ||
customer_id: "1234", | ||
id: "5" | ||
) | ||
|
@@ -242,7 +241,7 @@ def json(data) | |
with(body: json(id: "5")). | ||
to_return(status: 200, body: "", headers: {}) | ||
|
||
client.identify_customer_id( | ||
client.identify( | ||
customer_id: "cio_5", | ||
id: "5" | ||
) | ||
|
@@ -253,20 +252,11 @@ def json(data) | |
with(body: json(id: "5")). | ||
to_return(status: 200, body: "", headers: {}) | ||
|
||
client.identify_customer_id( | ||
client.identify( | ||
customer_id: "[email protected]", | ||
id: "5" | ||
) | ||
end | ||
|
||
it "requires a customer_id attribute" do | ||
lambda { client.identify_customer_id() }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
lambda { client.identify_customer_id(customer_id: "") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
# None of these are customer_id | ||
lambda { client.identify_customer_id(id: "5") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
lambda { client.identify_customer_id(cio_id: "cio_5") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
lambda { client.identify_customer_id(email: "[email protected]") }.should raise_error(Customerio::Client::MissingIdAttributeError) | ||
end | ||
end | ||
|
||
describe "#delete" do | ||
|