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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8eeddad6948c305215fe8efe6bd218550fad021aaa12615f6e32b8d69d552fda
4
- data.tar.gz: b4632c42a4762b587fc5a96b05c8aa25f734823bb2fe5de31a181556a6ac976d
3
+ metadata.gz: 359ea0bf26c0f71ba07ff6e8fe435ecf6ee72c33e994aeff4040661199768a9b
4
+ data.tar.gz: 62512a5d7c037aef79d56e4bc6bf13b71aaa0e11fd74ae9b5ac8b35f75779f04
5
5
  SHA512:
6
- metadata.gz: e9cff4116be11b5c86aa25137b0fe832ee1dd1875a33a3625554a094048781b2637388ed6065c8cd23be28d6b1771567f1fd5704c63f2f985aae4f3abd5b9f1f
7
- data.tar.gz: fc376fc43f139688c1e76bbe5a06cad0c39e6b3762f481636438a33e1548fa9af6eb1ea90f228384cccad162acb88aec927f50cf1487d35e88e18cdba1abc893
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.
@@ -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).
@@ -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
@@ -8,11 +8,11 @@ module LoopsSdk
8
8
  name: name,
9
9
  type: type
10
10
  }
11
- make_request(:post, "v1/contacts/properties", {}, body)
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
@@ -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
@@ -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", {}, email_data)
20
+ make_request(method: :post, path: "v1/transactional", headers: headers, body: email_data)
21
21
  end
22
22
  end
23
23
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoopsSdk
4
- VERSION = "1.1.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.1.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-27 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