loops_sdk 1.2.1 → 2.1.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/README.md +115 -6
- data/lib/loops_sdk/contacts.rb +20 -1
- data/lib/loops_sdk/version.rb +1 -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: 65b81eba842a1765bb2bc99006cbcaab839e442b3ee90ea92076cef8fba8f942
|
|
4
|
+
data.tar.gz: 3e544adfb4c2ed0b1069fc1a455773397a27a8254d9e8fe75ebbc33be2dfa9e8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 565a16854a58cf5510b8c6c189394f7b62bea1aa6b1448e41dbb1759268d6f25fe9f366190a29896b974a49648e2068478db8e4622c9db3bbb2a29ef25aba855
|
|
7
|
+
data.tar.gz: cd2b0f20ad57991723c3ca2bb68efe71b3759a0669a602be1c71583368fb7f3ae79dabbbb068ba9392918081edf9e465fcd4ee1f50c721ea5cbbcd2cc866d010
|
data/README.md
CHANGED
|
@@ -95,6 +95,7 @@ Each contact in Loops has a set of default properties. These will always be retu
|
|
|
95
95
|
- `subscribed`
|
|
96
96
|
- `userGroup`
|
|
97
97
|
- `userId`
|
|
98
|
+
- `optInStatus`
|
|
98
99
|
|
|
99
100
|
## Custom contact properties
|
|
100
101
|
|
|
@@ -107,6 +108,8 @@ You can use custom contact properties in API calls. Please make sure to [add cus
|
|
|
107
108
|
- [Contacts.update()](#contactsupdate)
|
|
108
109
|
- [Contacts.find()](#contactsfind)
|
|
109
110
|
- [Contacts.delete()](#contactsdelete)
|
|
111
|
+
- [Contacts.check_suppression()](#contactscheck_suppression)
|
|
112
|
+
- [Contacts.remove_suppression()](#contactsremove_suppression)
|
|
110
113
|
- [ContactProperties.create()](#contactpropertiescreate)
|
|
111
114
|
- [ContactProperties.list()](#contactpropertieslist)
|
|
112
115
|
- [MailingLists.list()](#mailinglistslist)
|
|
@@ -207,9 +210,9 @@ This method will return a success or error message:
|
|
|
207
210
|
|
|
208
211
|
### Contacts.update()
|
|
209
212
|
|
|
210
|
-
Update a contact.
|
|
213
|
+
Update a contact. This method will create a contact if one doesn't already exist.
|
|
211
214
|
|
|
212
|
-
Note: To update a contact's email address, the contact requires a `
|
|
215
|
+
Note: To update a contact's email address, the contact requires a `user_id` value. Then you can make a request with their `user_id` and an updated email address.
|
|
213
216
|
|
|
214
217
|
[API Reference](https://loops.so/docs/api-reference/update-contact)
|
|
215
218
|
|
|
@@ -217,7 +220,8 @@ Note: To update a contact's email address, the contact requires a `userId` value
|
|
|
217
220
|
|
|
218
221
|
| Name | Type | Required | Notes |
|
|
219
222
|
| --------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
220
|
-
| `email` | string |
|
|
223
|
+
| `email` | string | No | The email address of the contact to update. If there is no contact with this email address, a new contact will be created using the email and properties in this request. Required if `user_id` is not present. |
|
|
224
|
+
| `user_id` | string | No | The contact's unique user ID. If you use `user_id` without `email`, this value must have already been added to your contact in Loops. Required if `email` is not present. |
|
|
221
225
|
| `properties` | object | No | An object containing default and any custom properties for your contact.<br />Please [add custom properties](https://loops.so/docs/contacts/properties#custom-contact-properties) in your Loops account before using them with the SDK.<br />Values can be of type `string`, `number`, `nil` (to reset a value), `boolean` or `date` ([see allowed date formats](https://loops.so/docs/contacts/properties#dates)). |
|
|
222
226
|
| `mailing_lists` | object | No | An object of mailing list IDs and boolean subscription statuses. |
|
|
223
227
|
|
|
@@ -233,11 +237,17 @@ response = LoopsSdk::Contacts.update(
|
|
|
233
237
|
properties: contact_properties
|
|
234
238
|
)
|
|
235
239
|
|
|
236
|
-
# Updating a contact's email address using
|
|
240
|
+
# Updating a contact's email address using user_id
|
|
237
241
|
response = LoopsSdk::Contacts.update(
|
|
238
242
|
email: "newemail@gmail.com",
|
|
239
|
-
|
|
240
|
-
|
|
243
|
+
user_id: "1234"
|
|
244
|
+
)
|
|
245
|
+
|
|
246
|
+
# Subscribing a contact to a mailing list
|
|
247
|
+
response = LoopsSdk::Contacts.update(
|
|
248
|
+
email: "hello@gmail.com",
|
|
249
|
+
mailing_lists: {
|
|
250
|
+
cm06f5v0e45nf0ml5754o9cix: true,
|
|
241
251
|
}
|
|
242
252
|
)
|
|
243
253
|
```
|
|
@@ -305,6 +315,7 @@ If no contact is found, an empty list will be returned.
|
|
|
305
315
|
"mailingLists": {
|
|
306
316
|
"cm06f5v0e45nf0ml5754o9cix": true
|
|
307
317
|
},
|
|
318
|
+
"optInStatus": null,
|
|
308
319
|
"favoriteColor": "Blue" /* Custom property */
|
|
309
320
|
}
|
|
310
321
|
]
|
|
@@ -355,6 +366,104 @@ This method will return a success or error message:
|
|
|
355
366
|
|
|
356
367
|
---
|
|
357
368
|
|
|
369
|
+
### Contacts.check_suppression()
|
|
370
|
+
|
|
371
|
+
Check if a contact is suppressed.
|
|
372
|
+
|
|
373
|
+
[API Reference](https://loops.so/docs/api-reference/check-contact-suppression)
|
|
374
|
+
|
|
375
|
+
#### Parameters
|
|
376
|
+
|
|
377
|
+
You must use one parameter in the request.
|
|
378
|
+
|
|
379
|
+
| Name | Type | Required | Notes |
|
|
380
|
+
| --------- | ------ | -------- | ----- |
|
|
381
|
+
| `email` | string | No | |
|
|
382
|
+
| `user_id` | string | No | |
|
|
383
|
+
|
|
384
|
+
#### Example
|
|
385
|
+
|
|
386
|
+
```ruby
|
|
387
|
+
response = LoopsSdk::Contacts.check_suppression(email: "hello@gmail.com")
|
|
388
|
+
|
|
389
|
+
response = LoopsSdk::Contacts.check_suppression(user_id: "12345")
|
|
390
|
+
```
|
|
391
|
+
|
|
392
|
+
#### Response
|
|
393
|
+
|
|
394
|
+
This method will return the suppression status for a contact and the suppression removal quota.
|
|
395
|
+
|
|
396
|
+
```json
|
|
397
|
+
{
|
|
398
|
+
"contact": {
|
|
399
|
+
"id": "cll6b3i8901a9jx0oyktl2m4u",
|
|
400
|
+
"email": "hello@gmail.com",
|
|
401
|
+
"userId": "12345"
|
|
402
|
+
},
|
|
403
|
+
"isSuppressed": true,
|
|
404
|
+
"removalQuota": {
|
|
405
|
+
"limit": 100,
|
|
406
|
+
"remaining": 4
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
```
|
|
410
|
+
|
|
411
|
+
```json
|
|
412
|
+
{
|
|
413
|
+
"success": false,
|
|
414
|
+
"message": "An email or userId is required."
|
|
415
|
+
}
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
---
|
|
419
|
+
|
|
420
|
+
### Contacts.remove_suppression()
|
|
421
|
+
|
|
422
|
+
Remove suppression for a contact.
|
|
423
|
+
|
|
424
|
+
[API Reference](https://loops.so/docs/api-reference/remove-contact-suppression)
|
|
425
|
+
|
|
426
|
+
#### Parameters
|
|
427
|
+
|
|
428
|
+
You must use one parameter in the request.
|
|
429
|
+
|
|
430
|
+
| Name | Type | Required | Notes |
|
|
431
|
+
| --------- | ------ | -------- | ----- |
|
|
432
|
+
| `email` | string | No | |
|
|
433
|
+
| `user_id` | string | No | |
|
|
434
|
+
|
|
435
|
+
#### Example
|
|
436
|
+
|
|
437
|
+
```ruby
|
|
438
|
+
response = LoopsSdk::Contacts.remove_suppression(email: "hello@gmail.com")
|
|
439
|
+
|
|
440
|
+
response = LoopsSdk::Contacts.remove_suppression(user_id: "12345")
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
#### Response
|
|
444
|
+
|
|
445
|
+
This method will return a success or error message:
|
|
446
|
+
|
|
447
|
+
```json
|
|
448
|
+
{
|
|
449
|
+
"success": true,
|
|
450
|
+
"message": "Email removed from suppression list.",
|
|
451
|
+
"removalQuota": {
|
|
452
|
+
"limit": 100,
|
|
453
|
+
"remaining": 4
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
```json
|
|
459
|
+
{
|
|
460
|
+
"success": false,
|
|
461
|
+
"message": "This contact is not suppressed."
|
|
462
|
+
}
|
|
463
|
+
```
|
|
464
|
+
|
|
465
|
+
---
|
|
466
|
+
|
|
358
467
|
### ContactProperties.create()
|
|
359
468
|
|
|
360
469
|
Create a new contact property.
|
data/lib/loops_sdk/contacts.rb
CHANGED
|
@@ -11,9 +11,12 @@ module LoopsSdk
|
|
|
11
11
|
make_request(method: :post, path: "v1/contacts/create", body: contact_data)
|
|
12
12
|
end
|
|
13
13
|
|
|
14
|
-
def update(email
|
|
14
|
+
def update(email: nil, user_id: nil, properties: {}, mailing_lists: {})
|
|
15
|
+
raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?
|
|
16
|
+
|
|
15
17
|
contact_data = {
|
|
16
18
|
email: email,
|
|
19
|
+
userId: user_id,
|
|
17
20
|
mailingLists: mailing_lists
|
|
18
21
|
}.merge(properties)
|
|
19
22
|
make_request(method: :put, path: "v1/contacts/update", body: contact_data)
|
|
@@ -34,6 +37,22 @@ module LoopsSdk
|
|
|
34
37
|
body = email ? { email: email } : { userId: user_id }
|
|
35
38
|
make_request(method: :post, path: "v1/contacts/delete", body: body)
|
|
36
39
|
end
|
|
40
|
+
|
|
41
|
+
def check_suppression(email: nil, user_id: nil)
|
|
42
|
+
raise ArgumentError, "Only one parameter is permitted." if email && user_id
|
|
43
|
+
raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?
|
|
44
|
+
|
|
45
|
+
params = email ? { email: email } : { userId: user_id }
|
|
46
|
+
make_request(method: :get, path: "v1/contacts/suppression", params: params)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def remove_suppression(email: nil, user_id: nil)
|
|
50
|
+
raise ArgumentError, "Only one parameter is permitted." if email && user_id
|
|
51
|
+
raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?
|
|
52
|
+
|
|
53
|
+
params = email ? { email: email } : { userId: user_id }
|
|
54
|
+
make_request(method: :delete, path: "v1/contacts/suppression", params: params)
|
|
55
|
+
end
|
|
37
56
|
end
|
|
38
57
|
end
|
|
39
58
|
end
|
data/lib/loops_sdk/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: loops_sdk
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Rowden
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-04-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -65,7 +65,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
65
65
|
- !ruby/object:Gem::Version
|
|
66
66
|
version: '0'
|
|
67
67
|
requirements: []
|
|
68
|
-
rubygems_version: 3.
|
|
68
|
+
rubygems_version: 3.4.10
|
|
69
69
|
signing_key:
|
|
70
70
|
specification_version: 4
|
|
71
71
|
summary: The official Ruby SDK for Loops.
|