loops_sdk 1.1.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 +4 -4
- data/README.md +8 -0
- data/lib/loops_sdk/api_key.rb +1 -1
- data/lib/loops_sdk/base.rb +12 -2
- data/lib/loops_sdk/contact_properties.rb +2 -2
- data/lib/loops_sdk/contacts.rb +4 -4
- data/lib/loops_sdk/events.rb +2 -2
- data/lib/loops_sdk/mailing_lists.rb +1 -1
- data/lib/loops_sdk/transactional.rb +3 -3
- data/lib/loops_sdk/version.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: 359ea0bf26c0f71ba07ff6e8fe435ecf6ee72c33e994aeff4040661199768a9b
|
4
|
+
data.tar.gz: 62512a5d7c037aef79d56e4bc6bf13b71aaa0e11fd74ae9b5ac8b35f75779f04
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
+
[](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.
|
@@ -736,6 +738,12 @@ response = LoopsSdk::Transactional.list(perPage: 15)
|
|
736
738
|
|
737
739
|
---
|
738
740
|
|
741
|
+
## Testing
|
742
|
+
|
743
|
+
Run tests with `bundle exec rspec`.
|
744
|
+
|
745
|
+
---
|
746
|
+
|
739
747
|
## Contributing
|
740
748
|
|
741
749
|
Bug reports and pull requests are welcome. Please read our [Contributing Guidelines](CONTRIBUTING.md).
|
data/lib/loops_sdk/api_key.rb
CHANGED
data/lib/loops_sdk/base.rb
CHANGED
@@ -20,9 +20,19 @@ module LoopsSdk
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
def make_request(method
|
24
|
-
|
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
|
@@ -8,11 +8,11 @@ module LoopsSdk
|
|
8
8
|
name: name,
|
9
9
|
type: type
|
10
10
|
}
|
11
|
-
make_request(:post, "v1/contacts/properties",
|
11
|
+
make_request(method: :post, path: "v1/contacts/properties", body: body)
|
12
12
|
end
|
13
13
|
def list(list: nil)
|
14
14
|
raise ArgumentError, "List value must be nil, 'custom' or 'all'." unless [nil, "custom", "all"].include?(list)
|
15
|
-
make_request(:get, "v1/contacts/properties", {list: list || "all"})
|
15
|
+
make_request(method: :get, path: "v1/contacts/properties", params: { list: list || "all" })
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/loops_sdk/contacts.rb
CHANGED
@@ -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",
|
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",
|
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",
|
35
|
+
make_request(method: :post, path: "v1/contacts/delete", body: body)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
data/lib/loops_sdk/events.rb
CHANGED
@@ -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",
|
16
|
+
make_request(method: :post, path: "v1/events/send", headers: headers, body: event_data)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -4,9 +4,9 @@ module LoopsSdk
|
|
4
4
|
class Transactional < Base
|
5
5
|
class << self
|
6
6
|
def list(perPage: 20, cursor: nil)
|
7
|
-
make_request(:get, "v1/transactional", { perPage: perPage, cursor: cursor })
|
7
|
+
make_request(method: :get, path: "v1/transactional", params: { perPage: perPage, cursor: cursor })
|
8
8
|
end
|
9
|
-
def send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: [])
|
9
|
+
def send(transactional_id:, email:, add_to_audience: false, data_variables: {}, attachments: [], headers: {})
|
10
10
|
attachments = attachments.map do |attachment|
|
11
11
|
attachment.transform_keys { |key| key == :content_type ? :contentType : key }
|
12
12
|
end
|
@@ -17,7 +17,7 @@ module LoopsSdk
|
|
17
17
|
dataVariables: data_variables,
|
18
18
|
attachments: attachments
|
19
19
|
}.compact
|
20
|
-
make_request(:post, "v1/transactional",
|
20
|
+
make_request(method: :post, path: "v1/transactional", headers: headers, body: email_data)
|
21
21
|
end
|
22
22
|
end
|
23
23
|
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: 1.
|
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-
|
11
|
+
date: 2025-05-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|