loops_sdk 0.1.2 → 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 +10 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/CONTRIBUTING.md +51 -0
- data/README.md +187 -66
- data/lib/loops_sdk/base.rb +24 -6
- data/lib/loops_sdk/contacts.rb +0 -1
- data/lib/loops_sdk/version.rb +1 -1
- data/lib/loops_sdk.rb +1 -1
- metadata +4 -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,13 @@
|
|
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
|
+
|
7
|
+
## v0.2.0 - Oct 29, 2024
|
8
|
+
|
9
|
+
Added rate limit handling with `RateLimitError`.
|
10
|
+
|
1
11
|
## v0.1.2 - Aug 16, 2024
|
2
12
|
|
3
13
|
Support for resetting contact properties with `nil`.
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
- Demonstrating empathy and kindness toward other people
|
21
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
- Giving and gracefully accepting constructive feedback
|
23
|
+
- Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
- Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
- The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
- Public or private harassment
|
34
|
+
- Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
- Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,51 @@
|
|
1
|
+
# Contributing to Loops Ruby SDK
|
2
|
+
|
3
|
+
Thank you for your interest in contributing to Loops Ruby SDK. We welcome contributions from the community and are excited to see what you'll bring to the project.
|
4
|
+
|
5
|
+
## Getting Started
|
6
|
+
|
7
|
+
1. Fork the repository on GitHub.
|
8
|
+
2. Clone your fork locally: `git clone <https://github.com/Loops-so/loops-rb.git`>
|
9
|
+
3. Create a new branch for your feature or bug fix: `git checkout -b your-branch-name`
|
10
|
+
|
11
|
+
## Making Changes
|
12
|
+
|
13
|
+
1. Make your changes in your branch.
|
14
|
+
2. Follow the coding style and conventions used in the project.
|
15
|
+
3. Write clear, concise commit messages.
|
16
|
+
4. Test your changes thoroughly.
|
17
|
+
|
18
|
+
## Submitting a Pull Request
|
19
|
+
|
20
|
+
1. Push your changes to your fork on GitHub.
|
21
|
+
2. From your fork, open a pull request in the correct branch of the main repository.
|
22
|
+
3. Provide a clear title and description for your pull request using our PR template.
|
23
|
+
4. Link any relevant issues in the pull request description.
|
24
|
+
|
25
|
+
## Code of Conduct
|
26
|
+
|
27
|
+
Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project, you agree to abide by its terms.
|
28
|
+
|
29
|
+
## Reporting Bugs
|
30
|
+
|
31
|
+
If you find a bug, please open an issue on GitHub. Include as much detail as possible:
|
32
|
+
|
33
|
+
- A clear and descriptive title
|
34
|
+
- Steps to reproduce the issue
|
35
|
+
- Expected behavior
|
36
|
+
- Actual behavior
|
37
|
+
- Any error messages or screenshots
|
38
|
+
|
39
|
+
## Suggesting Enhancements
|
40
|
+
|
41
|
+
We welcome suggestions for enhancements! Please open an issue on GitHub with:
|
42
|
+
|
43
|
+
- A clear and descriptive title
|
44
|
+
- A detailed description of the proposed enhancement
|
45
|
+
- Any examples or mock-ups if applicable
|
46
|
+
|
47
|
+
## Questions?
|
48
|
+
|
49
|
+
If you have any questions, feel free to open an issue or contact the maintainers directly.
|
50
|
+
|
51
|
+
Thank you for contributing!
|
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,35 @@ begin
|
|
48
49
|
loginUrl: "https://app.domain.com/login?code=1234567890"
|
49
50
|
}
|
50
51
|
)
|
52
|
+
render json: response
|
53
|
+
|
54
|
+
rescue LoopsSdk::APIError => e
|
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})")
|
58
|
+
end
|
59
|
+
```
|
60
|
+
|
61
|
+
## Handling rate limits
|
62
|
+
|
63
|
+
You can use the check for rate limit issues with your requests.
|
64
|
+
|
65
|
+
You can access details about the rate limits from the `limit` and `remaining` attributes.
|
66
|
+
|
67
|
+
```ruby
|
68
|
+
begin
|
69
|
+
|
70
|
+
response = LoopsSdk::Contacts.update(
|
71
|
+
email: "dan@loops.so"
|
72
|
+
)
|
51
73
|
|
52
74
|
render json: response
|
53
75
|
|
76
|
+
rescue LoopsSdk::RateLimitError => e
|
77
|
+
Rails.logger.error("Rate limit exceeded (#{e.limit} requests per second)")
|
78
|
+
# Code here to re-try this request
|
54
79
|
rescue LoopsSdk::APIError => e
|
55
|
-
#
|
80
|
+
# Handle other errors
|
56
81
|
end
|
57
82
|
```
|
58
83
|
|
@@ -75,15 +100,16 @@ You can use custom contact properties in API calls. Please make sure to [add cus
|
|
75
100
|
|
76
101
|
## Methods
|
77
102
|
|
78
|
-
- [ApiKey.test()](#
|
79
|
-
- [Contacts.create()](#
|
80
|
-
- [Contacts.update()](#
|
81
|
-
- [Contacts.find()](#
|
82
|
-
- [Contacts.delete()](#
|
83
|
-
- [
|
84
|
-
- [
|
85
|
-
- [
|
86
|
-
- [
|
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)
|
87
113
|
|
88
114
|
---
|
89
115
|
|
@@ -122,7 +148,7 @@ This method will return a success or error message:
|
|
122
148
|
|
123
149
|
---
|
124
150
|
|
125
|
-
|
151
|
+
### Contacts.create()
|
126
152
|
|
127
153
|
Create a new contact.
|
128
154
|
|
@@ -146,8 +172,8 @@ contact_properties = {
|
|
146
172
|
favoriteColor: "Red" /* Custom property */,
|
147
173
|
};
|
148
174
|
mailing_lists = {
|
149
|
-
|
150
|
-
|
175
|
+
cm06f5v0e45nf0ml5754o9cix: true,
|
176
|
+
cm16k73gq014h0mmj5b6jdi9r: false,
|
151
177
|
};
|
152
178
|
response = LoopsSdk::Contacts.create(
|
153
179
|
email: "hello@gmail.com",
|
@@ -176,7 +202,7 @@ This method will return a success or error message:
|
|
176
202
|
|
177
203
|
---
|
178
204
|
|
179
|
-
|
205
|
+
### Contacts.update()
|
180
206
|
|
181
207
|
Update a contact.
|
182
208
|
|
@@ -252,7 +278,7 @@ You must use one parameter in the request.
|
|
252
278
|
```ruby
|
253
279
|
response = LoopsSdk::Contacts.find(email: "hello@gmail.com")
|
254
280
|
|
255
|
-
response = LoopsSdk::Contacts.find(
|
281
|
+
response = LoopsSdk::Contacts.find(user_id: "12345")
|
256
282
|
```
|
257
283
|
|
258
284
|
#### Response
|
@@ -272,6 +298,9 @@ If no contact is found, an empty list will be returned.
|
|
272
298
|
"subscribed": true,
|
273
299
|
"userGroup": "",
|
274
300
|
"userId": "12345",
|
301
|
+
"mailingLists": {
|
302
|
+
"cm06f5v0e45nf0ml5754o9cix": true
|
303
|
+
},
|
275
304
|
"favoriteColor": "Blue" /* Custom property */
|
276
305
|
}
|
277
306
|
]
|
@@ -281,7 +310,7 @@ If no contact is found, an empty list will be returned.
|
|
281
310
|
|
282
311
|
### Contacts.delete()
|
283
312
|
|
284
|
-
Delete a contact
|
313
|
+
Delete a contact.
|
285
314
|
|
286
315
|
[API Reference](https://loops.so/docs/api-reference/delete-contact)
|
287
316
|
|
@@ -299,7 +328,7 @@ You must use one parameter in the request.
|
|
299
328
|
```ruby
|
300
329
|
response = LoopsSdk::Contacts.delete(email: "hello@gmail.com")
|
301
330
|
|
302
|
-
response = LoopsSdk::Contacts.delete(
|
331
|
+
response = LoopsSdk::Contacts.delete(user_id: "12345")
|
303
332
|
```
|
304
333
|
|
305
334
|
#### Response
|
@@ -322,6 +351,133 @@ This method will return a success or error message:
|
|
322
351
|
|
323
352
|
---
|
324
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
|
+
|
325
481
|
### MailingLists.list()
|
326
482
|
|
327
483
|
Get a list of your account's mailing lists. [Read more about mailing lists](https://loops.so/docs/contacts/mailing-lists)
|
@@ -340,19 +496,23 @@ response = LoopsSdk::MailingLists.list
|
|
340
496
|
|
341
497
|
#### Response
|
342
498
|
|
343
|
-
This method will return a list of mailing list objects containing `id` and `
|
499
|
+
This method will return a list of mailing list objects containing `id`, `name`, `description` and `isPublic` attributes.
|
344
500
|
|
345
501
|
If your account has no mailing lists, an empty list will be returned.
|
346
502
|
|
347
503
|
```json
|
348
504
|
[
|
349
505
|
{
|
350
|
-
"id": "
|
351
|
-
"name": "Main list"
|
506
|
+
"id": "cm06f5v0e45nf0ml5754o9cix",
|
507
|
+
"name": "Main list",
|
508
|
+
"description": "All customers.",
|
509
|
+
"isPublic": true
|
352
510
|
},
|
353
511
|
{
|
354
|
-
"id": "
|
355
|
-
"name": "Investors"
|
512
|
+
"id": "cm16k73gq014h0mmj5b6jdi9r",
|
513
|
+
"name": "Investors",
|
514
|
+
"description": null,
|
515
|
+
"isPublic": false
|
356
516
|
}
|
357
517
|
]
|
358
518
|
```
|
@@ -392,8 +552,8 @@ response = LoopsSdk::Events.send(
|
|
392
552
|
signupDate: "2024-03-21T10:09:23Z",
|
393
553
|
},
|
394
554
|
mailing_lists: {
|
395
|
-
|
396
|
-
|
555
|
+
cm06f5v0e45nf0ml5754o9cix: true,
|
556
|
+
cm16k73gq014h0mmj5b6jdi9r: false,
|
397
557
|
},
|
398
558
|
})
|
399
559
|
|
@@ -476,7 +636,7 @@ response = LoopsSdk::Transactional.send(
|
|
476
636
|
data: "JVBERi0xLjMKJcTl8uXrp/Og0MTGCjQgMCBvYmoKPD...",
|
477
637
|
},
|
478
638
|
],
|
479
|
-
|
639
|
+
)
|
480
640
|
```
|
481
641
|
|
482
642
|
#### Response
|
@@ -512,45 +672,6 @@ If there is a problem with the request, a descriptive error message will be retu
|
|
512
672
|
|
513
673
|
---
|
514
674
|
|
515
|
-
### CustomFields.list()
|
516
|
-
|
517
|
-
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)
|
518
|
-
|
519
|
-
[API Reference](https://loops.so/docs/api-reference/list-custom-fields)
|
520
|
-
|
521
|
-
#### Parameters
|
522
|
-
|
523
|
-
None
|
524
|
-
|
525
|
-
#### Example
|
526
|
-
|
527
|
-
```ruby
|
528
|
-
response LoopsSdk::CustomFields.list
|
529
|
-
```
|
530
|
-
|
531
|
-
#### Response
|
532
|
-
|
533
|
-
This method will return a list of custom field objects containing `key`, `label` and `type` attributes.
|
534
|
-
|
535
|
-
If your account has no custom fields, an empty list will be returned.
|
536
|
-
|
537
|
-
```json
|
538
|
-
[
|
539
|
-
{
|
540
|
-
"key": "favoriteColor",
|
541
|
-
"label": "Favorite Color",
|
542
|
-
"type": "string"
|
543
|
-
},
|
544
|
-
{
|
545
|
-
"key": "plan",
|
546
|
-
"label": "Plan",
|
547
|
-
"type": "string"
|
548
|
-
}
|
549
|
-
]
|
550
|
-
```
|
551
|
-
|
552
|
-
---
|
553
|
-
|
554
675
|
## Contributing
|
555
676
|
|
556
|
-
Bug reports and pull requests are welcome
|
677
|
+
Bug reports and pull requests are welcome. Please read our [Contributing Guidelines](CONTRIBUTING.md).
|
data/lib/loops_sdk/base.rb
CHANGED
@@ -9,6 +9,10 @@ module LoopsSdk
|
|
9
9
|
case response.status
|
10
10
|
when 200
|
11
11
|
JSON.parse(response.body)
|
12
|
+
when 429
|
13
|
+
limit = response.headers["x-ratelimit-limit"]
|
14
|
+
remaining = response.headers["x-ratelimit-remaining"]
|
15
|
+
raise RateLimitError.new(limit, remaining)
|
12
16
|
when 400, 404, 405, 409, 500
|
13
17
|
raise APIError.new(response.status, response.body)
|
14
18
|
else
|
@@ -25,15 +29,29 @@ module LoopsSdk
|
|
25
29
|
end
|
26
30
|
end
|
27
31
|
|
28
|
-
|
29
|
-
|
32
|
+
class RateLimitError < StandardError
|
33
|
+
attr_reader :limit, :remaining
|
34
|
+
|
35
|
+
def initialize(limit, remaining)
|
36
|
+
@limit = limit
|
37
|
+
@remaining = remaining
|
38
|
+
super("Rate limit of #{limit} requests per second exceeded.")
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
30
42
|
class APIError < StandardError
|
31
|
-
attr_reader :
|
43
|
+
attr_reader :statusCode, :json
|
32
44
|
|
33
45
|
def initialize(status, body)
|
34
|
-
@
|
35
|
-
@
|
36
|
-
|
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}")
|
37
55
|
end
|
38
56
|
end
|
39
57
|
end
|
data/lib/loops_sdk/contacts.rb
CHANGED
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
|
@@ -33,6 +33,8 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- ".rubocop.yml"
|
35
35
|
- CHANGELOG.md
|
36
|
+
- CODE_OF_CONDUCT.md
|
37
|
+
- CONTRIBUTING.md
|
36
38
|
- LICENSE.txt
|
37
39
|
- README.md
|
38
40
|
- Rakefile
|