clerk-rails 0.1.14 → 0.1.15

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: 321e4434734804eaee62e665f635a2d09e8e0c45162509de6f0d8c8586bc2f0b
4
- data.tar.gz: abad35a9178f4c8ad9fa6aa6efbfd85da069b7dfaa53bea825742564f44bfdcc
3
+ metadata.gz: a18baef5e78acc93663b1bda90b67694d876ef20d0143f0009df731f4db30dc2
4
+ data.tar.gz: bf69b8fcd8f01e6cb46804c4fab6b65542e81f8538440b606e856d69d5c813a7
5
5
  SHA512:
6
- metadata.gz: 07a87037aed001bbb3e755a8454054487fefeba60590821d6cccb2a3594ce54f6a95a0340003702d1e4db30142b799adb6109ad62a5857d86a1aa25afbd1ee69
7
- data.tar.gz: ef0d555e37854fed946fa2cfe3059ff4d51758785cd8077d31d745f0193970d99792e984548d078168184c7a1e1c167a3615f30099130611090c92bd62d0f264
6
+ metadata.gz: 6f36a9b5d1585c7b5f0c8edaa6fcb551127a6398193e071794dd0c9d70d14fcc3f262997f473ab098ea68df1f58a3bc59ad27e4507566ce4e6cbb309aa8a3008
7
+ data.tar.gz: 73f67024d28ab7b6bb36fc529a9f9631b3a200107f24d3818b8b455b5a35151b02a74d37a02d10b5c0ad53dfea9e8e77c67f06e2efc631f28e42df662ebe8d39
@@ -6,6 +6,26 @@ module Clerk
6
6
  has_many :roles, class_name: "Clerk::Role"
7
7
  has_many :payment_methods, class_name: "Clerk::PaymentMethod"
8
8
  has_many :subscriptions, class_name: "Clerk::Subscription"
9
+ has_many :emails, class_name: "Clerk::Email"
10
+
11
+ def email(
12
+ from_email_name:,
13
+ email_template_token: nil,
14
+ replacements: nil,
15
+ subject: nil,
16
+ body: nil
17
+ )
18
+ Clerk.email(
19
+ account: self,
20
+ from_email_name: from_email_name,
21
+ email_template_token: email_template_token,
22
+ replacements: replacements,
23
+ subject: subject,
24
+ body: body
25
+ )
26
+ end
27
+
28
+
9
29
  def add_clerk_role(role_type_symbol, instance = nil)
10
30
  json = { }
11
31
  json[:name] = role_type_symbol.to_s
@@ -16,6 +16,8 @@ module Clerk
16
16
  # were overriding all the methods that need transactions
17
17
  # these interfere with pgbouncer. just yield the block
18
18
  yield
19
+ rescue ActiveRecord::Rollback
20
+ # rollbacks are silently swallowed
19
21
  end
20
22
  end
21
23
  end
@@ -0,0 +1,17 @@
1
+ module Clerk
2
+ class Email < Clerk::ApplicationRecord
3
+ self.table_name = self.clerk_table_name("emails")
4
+ self.primary_key = 'id'
5
+
6
+ def self.clerk_persistence_path
7
+ "/api/emails"
8
+ end
9
+
10
+ def self.clerk_persistence_api
11
+ @@conn ||= Clerk::Api::Connection.new(
12
+ (ENV["CLERK_API_PATH"] || "https://accounts.clerk.dev"),
13
+ Clerk.key_secret
14
+ )
15
+ end
16
+ end
17
+ end
@@ -65,11 +65,32 @@ module Clerk
65
65
  message << cipher.final
66
66
  message
67
67
  end
68
+
69
+ def email(
70
+ account: nil,
71
+ to_email_address: nil,
72
+ from_email_name: nil,
73
+ email_template_token: nil,
74
+ replacements: nil,
75
+ subject: nil,
76
+ body: nil
77
+ )
78
+ email = Clerk::Email.create(
79
+ account_id: account&.id,
80
+ to_email_address: to_email_address,
81
+ from_email_name: from_email_name,
82
+ email_template_token: email_template_token,
83
+ replacements: replacements.nil? ? nil : replacements.to_json,
84
+ subject: subject,
85
+ body: body
86
+ )
87
+ end
68
88
  end
69
89
 
70
90
  class Configuration
71
91
  attr_accessor :accounts_host,
72
92
  :app_host,
93
+ :host,
73
94
  :cipher_key,
74
95
  :database_url,
75
96
  :email_address_verification,
@@ -16,6 +16,7 @@ module Clerk
16
16
  begin
17
17
  config_data = Clerk.api.get('/api/environment').data
18
18
  Clerk.configure do |config|
19
+ config.host = config_data[:HOST]
19
20
  config.accounts_host = config_data[:ACCOUNTS_HOST]
20
21
  config.app_host = config_data[:APP_HOST]
21
22
  config.cipher_key = config_data[:CIPHER_KEY]
@@ -23,7 +24,7 @@ module Clerk
23
24
  config.email_address_verification = config_data[:EMAIL_ADDRESS_VERIFICATION]
24
25
  config.ngrok_authtoken = config_data[:NGROK_AUTHTOKEN]
25
26
  config.tunnel_cert = config_data[:TUNNEL_CERT]
26
- config.tunnel_key = config_data[:TUNNEL_KEY]
27
+ config.tunnel_key = config_data[:TUNNEL_KEY]
27
28
  end
28
29
  rescue => e
29
30
  raise "Clerk could not be loaded. #{e} #{config_data}"
@@ -1,3 +1,3 @@
1
1
  module Clerk
2
- VERSION = '0.1.14'
2
+ VERSION = '0.1.15'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clerk-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.14
4
+ version: 0.1.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Clerk
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-17 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -156,6 +156,7 @@ files:
156
156
  - app/models/clerk/application_record.rb
157
157
  - app/models/clerk/charge.rb
158
158
  - app/models/clerk/client.rb
159
+ - app/models/clerk/email.rb
159
160
  - app/models/clerk/payment_method.rb
160
161
  - app/models/clerk/plan.rb
161
162
  - app/models/clerk/role.rb