viral_loops 0.0.1 → 0.0.3

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: 340e9ec452bf69c95b6eae53845626b9088bfc29feb42edbd6d10a6ad03ab977
4
- data.tar.gz: 39821c7e94855163befb0f8327186cf61edf8bfb169c85220379c76ca1ce288e
3
+ metadata.gz: 93a9284729f3b539998254dc89a2128b316b41b2307c8ebee371ca0e6ec39a13
4
+ data.tar.gz: 8da2f0fad50f918ab5a3eab0a62a0cc88a5fd67ac03bb68fb1faf72c8e54d1f7
5
5
  SHA512:
6
- metadata.gz: 1b6a1b6e7d456fae50de705337d6fd298e1e3930c53483946250800cc57ed2df8ead977251ef04b32b0c0a09b9a7dc2e40612d5e0ad09f0112f5aab1ce685bd2
7
- data.tar.gz: 6cf7bc2f41ca5f826c15662043c985e29027c8b320f0c0253bfd1c744944dd38939954d0435bb1b778af9f90a1bd8dec9a70a807e4c82f79a2e44a317ae925e6
6
+ metadata.gz: a5a960507cae94ba27f1554f10cfc78767025567d6427de900dc2925cbbd4431a8d323e6d4f9ea8d083e195fa3d3fd942e0731da345f6c2662113d551bd6043e
7
+ data.tar.gz: 6268c8da54f840b05859d4a870d5a20c11b0bdbb600cd167ee90b58978e7ff31be1e34daa5f6a52177909624a22cab0c356e1438414407b7cf90e875fa5ad338
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'faraday'
2
4
  require 'json'
3
5
  require 'rack/utils'
@@ -7,7 +9,7 @@ module ViralLoops
7
9
  API_VERSION = 'v3'
8
10
 
9
11
  def initialize(secret_token: ViralLoops.configuration.secret_token)
10
- @connection ||= Faraday.new(url: ViralLoops.configuration.api_base) do |faraday|
12
+ @connection = Faraday.new(url: ViralLoops.configuration.api_base) do |faraday|
11
13
  faraday.headers['Content-Type'] = 'application/json'
12
14
  faraday.headers['apiToken'] = secret_token
13
15
  faraday.adapter Faraday.default_adapter
@@ -33,12 +35,12 @@ module ViralLoops
33
35
  case response.status
34
36
  when 200..299 then JSON.parse(response.body)
35
37
  else
36
- status_symbol = Rack::Utils::SYMBOL_TO_STATUS_CODE.key(response.status)
37
- default_message = Rack::Utils::HTTP_STATUS_CODES[response.status] || "API error"
38
+ Rack::Utils::SYMBOL_TO_STATUS_CODE.key(response.status)
39
+ default_message = Rack::Utils::HTTP_STATUS_CODES[response.status] || 'API error'
38
40
 
39
41
  raise ViralLoops::ApiError.new(
40
42
  body: response.body.to_s.strip.empty? ? default_message : response.body,
41
- status: response.status,
43
+ status: response.status
42
44
  )
43
45
  end
44
46
  end
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ViralLoops
2
4
  class Configuration
3
5
  attr_accessor :api_base, :campaign_id, :debug, :secret_token
4
6
 
5
7
  def initialize
6
- @api_base = "https://app.viral-loops.com"
8
+ @api_base = 'https://app.viral-loops.com'
7
9
  end
8
10
  end
9
11
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module ViralLoops
4
+ module Models
5
+ class Participant
6
+ class Convert
7
+ attr_accessor :processing
8
+
9
+ def initialize(processing:)
10
+ @processing = processing
11
+ end
12
+
13
+ def processing? = !!processing
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,12 +1,20 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ViralLoops
2
4
  module Resources
3
5
  class Participants < Client
4
- BASE_PATH = "campaign/participant"
6
+ BASE_PATH = 'campaign/participant'
5
7
 
6
8
  def create(params)
7
9
  response = post(BASE_PATH, params)
8
10
 
9
- Models::Participant.new(referral_code: response["referralCode"], new: response["isNew"])
11
+ Models::Participant.new(referral_code: response['referralCode'], new: response['isNew'])
12
+ end
13
+
14
+ def convert(params)
15
+ response = post("#{BASE_PATH}/convert", params)
16
+
17
+ Models::Participant::Convert.new(processing: response['status'])
10
18
  end
11
19
  end
12
20
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ViralLoops
2
- VERSION = '0.0.1'
4
+ VERSION = '0.0.3'
3
5
  end
data/lib/viral_loops.rb CHANGED
@@ -1,13 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "viral_loops/client"
4
- require "viral_loops/configuration"
5
- require "viral_loops/resources"
6
- require "viral_loops/models"
7
- require "viral_loops/version"
3
+ require 'viral_loops/client'
4
+ require 'viral_loops/configuration'
5
+ require 'viral_loops/resources'
6
+ require 'viral_loops/models'
7
+ require 'viral_loops/version'
8
8
 
9
- require "viral_loops/resources/participants"
10
- require "viral_loops/models/participant"
9
+ require 'viral_loops/resources/participants'
10
+ require 'viral_loops/models/participant'
11
+ require 'viral_loops/models/participant/convert'
11
12
 
12
13
  module ViralLoops
13
14
  class << self
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: viral_loops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cairo Noleto
@@ -37,34 +37,6 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '3.2'
40
- - !ruby/object:Gem::Dependency
41
- name: rspec
42
- requirement: !ruby/object:Gem::Requirement
43
- requirements:
44
- - - "~>"
45
- - !ruby/object:Gem::Version
46
- version: '3.13'
47
- type: :development
48
- prerelease: false
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - "~>"
52
- - !ruby/object:Gem::Version
53
- version: '3.13'
54
- - !ruby/object:Gem::Dependency
55
- name: webmock
56
- requirement: !ruby/object:Gem::Requirement
57
- requirements:
58
- - - "~>"
59
- - !ruby/object:Gem::Version
60
- version: '3.25'
61
- type: :development
62
- prerelease: false
63
- version_requirements: !ruby/object:Gem::Requirement
64
- requirements:
65
- - - "~>"
66
- - !ruby/object:Gem::Version
67
- version: '3.25'
68
40
  email:
69
41
  - hey@caironoleto.dev
70
42
  executables: []
@@ -76,13 +48,15 @@ files:
76
48
  - lib/viral_loops/configuration.rb
77
49
  - lib/viral_loops/models.rb
78
50
  - lib/viral_loops/models/participant.rb
51
+ - lib/viral_loops/models/participant/convert.rb
79
52
  - lib/viral_loops/resources.rb
80
53
  - lib/viral_loops/resources/participants.rb
81
54
  - lib/viral_loops/version.rb
82
55
  homepage: https://github.com/caironoleto/viral-loops
83
56
  licenses:
84
57
  - MIT
85
- metadata: {}
58
+ metadata:
59
+ rubygems_mfa_required: 'true'
86
60
  rdoc_options: []
87
61
  require_paths:
88
62
  - lib