-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
564 additions
and
727 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
require "base64" | ||
require "json" | ||
require "rest-client" | ||
|
||
module Vero | ||
autoload :Config, "vero/config" | ||
autoload :App, "vero/app" | ||
autoload :Context, "vero/context" | ||
autoload :APIContext, "vero/context/api" | ||
autoload :Trackable, "vero/trackable" | ||
autoload :DSL, "vero/dsl" | ||
autoload :Sender, "vero/sender" | ||
autoload :SuckerPunchWorker, "vero/senders/sucker_punch" | ||
autoload :ResqueWorker, "vero/senders/resque" | ||
autoload :SidekiqWorker, "vero/senders/sidekiq" | ||
|
||
module Api | ||
module Workers | ||
autoload :BaseAPI, "vero/api/base_api" | ||
|
||
module Events | ||
autoload :TrackAPI, "vero/api/events/track_api" | ||
end | ||
|
||
module Users | ||
autoload :TrackAPI, "vero/api/users/track_api" | ||
autoload :EditAPI, "vero/api/users/edit_api" | ||
autoload :EditTagsAPI, "vero/api/users/edit_tags_api" | ||
autoload :UnsubscribeAPI, "vero/api/users/unsubscribe_api" | ||
autoload :ResubscribeAPI, "vero/api/users/resubscribe_api" | ||
autoload :ReidentifyAPI, "vero/api/users/reidentify_api" | ||
autoload :DeleteAPI, "vero/api/users/delete_api" | ||
end | ||
end | ||
|
||
autoload :Events, "vero/api" | ||
autoload :Users, "vero/api" | ||
end | ||
|
||
module Senders | ||
autoload :Base, "vero/senders/base" | ||
autoload :DelayedJob, "vero/senders/delayed_job" | ||
autoload :Resque, "vero/senders/resque" | ||
autoload :Sidekiq, "vero/senders/sidekiq" | ||
autoload :Invalid, "vero/senders/invalid" | ||
autoload :SuckerPunch, "vero/senders/sucker_punch" | ||
end | ||
|
||
module Utility | ||
autoload :Logger, "vero/utility/logger" | ||
end | ||
end | ||
require "zeitwerk" | ||
|
||
loader = Zeitwerk::Loader.for_gem | ||
loader.inflector.inflect( | ||
"api_context" => "APIContext", | ||
"dsl" => "DSL", | ||
"base_api" => "BaseAPI", | ||
"track_api" => "TrackAPI", | ||
"delete_api" => "DeleteAPI", | ||
"edit_api" => "EditAPI", | ||
"edit_tags_api" => "EditTagsAPI", | ||
"reidentify_api" => "ReidentifyAPI", | ||
"resubscribe_api" => "ResubscribeAPI", | ||
"unsubscribe_api" => "UnsubscribeAPI" | ||
) | ||
loader.ignore("#{__dir__}/generators") | ||
loader.setup | ||
|
||
require "vero/railtie" if defined?(Rails) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class Vero::Api::Base | ||
attr_accessor :context | ||
|
||
def initialize(context) | ||
self.context = context | ||
end | ||
|
||
def config | ||
context.config | ||
end | ||
|
||
def run_api(api_klass, options) | ||
return if config.disabled | ||
|
||
validate_configured! | ||
options.merge!(config.request_params) | ||
Vero::Sender.send(api_klass, config.async, config.domain, options) | ||
end | ||
|
||
protected | ||
|
||
def validate_configured! | ||
raise "You must configure the 'vero' gem. Visit https://github.com/getvero/vero for more details." unless config.configured? | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# frozen_string_literal: true | ||
|
||
class Vero::Api::Events < Vero::Api::Base | ||
def self.track!(options, context = Vero::App.default_context) | ||
new(context).track!(options) | ||
end | ||
|
||
def track!(options) | ||
run_api(Vero::Api::Workers::Events::TrackAPI, options) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
class Vero::Api::Users < Vero::Api::Base | ||
def self.track!(options, context = Vero::App.default_context) | ||
new(context).track!(options) | ||
end | ||
|
||
def self.edit_user!(options, context = Vero::App.default_context) | ||
new(context).edit_user!(options) | ||
end | ||
|
||
def self.edit_user_tags!(options, context = Vero::App.default_context) | ||
new(context).edit_user_tags!(options) | ||
end | ||
|
||
def self.reidentify!(options, context = Vero::App.default_context) | ||
new(context).reidentify!(options) | ||
end | ||
|
||
def self.unsubscribe!(options, context = Vero::App.default_context) | ||
new(context).unsubscribe!(options) | ||
end | ||
|
||
def self.resubscribe!(options, context = Vero::App.default_context) | ||
new(context).resubscribe!(options) | ||
end | ||
|
||
def self.delete!(options, context = Vero::App.default_context) | ||
new(context).delete!(options) | ||
end | ||
|
||
def track!(options) | ||
run_api(Vero::Api::Workers::Users::TrackAPI, options) | ||
end | ||
|
||
def edit_user!(options) | ||
run_api(Vero::Api::Workers::Users::EditAPI, options) | ||
end | ||
|
||
def edit_user_tags!(options) | ||
run_api(Vero::Api::Workers::Users::EditTagsAPI, options) | ||
end | ||
|
||
def unsubscribe!(options) | ||
run_api(Vero::Api::Workers::Users::UnsubscribeAPI, options) | ||
end | ||
|
||
def resubscribe!(options) | ||
run_api(Vero::Api::Workers::Users::ResubscribeAPI, options) | ||
end | ||
|
||
def reidentify!(options) | ||
run_api(Vero::Api::Workers::Users::ReidentifyAPI, options) | ||
end | ||
|
||
def delete!(options) | ||
run_api(Vero::Api::Workers::Users::DeleteAPI, options) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.