loops_sdk 0.2.0 → 1.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.md +6 -0
- data/README.md +148 -55
- data/lib/loops_sdk/base.rb +10 -4
- data/lib/loops_sdk/version.rb +1 -1
- data/lib/loops_sdk.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a8b0b6350209acdbb57d8414d35d24c27dc3b53ddbb8dfebf30893221863483
|
4
|
+
data.tar.gz: 462b317da348740e35285efb05d67aa59f71adb54644094f2fe666b6968f8fad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a4b0181a592ff98fda831db5235def393d934375957215cb223219148dce1cbe940271ff5a6881dddec2dc5a9b68bc307009d1ebce947a2522aa672f6f8d752
|
7
|
+
data.tar.gz: b6134652c05daf397d23c1a30bf86fb89f8ae681c60b88e645f6921941f2c327dc1acedc2e86c6db26addb819e7e2b09287373e58460942aaa66766471e1a2c9
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## v1.0.0 - Feb 26, 2025
|
2
|
+
|
3
|
+
- JSON from API errors is now accessible from the `APIError` class.
|
4
|
+
- Added support for two new contact property endpoints: `ContactProperties.create()` and `ContactProperties.list()`.
|
5
|
+
- Deprecated and removed the `CustomFields.list()` method (you can now use `ContactProperties.list()` instead).
|
6
|
+
|
1
7
|
## v0.2.0 - Oct 29, 2024
|
2
8
|
|
3
9
|
Added rate limit handling with `RateLimitError`.
|
data/README.md
CHANGED
@@ -38,9 +38,10 @@ LoopsSdk.configure do |config|
|
|
38
38
|
end
|
39
39
|
```
|
40
40
|
|
41
|
+
Then you can call methods in your code:
|
42
|
+
|
41
43
|
```ruby
|
42
44
|
begin
|
43
|
-
|
44
45
|
response = LoopsSdk::Transactional.send(
|
45
46
|
transactional_id: "closfz8ui02yq......",
|
46
47
|
email: "dan@loops.so",
|
@@ -48,11 +49,12 @@ begin
|
|
48
49
|
loginUrl: "https://app.domain.com/login?code=1234567890"
|
49
50
|
}
|
50
51
|
)
|
51
|
-
|
52
52
|
render json: response
|
53
53
|
|
54
54
|
rescue LoopsSdk::APIError => e
|
55
|
-
#
|
55
|
+
# JSON returned by the API is in error.json and the HTTP code is in error.statusCode
|
56
|
+
# Error messages explaining the issue can be found in error.json['message']
|
57
|
+
Rails.logger.error("Loops API Error: #{e.json['message']} (Status: #{e.statusCode})")
|
56
58
|
end
|
57
59
|
```
|
58
60
|
|
@@ -98,15 +100,16 @@ You can use custom contact properties in API calls. Please make sure to [add cus
|
|
98
100
|
|
99
101
|
## Methods
|
100
102
|
|
101
|
-
- [ApiKey.test()](#
|
102
|
-
- [Contacts.create()](#
|
103
|
-
- [Contacts.update()](#
|
104
|
-
- [Contacts.find()](#
|
105
|
-
- [Contacts.delete()](#
|
106
|
-
- [
|
107
|
-
- [
|
108
|
-
- [
|
109
|
-
- [
|
103
|
+
- [ApiKey.test()](#apikeytest)
|
104
|
+
- [Contacts.create()](#contactscreate)
|
105
|
+
- [Contacts.update()](#contactsupdate)
|
106
|
+
- [Contacts.find()](#contactsfind)
|
107
|
+
- [Contacts.delete()](#contactsdelete)
|
108
|
+
- [ContactProperties.create()](#contactpropertiescreate)
|
109
|
+
- [ContactProperties.list()](#contactpropertieslist)
|
110
|
+
- [MailingLists.list()](#mailinglistslist)
|
111
|
+
- [Events.send()](#eventssend)
|
112
|
+
- [Transactional.send()](#transactionalsend)
|
110
113
|
|
111
114
|
---
|
112
115
|
|
@@ -145,7 +148,7 @@ This method will return a success or error message:
|
|
145
148
|
|
146
149
|
---
|
147
150
|
|
148
|
-
|
151
|
+
### Contacts.create()
|
149
152
|
|
150
153
|
Create a new contact.
|
151
154
|
|
@@ -199,7 +202,7 @@ This method will return a success or error message:
|
|
199
202
|
|
200
203
|
---
|
201
204
|
|
202
|
-
|
205
|
+
### Contacts.update()
|
203
206
|
|
204
207
|
Update a contact.
|
205
208
|
|
@@ -348,6 +351,133 @@ This method will return a success or error message:
|
|
348
351
|
|
349
352
|
---
|
350
353
|
|
354
|
+
### ContactProperties.create()
|
355
|
+
|
356
|
+
Create a new contact property.
|
357
|
+
|
358
|
+
[API Reference](https://loops.so/docs/api-reference/create-contact-property)
|
359
|
+
|
360
|
+
#### Parameters
|
361
|
+
|
362
|
+
| Name | Type | Required | Notes |
|
363
|
+
| ------ | ------ | -------- | -------------------------------------------------------------------------------------- |
|
364
|
+
| `name` | string | Yes | The name of the property. Should be in camelCase, like `planName` or `favouriteColor`. |
|
365
|
+
| `type` | string | Yes | The property's value type.<br />Can be one of `string`, `number`, `boolean` or `date`. |
|
366
|
+
|
367
|
+
#### Examples
|
368
|
+
|
369
|
+
```ruby
|
370
|
+
response = LoopsSdk::ContactProperties.create(
|
371
|
+
name: "planName",
|
372
|
+
type: "string"
|
373
|
+
)
|
374
|
+
```
|
375
|
+
|
376
|
+
#### Response
|
377
|
+
|
378
|
+
This method will return a success or error message:
|
379
|
+
|
380
|
+
```json
|
381
|
+
{
|
382
|
+
"success": true
|
383
|
+
}
|
384
|
+
```
|
385
|
+
|
386
|
+
```json
|
387
|
+
{
|
388
|
+
"success": false,
|
389
|
+
"message": "An error message here."
|
390
|
+
}
|
391
|
+
```
|
392
|
+
|
393
|
+
---
|
394
|
+
|
395
|
+
### ContactProperties.list()
|
396
|
+
|
397
|
+
Get a list of your account's contact properties.
|
398
|
+
|
399
|
+
[API Reference](https://loops.so/docs/api-reference/list-contact-properties)
|
400
|
+
|
401
|
+
#### Parameters
|
402
|
+
|
403
|
+
| Name | Type | Required | Notes |
|
404
|
+
| ------ | ------ | -------- | --------------------------------------------------------------- |
|
405
|
+
| `list` | string | No | Use "custom" to retrieve only your account's custom properties. |
|
406
|
+
|
407
|
+
#### Example
|
408
|
+
|
409
|
+
```ruby
|
410
|
+
response = LoopsSdk::ContactProperties.list
|
411
|
+
|
412
|
+
response = LoopsSdk::ContactProperties.list(list: "custom")
|
413
|
+
```
|
414
|
+
|
415
|
+
#### Response
|
416
|
+
|
417
|
+
This method will return a list of contact property objects containing `key`, `label` and `type` attributes.
|
418
|
+
|
419
|
+
```json
|
420
|
+
[
|
421
|
+
{
|
422
|
+
"key": "firstName",
|
423
|
+
"label": "First Name",
|
424
|
+
"type": "string"
|
425
|
+
},
|
426
|
+
{
|
427
|
+
"key": "lastName",
|
428
|
+
"label": "Last Name",
|
429
|
+
"type": "string"
|
430
|
+
},
|
431
|
+
{
|
432
|
+
"key": "email",
|
433
|
+
"label": "Email",
|
434
|
+
"type": "string"
|
435
|
+
},
|
436
|
+
{
|
437
|
+
"key": "notes",
|
438
|
+
"label": "Notes",
|
439
|
+
"type": "string"
|
440
|
+
},
|
441
|
+
{
|
442
|
+
"key": "source",
|
443
|
+
"label": "Source",
|
444
|
+
"type": "string"
|
445
|
+
},
|
446
|
+
{
|
447
|
+
"key": "userGroup",
|
448
|
+
"label": "User Group",
|
449
|
+
"type": "string"
|
450
|
+
},
|
451
|
+
{
|
452
|
+
"key": "userId",
|
453
|
+
"label": "User Id",
|
454
|
+
"type": "string"
|
455
|
+
},
|
456
|
+
{
|
457
|
+
"key": "subscribed",
|
458
|
+
"label": "Subscribed",
|
459
|
+
"type": "boolean"
|
460
|
+
},
|
461
|
+
{
|
462
|
+
"key": "createdAt",
|
463
|
+
"label": "Created At",
|
464
|
+
"type": "date"
|
465
|
+
},
|
466
|
+
{
|
467
|
+
"key": "favoriteColor",
|
468
|
+
"label": "Favorite Color",
|
469
|
+
"type": "string"
|
470
|
+
},
|
471
|
+
{
|
472
|
+
"key": "plan",
|
473
|
+
"label": "Plan",
|
474
|
+
"type": "string"
|
475
|
+
}
|
476
|
+
]
|
477
|
+
```
|
478
|
+
|
479
|
+
---
|
480
|
+
|
351
481
|
### MailingLists.list()
|
352
482
|
|
353
483
|
Get a list of your account's mailing lists. [Read more about mailing lists](https://loops.so/docs/contacts/mailing-lists)
|
@@ -366,7 +496,7 @@ response = LoopsSdk::MailingLists.list
|
|
366
496
|
|
367
497
|
#### Response
|
368
498
|
|
369
|
-
This method will return a list of mailing list objects containing `id`, `name` and `isPublic` attributes.
|
499
|
+
This method will return a list of mailing list objects containing `id`, `name`, `description` and `isPublic` attributes.
|
370
500
|
|
371
501
|
If your account has no mailing lists, an empty list will be returned.
|
372
502
|
|
@@ -375,11 +505,13 @@ If your account has no mailing lists, an empty list will be returned.
|
|
375
505
|
{
|
376
506
|
"id": "cm06f5v0e45nf0ml5754o9cix",
|
377
507
|
"name": "Main list",
|
508
|
+
"description": "All customers.",
|
378
509
|
"isPublic": true
|
379
510
|
},
|
380
511
|
{
|
381
512
|
"id": "cm16k73gq014h0mmj5b6jdi9r",
|
382
513
|
"name": "Investors",
|
514
|
+
"description": null,
|
383
515
|
"isPublic": false
|
384
516
|
}
|
385
517
|
]
|
@@ -504,7 +636,7 @@ response = LoopsSdk::Transactional.send(
|
|
504
636
|
data: "JVBERi0xLjMKJcTl8uXrp/Og0MTGCjQgMCBvYmoKPD...",
|
505
637
|
},
|
506
638
|
],
|
507
|
-
|
639
|
+
)
|
508
640
|
```
|
509
641
|
|
510
642
|
#### Response
|
@@ -540,45 +672,6 @@ If there is a problem with the request, a descriptive error message will be retu
|
|
540
672
|
|
541
673
|
---
|
542
674
|
|
543
|
-
### CustomFields.list()
|
544
|
-
|
545
|
-
Get a list of your account's custom fields. These are custom properties that can be added to contacts to store extra data. [Read more about contact properties](https://loops.so/docs/contacts/properties)
|
546
|
-
|
547
|
-
[API Reference](https://loops.so/docs/api-reference/list-custom-fields)
|
548
|
-
|
549
|
-
#### Parameters
|
550
|
-
|
551
|
-
None
|
552
|
-
|
553
|
-
#### Example
|
554
|
-
|
555
|
-
```ruby
|
556
|
-
response LoopsSdk::CustomFields.list
|
557
|
-
```
|
558
|
-
|
559
|
-
#### Response
|
560
|
-
|
561
|
-
This method will return a list of custom field objects containing `key`, `label` and `type` attributes.
|
562
|
-
|
563
|
-
If your account has no custom fields, an empty list will be returned.
|
564
|
-
|
565
|
-
```json
|
566
|
-
[
|
567
|
-
{
|
568
|
-
"key": "favoriteColor",
|
569
|
-
"label": "Favorite Color",
|
570
|
-
"type": "string"
|
571
|
-
},
|
572
|
-
{
|
573
|
-
"key": "plan",
|
574
|
-
"label": "Plan",
|
575
|
-
"type": "string"
|
576
|
-
}
|
577
|
-
]
|
578
|
-
```
|
579
|
-
|
580
|
-
---
|
581
|
-
|
582
675
|
## Contributing
|
583
676
|
|
584
677
|
Bug reports and pull requests are welcome. Please read our [Contributing Guidelines](CONTRIBUTING.md).
|
data/lib/loops_sdk/base.rb
CHANGED
@@ -40,12 +40,18 @@ module LoopsSdk
|
|
40
40
|
end
|
41
41
|
|
42
42
|
class APIError < StandardError
|
43
|
-
attr_reader :
|
43
|
+
attr_reader :statusCode, :json
|
44
44
|
|
45
45
|
def initialize(status, body)
|
46
|
-
@
|
47
|
-
@
|
48
|
-
|
46
|
+
@statusCode = status
|
47
|
+
@json = body
|
48
|
+
message = begin
|
49
|
+
parsed = JSON.parse(body)
|
50
|
+
parsed["message"] ? ": #{parsed["message"]}" : ""
|
51
|
+
rescue JSON::ParserError
|
52
|
+
""
|
53
|
+
end
|
54
|
+
super("API request failed with status #{statusCode}#{message}")
|
49
55
|
end
|
50
56
|
end
|
51
57
|
end
|
data/lib/loops_sdk/version.rb
CHANGED
data/lib/loops_sdk.rb
CHANGED
@@ -9,7 +9,7 @@ require_relative "loops_sdk/contacts"
|
|
9
9
|
require_relative "loops_sdk/events"
|
10
10
|
require_relative "loops_sdk/mailing_lists"
|
11
11
|
require_relative "loops_sdk/transactional"
|
12
|
-
require_relative "loops_sdk/
|
12
|
+
require_relative "loops_sdk/contact_properties"
|
13
13
|
require_relative "loops_sdk/api_key"
|
14
14
|
|
15
15
|
module LoopsSdk
|
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: 0.
|
4
|
+
version: 1.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:
|
11
|
+
date: 2025-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|