loops_sdk 1.2.1 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cef2e34971e3c98b0ceaf334bb80415ab912b3b3c384f9bc0f3daee486af3137
4
- data.tar.gz: 43bd7500763bdc8eec606220a122cd5c2acb9ce24e3fa7070917fb13ffa0c541
3
+ metadata.gz: aeb0e30d4d199706208e701f31340143aa7eae407b04f561b6bc14fa94f05346
4
+ data.tar.gz: f48c5dc9e2e5c69314656fc20f0e49402ad803b57a01cb00ad9079a837601ce8
5
5
  SHA512:
6
- metadata.gz: 99dffd773f4da8f24ea7679433c8e1c239d96f2b8df98b8fbf7d93cd732b6ca241fe6e1380864a0c74439a31b756b4671d908d8dd2c2cffec43c88347938772f
7
- data.tar.gz: '0128fc22eac586c9c3500283493b5519ab279cf5d46fcc46ea92e15c2d057eb106a75fdd9322413ae101d4b460fe0dd33ec6cc244ea8c9751b3cc76903b217c8'
6
+ metadata.gz: 526bec40bd9353f5c7c62adc9c049e70cee26eead9d81619ffe9933f5054aa4d416447a18b5d5aea966cf795784b3bf0446d132fa5c2963e16e1a975cffc5d8a
7
+ data.tar.gz: d178e957e3b3287ce91e2598d2e871fb91e4075e9d7dbd8a6002d5d4a11cb91b11e0355c031a38e71ab18c7093320ec4d8619792e4aa628411347f3d1d5b87a3
data/README.md CHANGED
@@ -207,7 +207,7 @@ This method will return a success or error message:
207
207
 
208
208
  ### Contacts.update()
209
209
 
210
- Update a contact.
210
+ Update a contact. This method will create a contact if one doesn't already exist.
211
211
 
212
212
  Note: To update a contact's email address, the contact requires a `userId` value. Then you can make a request with their `userId` and an updated email address.
213
213
 
@@ -217,7 +217,8 @@ Note: To update a contact's email address, the contact requires a `userId` value
217
217
 
218
218
  | Name | Type | Required | Notes |
219
219
  | --------------- | ------ | -------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
220
- | `email` | string | Yes | 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. |
220
+ | `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. |
221
+ | `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
222
  | `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
223
  | `mailing_lists` | object | No | An object of mailing list IDs and boolean subscription statuses. |
223
224
 
@@ -240,6 +241,14 @@ response = LoopsSdk::Contacts.update(
240
241
  userId: "1234",
241
242
  }
242
243
  )
244
+
245
+ # Subscribing a contact to a mailing list
246
+ response = LoopsSdk::Contacts.update(
247
+ email: "hello@gmail.com",
248
+ mailing_lists: {
249
+ cm06f5v0e45nf0ml5754o9cix: true,
250
+ }
251
+ )
243
252
  ```
244
253
 
245
254
  #### Response
@@ -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:, properties: {}, mailing_lists: {})
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoopsSdk
4
- VERSION = "1.2.1"
4
+ VERSION = "2.0.0"
5
5
  end
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: 1.2.1
4
+ version: 2.0.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: 2025-05-22 00:00:00.000000000 Z
11
+ date: 2025-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday