loops_rails 0.1.0 → 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: be0f5a041a6bc29955f19f4f9f81ecb670233e2a8776772d8e894070eab38a6a
4
- data.tar.gz: a6b3358e15f6b3dcf6db27999205c7ee6066ed08e9034840c20db4d51e106430
3
+ metadata.gz: f79d4af123b8a77eaf6ad7533bcab6d19e6178a5fbba0f21e73066db1009f50b
4
+ data.tar.gz: ff8d1fe3eb16b606a0914406672f30821d1a169f747ea2d6db1966df0ad99718
5
5
  SHA512:
6
- metadata.gz: 87d31d93f2c08cd5305e533b18b5b0c295f40cdf478194e308189e87ea2d45964d41c21a93f75aed853a12e1f32d8c65a83539f1aa56c157b92cb533cc21c51f
7
- data.tar.gz: 005f4aa20127104f6b35070b205a8ace43de454e225e4cbe86117b675abc4db6fcdd9b390fef0447e34cfc2c273d12ef0d3917b28e8fb472469ac7e0e4089c0f
6
+ metadata.gz: f7273b8e7c1bc6a8b4bf4e9c5e0b6be1eea2d32107c3d8f55f366b69e6f5b8feb3ba01586f0c115f27ae03717efb96b758d105b10af4c5d2b37c6d2679b8f692
7
+ data.tar.gz: a3eeab9a2f5ba91e4a86f6a678ea080a9905eb7cbb00009b9dab867a654c1d0e490031ca1804577641fc049cf6c06f46eae806c04306a1b482a42102848e2c39
data/README.md CHANGED
@@ -1,24 +1,33 @@
1
1
  # LoopsRails
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
4
-
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/loops_rails`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ LoopsRails is a Rails client for the [Loops](https://loops.so) API.
6
4
 
7
5
  ## Installation
8
6
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
10
-
11
7
  Install the gem and add to the application's Gemfile by executing:
12
8
 
13
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
9
+ $ bundle add loops_rails
14
10
 
15
11
  If bundler is not being used to manage dependencies, install the gem by executing:
16
12
 
17
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
13
+ $ gem install loops_rails
18
14
 
19
15
  ## Usage
20
16
 
21
- TODO: Write usage instructions here
17
+ 1. Sign up for a [Loops](https://loops.so) account.
18
+ 2. Create an API key in your account settings.
19
+ 3. Use the API key to authenticate requests to the API.
20
+
21
+ ```ruby
22
+ client = LoopsRails::Client.new(api_key: "your_api_key")
23
+
24
+ client.test_api_key
25
+ client.contacts.create(email: "john@example.com")
26
+ client.transactional_emails.send(
27
+ email: "john@example.com",
28
+ transactional_id: "your_transactional_id"
29
+ )
30
+ ```
22
31
 
23
32
  ## Development
24
33
 
@@ -26,9 +35,18 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
26
35
 
27
36
  To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
37
 
38
+ ## TODO
39
+
40
+ - [X] Add support for the `/api-key` endpoint
41
+ - [X] Add support for the `/contacts` endpoint
42
+ - [X] Add support for the `/transactional` endpoint
43
+ - [ ] Add support for the `/lists` endpoint
44
+ - [ ] Add support for the `/events` endpoint
45
+ - [ ] Add support for the `/customFields` endpoint
46
+
29
47
  ## Contributing
30
48
 
31
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/loops_rails.
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/danielfriis/loops_rails.
32
50
 
33
51
  ## License
34
52
 
@@ -1,7 +1,8 @@
1
1
  module LoopsRails
2
2
  class ApiKey < ApiResource
3
- def test_api_key
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
@@ -13,13 +13,25 @@ module LoopsRails
13
13
  end
14
14
 
15
15
  def api_key
16
- @api_key ||= ApiKey.new(@conn)
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.0"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/loops_rails.rb CHANGED
@@ -6,11 +6,13 @@ 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/custom_fields"
10
+ require_relative "loops_rails/client/events"
11
+ require_relative "loops_rails/client/lists"
9
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
 
13
16
  module LoopsRails
14
17
  class Error < StandardError; end
15
-
16
18
  end
Binary file
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.0
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
@@ -40,9 +40,14 @@ files:
40
40
  - lib/loops_rails/client/api_key.rb
41
41
  - lib/loops_rails/client/api_resource.rb
42
42
  - lib/loops_rails/client/contacts.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
49
+ - loops_rails-0.1.0.gem
50
+ - loops_rails-0.1.1.gem
46
51
  - loops_rails.gemspec
47
52
  - sig/loops_rails.rbs
48
53
  homepage: https://github.com/danielfriis/loops_rails