loops_sdk 1.0.0 → 1.2.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: 0a8b0b6350209acdbb57d8414d35d24c27dc3b53ddbb8dfebf30893221863483
4
- data.tar.gz: 462b317da348740e35285efb05d67aa59f71adb54644094f2fe666b6968f8fad
3
+ metadata.gz: 359ea0bf26c0f71ba07ff6e8fe435ecf6ee72c33e994aeff4040661199768a9b
4
+ data.tar.gz: 62512a5d7c037aef79d56e4bc6bf13b71aaa0e11fd74ae9b5ac8b35f75779f04
5
5
  SHA512:
6
- metadata.gz: 2a4b0181a592ff98fda831db5235def393d934375957215cb223219148dce1cbe940271ff5a6881dddec2dc5a9b68bc307009d1ebce947a2522aa672f6f8d752
7
- data.tar.gz: b6134652c05daf397d23c1a30bf86fb89f8ae681c60b88e645f6921941f2c327dc1acedc2e86c6db26addb819e7e2b09287373e58460942aaa66766471e1a2c9
6
+ metadata.gz: e35da20e6e24efa3a37a7a8fdf09acedb6b7e333d515251c095ce8222c7635834dc6fa0acc42d2cab516253b7e101654665b76f252bcce7965cde97adbc98717
7
+ data.tar.gz: c20564327c894dad4b4b97ffc65b5b5eca60f7bf5eaad5d106b00ca1e3dd3b87910fc48c47f16b3688af314ef8effe34177a843f55d141df4e6ec0eb628b1e90
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Loops Ruby SDK
2
2
 
3
+ [![Gem Total Downloads](https://img.shields.io/gem/dt/loops_sdk?style=social)](https://rubygems.org/gems/loops_sdk)
4
+
3
5
  ## Introduction
4
6
 
5
7
  This is the official Ruby SDK for [Loops](https://loops.so), an email platform for modern software companies.
@@ -110,6 +112,7 @@ You can use custom contact properties in API calls. Please make sure to [add cus
110
112
  - [MailingLists.list()](#mailinglistslist)
111
113
  - [Events.send()](#eventssend)
112
114
  - [Transactional.send()](#transactionalsend)
115
+ - [Transactional.list()](#transactionallist)
113
116
 
114
117
  ---
115
118
 
@@ -235,7 +238,8 @@ response = LoopsSdk::Contacts.update(
235
238
  email: "newemail@gmail.com",
236
239
  properties: {
237
240
  userId: "1234",
238
- })
241
+ }
242
+ )
239
243
  ```
240
244
 
241
245
  #### Response
@@ -555,7 +559,7 @@ response = LoopsSdk::Events.send(
555
559
  cm06f5v0e45nf0ml5754o9cix: true,
556
560
  cm16k73gq014h0mmj5b6jdi9r: false,
557
561
  },
558
- })
562
+ )
559
563
 
560
564
  # In this case with both email and userId present, the system will look for a contact with either a
561
565
  # matching `email` or `user_id` value.
@@ -570,7 +574,7 @@ response = LoopsSdk::Events.send(
570
574
  firstName: "Bob",
571
575
  plan: "pro",
572
576
  },
573
- })
577
+ )
574
578
  ```
575
579
 
576
580
  #### Response
@@ -672,6 +676,74 @@ If there is a problem with the request, a descriptive error message will be retu
672
676
 
673
677
  ---
674
678
 
679
+ ### Transactional.list()
680
+
681
+ Get a list of published transactional emails.
682
+
683
+ [API Reference](https://loops.so/docs/api-reference/list-transactional-emails)
684
+
685
+ #### Parameters
686
+
687
+ | Name | Type | Required | Notes |
688
+ | --------- | ------- | -------- | ----------------------------------------------------------------------------------------------------------------------------- |
689
+ | `perPage` | integer | No | How many results to return per page. Must be between 10 and 50. Defaults to 20 if omitted. |
690
+ | `cursor` | string | No | A cursor, to return a specific page of results. Cursors can be found from the `pagination.nextCursor` value in each response. |
691
+
692
+ #### Example
693
+
694
+ ```ruby
695
+ response = LoopsSdk::Transactional.list
696
+
697
+ response = LoopsSdk::Transactional.list(perPage: 15)
698
+ ```
699
+
700
+ #### Response
701
+
702
+ ```json
703
+ {
704
+ "pagination": {
705
+ "totalResults": 23,
706
+ "returnedResults": 20,
707
+ "perPage": 20,
708
+ "totalPages": 2,
709
+ "nextCursor": "clyo0q4wo01p59fsecyxqsh38",
710
+ "nextPage": "https://app.loops.so/api/v1/transactional?cursor=clyo0q4wo01p59fsecyxqsh38&perPage=20"
711
+ },
712
+ "data": [
713
+ {
714
+ "id": "clfn0k1yg001imo0fdeqg30i8",
715
+ "lastUpdated": "2023-11-06T17:48:07.249Z",
716
+ "dataVariables": []
717
+ },
718
+ {
719
+ "id": "cll42l54f20i1la0lfooe3z12",
720
+ "lastUpdated": "2025-02-02T02:56:28.845Z",
721
+ "dataVariables": [
722
+ "confirmationUrl"
723
+ ]
724
+ },
725
+ {
726
+ "id": "clw6rbuwp01rmeiyndm80155l",
727
+ "lastUpdated": "2024-05-14T19:02:52.000Z",
728
+ "dataVariables": [
729
+ "firstName",
730
+ "lastName",
731
+ "inviteLink"
732
+ ]
733
+ },
734
+ ...
735
+ ]
736
+ }
737
+ ```
738
+
739
+ ---
740
+
741
+ ## Testing
742
+
743
+ Run tests with `bundle exec rspec`.
744
+
745
+ ---
746
+
675
747
  ## Contributing
676
748
 
677
749
  Bug reports and pull requests are welcome. Please read our [Contributing Guidelines](CONTRIBUTING.md).
@@ -4,7 +4,7 @@ module LoopsSdk
4
4
  class ApiKey < Base
5
5
  class << self
6
6
  def test
7
- make_request(:get, "v1/api-key")
7
+ make_request(method: :get, path: "v1/api-key")
8
8
  end
9
9
  end
10
10
  end
@@ -20,9 +20,19 @@ module LoopsSdk
20
20
  end
21
21
  end
22
22
 
23
- def make_request(method, path, params = {}, body = nil)
24
- response = LoopsSdk.configuration.connection.send(method, path, params) do |req|
23
+ def make_request(method:, path:, headers: {}, params: {}, body: nil)
24
+ # Merge default headers with request-specific headers
25
+ merged_headers = LoopsSdk.configuration.connection.headers.merge(headers)
26
+
27
+ response = LoopsSdk.configuration.connection.send(
28
+ method: method,
29
+ path: path,
30
+ headers: merged_headers,
31
+ params: params,
32
+ body: body
33
+ ) do |req|
25
34
  req.body = body.to_json if body
35
+ req
26
36
  end
27
37
  handle_response(response)
28
38
  end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ module LoopsSdk
4
+ class ContactProperties < Base
5
+ class << self
6
+ def create(name:, type:)
7
+ body = {
8
+ name: name,
9
+ type: type
10
+ }
11
+ make_request(method: :post, path: "v1/contacts/properties", body: body)
12
+ end
13
+ def list(list: nil)
14
+ raise ArgumentError, "List value must be nil, 'custom' or 'all'." unless [nil, "custom", "all"].include?(list)
15
+ make_request(method: :get, path: "v1/contacts/properties", params: { list: list || "all" })
16
+ end
17
+ end
18
+ end
19
+ end
@@ -8,7 +8,7 @@ module LoopsSdk
8
8
  email: email,
9
9
  mailingLists: mailing_lists
10
10
  }.merge(properties)
11
- make_request(:post, "v1/contacts/create", {}, contact_data)
11
+ make_request(method: :post, path: "v1/contacts/create", body: contact_data)
12
12
  end
13
13
 
14
14
  def update(email:, properties: {}, mailing_lists: {})
@@ -16,7 +16,7 @@ module LoopsSdk
16
16
  email: email,
17
17
  mailingLists: mailing_lists
18
18
  }.merge(properties)
19
- make_request(:put, "v1/contacts/update", {}, contact_data)
19
+ make_request(method: :put, path: "v1/contacts/update", body: contact_data)
20
20
  end
21
21
 
22
22
  def find(email: nil, user_id: nil)
@@ -24,7 +24,7 @@ module LoopsSdk
24
24
  raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?
25
25
 
26
26
  params = email ? { email: email } : { userId: user_id }
27
- make_request(:get, "v1/contacts/find", params)
27
+ make_request(method: :get, path: "v1/contacts/find", params: params)
28
28
  end
29
29
 
30
30
  def delete(email: nil, user_id: nil)
@@ -32,7 +32,7 @@ module LoopsSdk
32
32
  raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?
33
33
 
34
34
  body = email ? { email: email } : { userId: user_id }
35
- make_request(:post, "v1/contacts/delete", {}, body)
35
+ make_request(method: :post, path: "v1/contacts/delete", body: body)
36
36
  end
37
37
  end
38
38
  end
@@ -3,7 +3,7 @@
3
3
  module LoopsSdk
4
4
  class Events < Base
5
5
  class << self
6
- def send(event_name:, email: nil, user_id: nil, contact_properties: {}, event_properties: {}, mailing_lists: {})
6
+ def send(event_name:, email: nil, user_id: nil, contact_properties: {}, event_properties: {}, mailing_lists: {}, headers: {})
7
7
  raise ArgumentError, "You must provide an email or user_id value." if email.nil? && user_id.nil?
8
8
 
9
9
  event_data = {
@@ -13,7 +13,7 @@ module LoopsSdk
13
13
  eventProperties: event_properties.compact,
14
14
  mailingLists: mailing_lists.compact
15
15
  }.merge(contact_properties)
16
- make_request(:post, "v1/events/send", {}, event_data)
16
+ make_request(method: :post, path: "v1/events/send", headers: headers, body: event_data)
17
17
  end
18
18
  end
19
19
  end
@@ -4,7 +4,7 @@ module LoopsSdk
4
4
  class MailingLists < Base
5
5
  class << self
6
6
  def list
7
- make_request(:get, "v1/lists")
7
+ make_request(method: :get, path: "v1/lists")
8
8
  end
9
9
  end
10
10
  end
@@ -3,7 +3,10 @@
3
3
  module LoopsSdk
4
4
  class Transactional < Base
5
5
  class << self
6
- def send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: [])
6
+ def list(perPage: 20, cursor: nil)
7
+ make_request(method: :get, path: "v1/transactional", params: { perPage: perPage, cursor: cursor })
8
+ end
9
+ def send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: [], headers: {})
7
10
  attachments = attachments.map do |attachment|
8
11
  attachment.transform_keys { |key| key == :content_type ? :contentType : key }
9
12
  end
@@ -14,7 +17,7 @@ module LoopsSdk
14
17
  dataVariables: data_variables,
15
18
  attachments: attachments
16
19
  }.compact
17
- make_request(:post, "v1/transactional", {}, email_data)
20
+ make_request(method: :post, path: "v1/transactional", headers: headers, body: email_data)
18
21
  end
19
22
  end
20
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoopsSdk
4
- VERSION = "1.0.0"
4
+ VERSION = "1.2.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.0.0
4
+ version: 1.2.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-02-26 00:00:00.000000000 Z
11
+ date: 2025-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -31,24 +31,18 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".rubocop.yml"
35
- - CHANGELOG.md
36
- - CODE_OF_CONDUCT.md
37
- - CONTRIBUTING.md
38
34
  - LICENSE.txt
39
35
  - README.md
40
- - Rakefile
41
36
  - lib/loops_sdk.rb
42
37
  - lib/loops_sdk/api_key.rb
43
38
  - lib/loops_sdk/base.rb
44
39
  - lib/loops_sdk/configuration.rb
40
+ - lib/loops_sdk/contact_properties.rb
45
41
  - lib/loops_sdk/contacts.rb
46
- - lib/loops_sdk/custom_fields.rb
47
42
  - lib/loops_sdk/events.rb
48
43
  - lib/loops_sdk/mailing_lists.rb
49
44
  - lib/loops_sdk/transactional.rb
50
45
  - lib/loops_sdk/version.rb
51
- - sig/loops_sdk.rbs
52
46
  homepage: https://loops.so/docs/api-reference
53
47
  licenses:
54
48
  - MIT
data/.rubocop.yml DELETED
@@ -1,11 +0,0 @@
1
- AllCops:
2
- TargetRubyVersion: 3.0
3
-
4
- Style/StringLiterals:
5
- EnforcedStyle: double_quotes
6
-
7
- Style/StringLiteralsInInterpolation:
8
- EnforcedStyle: double_quotes
9
-
10
- Metrics/ParameterLists:
11
- Max: 6
data/CHANGELOG.md DELETED
@@ -1,21 +0,0 @@
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
-
11
- ## v0.1.2 - Aug 16, 2024
12
-
13
- Support for resetting contact properties with `nil`.
14
-
15
- ## v0.1.1 - Aug 16, 2024
16
-
17
- Added `ApiKey.test` method for testing API keys.
18
-
19
- ## v0.1.0 - Aug 16, 2024
20
-
21
- Initial release.
data/CODE_OF_CONDUCT.md DELETED
@@ -1,132 +0,0 @@
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 DELETED
@@ -1,51 +0,0 @@
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/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "bundler/gem_tasks"
4
- require "rubocop/rake_task"
5
-
6
- RuboCop::RakeTask.new
7
-
8
- task default: :rubocop
@@ -1,11 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module LoopsSdk
4
- class CustomFields < Base
5
- class << self
6
- def list
7
- make_request(:get, "v1/contacts/customFields")
8
- end
9
- end
10
- end
11
- end
data/sig/loops_sdk.rbs DELETED
@@ -1,4 +0,0 @@
1
- module LoopsSdk
2
- VERSION: String
3
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
- end