loops_rails 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4a01b300b7edd07daf94406b06af9fcc49ecca1a8f731240ead0bfa845baed9
4
- data.tar.gz: 8891a9cce0094da646b82f24e1f9b29a9e1d9d567d7ef2baaad788cd6ceb9443
3
+ metadata.gz: f79d4af123b8a77eaf6ad7533bcab6d19e6178a5fbba0f21e73066db1009f50b
4
+ data.tar.gz: ff8d1fe3eb16b606a0914406672f30821d1a169f747ea2d6db1966df0ad99718
5
5
  SHA512:
6
- metadata.gz: 84ec1a3d1406415776686e8cb97edb2dff593f8be3fc8592eb80f40ee838a89c991e15309af14e9ac6f46c44cec347e0f1a4302e8b229cc0adba2302bf632f14
7
- data.tar.gz: 89474f2371cd1e2ca408e590aced6520a40d30540574a2c9d379df5b1b5b39a74756388b1cbd642e66681e0643c81617ab72ad06876f41c48d53416d925ff065
6
+ metadata.gz: f7273b8e7c1bc6a8b4bf4e9c5e0b6be1eea2d32107c3d8f55f366b69e6f5b8feb3ba01586f0c115f27ae03717efb96b758d105b10af4c5d2b37c6d2679b8f692
7
+ data.tar.gz: a3eeab9a2f5ba91e4a86f6a678ea080a9905eb7cbb00009b9dab867a654c1d0e490031ca1804577641fc049cf6c06f46eae806c04306a1b482a42102848e2c39
data/README.md CHANGED
@@ -21,7 +21,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
21
21
  ```ruby
22
22
  client = LoopsRails::Client.new(api_key: "your_api_key")
23
23
 
24
- client.api_keys.test
24
+ client.test_api_key
25
25
  client.contacts.create(email: "john@example.com")
26
26
  client.transactional_emails.send(
27
27
  email: "john@example.com",
@@ -1,7 +1,8 @@
1
1
  module LoopsRails
2
- class TestApiKey < ApiResource
2
+ class ApiKey < ApiResource
3
3
  def test
4
4
  response = @conn.get('api-key')
5
+
5
6
  parse_response(response)
6
7
  end
7
8
  end
@@ -24,9 +24,11 @@ module LoopsRails
24
24
  raise ArgumentError, "Either email or user_id must be provided" if email.nil? && user_id.nil?
25
25
 
26
26
  params = { email: email, userId: user_id }.compact
27
+
27
28
  response = @conn.get("contacts/find") do |req|
28
29
  req.params = params
29
30
  end
31
+
30
32
  parse_response(response)
31
33
  end
32
34
 
@@ -0,0 +1,9 @@
1
+ module LoopsRails
2
+ class CustomFields < ApiResource
3
+ def list
4
+ response = @conn.get("contacts/customFields")
5
+
6
+ parse_response(response)
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,22 @@
1
+ module LoopsRails
2
+ class Events < ApiResource
3
+ def send(email: nil, user_id: nil, event_name:, event_properties: {}, mailing_lists: {}, contact_properties: {})
4
+ raise ArgumentError, "Either email or user_id must be provided" if email.nil? && user_id.nil?
5
+
6
+ payload = {
7
+ email: email,
8
+ userId: user_id,
9
+ eventName: event_name,
10
+ eventProperties: event_properties,
11
+ mailingLists: mailing_lists,
12
+ contactProperties: contact_properties
13
+ }.compact.to_json
14
+
15
+ response = @conn.post('events/send') do |req|
16
+ req.body = payload
17
+ end
18
+
19
+ parse_response(response)
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,9 @@
1
+ module LoopsRails
2
+ class Lists < ApiResource
3
+ def list
4
+ response = @conn.get("lists")
5
+
6
+ parse_response(response)
7
+ end
8
+ end
9
+ end
@@ -1,14 +1,17 @@
1
1
  module LoopsRails
2
2
  class TransactionalEmails < ApiResource
3
3
  def send(email:, transactional_id:, data_variables: {}, attachments: [])
4
+ payload = {
5
+ email: email,
6
+ transactionalId: transactional_id,
7
+ dataVariables: data_variables,
8
+ attachments: attachments
9
+ }.compact.to_json
10
+
4
11
  response = @conn.post('transactional') do |req|
5
- req.body = {
6
- email: email,
7
- transactionalId: transactional_id,
8
- dataVariables: data_variables,
9
- attachments: attachments
10
- }.to_json
12
+ req.body = payload
11
13
  end
14
+
12
15
  parse_response(response)
13
16
  end
14
17
  end
@@ -12,14 +12,26 @@ module LoopsRails
12
12
  end
13
13
  end
14
14
 
15
- def test_api_key
16
- TestApiKey.new(@conn).test
15
+ def api_key
16
+ @api_key_endpoint ||= ApiKey.new(@conn)
17
17
  end
18
18
 
19
19
  def contacts
20
20
  @contacts ||= Contacts.new(@conn)
21
21
  end
22
22
 
23
+ def custom_fields
24
+ @custom_fields ||= CustomFields.new(@conn)
25
+ end
26
+
27
+ def lists
28
+ @lists ||= Lists.new(@conn)
29
+ end
30
+
31
+ def events
32
+ @events ||= Events.new(@conn)
33
+ end
34
+
23
35
  def transactional_emails
24
36
  @transactional_emails ||= TransactionalEmails.new(@conn)
25
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LoopsRails
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/loops_rails.rb CHANGED
@@ -6,7 +6,10 @@ require_relative "loops_rails/version"
6
6
  require_relative "loops_rails/client"
7
7
  require_relative "loops_rails/configuration"
8
8
  require_relative "loops_rails/client/api_resource"
9
- require_relative "loops_rails/client/test_api_key"
9
+ require_relative "loops_rails/client/custom_fields"
10
+ require_relative "loops_rails/client/events"
11
+ require_relative "loops_rails/client/lists"
12
+ require_relative "loops_rails/client/api_key"
10
13
  require_relative "loops_rails/client/contacts"
11
14
  require_relative "loops_rails/client/transactional_emails"
12
15
 
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loops_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Friis
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-07-10 00:00:00.000000000 Z
11
+ date: 2024-07-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -37,13 +37,17 @@ files:
37
37
  - Rakefile
38
38
  - lib/loops_rails.rb
39
39
  - lib/loops_rails/client.rb
40
+ - lib/loops_rails/client/api_key.rb
40
41
  - lib/loops_rails/client/api_resource.rb
41
42
  - lib/loops_rails/client/contacts.rb
42
- - lib/loops_rails/client/test_api_key.rb
43
+ - lib/loops_rails/client/custom_fields.rb
44
+ - lib/loops_rails/client/events.rb
45
+ - lib/loops_rails/client/lists.rb
43
46
  - lib/loops_rails/client/transactional_emails.rb
44
47
  - lib/loops_rails/configuration.rb
45
48
  - lib/loops_rails/version.rb
46
49
  - loops_rails-0.1.0.gem
50
+ - loops_rails-0.1.1.gem
47
51
  - loops_rails.gemspec
48
52
  - sig/loops_rails.rbs
49
53
  homepage: https://github.com/danielfriis/loops_rails