Skip to content

Commit

Permalink
Minor: Refactor API urls.
Browse files Browse the repository at this point in the history
  • Loading branch information
jylamont committed Apr 17, 2024
1 parent ea3dfee commit 5cad5d2
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 17 deletions.
11 changes: 8 additions & 3 deletions lib/vero/api/base_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ class BaseAPI
attr_reader :options

def self.perform(domain, options)
caller = new(domain, options)
caller.perform
new(domain, options).perform
end

def initialize(domain, options)
Expand Down Expand Up @@ -42,7 +41,13 @@ def proxy.<<(message)
end
end

def url; end
def url
"#{@domain}/api/v2/#{api_url}"
end

def api_url
raise NotImplementedError
end

def validate!
raise "#{self.class.name}#validate! should be overridden"
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/events/track_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Events
class TrackAPI < BaseAPI
def url
"#{@domain}/api/v2/events/track.json"
def api_url
'events/track.json'
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/edit_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Users
class EditAPI < BaseAPI
def url
"#{@domain}/api/v2/users/edit.json"
def api_url
'users/edit.json'
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/edit_tags_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Users
class EditTagsAPI < BaseAPI
def url
"#{@domain}/api/v2/users/tags/edit.json"
def api_url
'users/tags/edit.json'
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/reidentify_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Users
class ReidentifyAPI < BaseAPI
def url
"#{@domain}/api/v2/users/reidentify.json"
def api_url
'users/reidentify.json'
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/resubscribe_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Users
class ResubscribeAPI < BaseAPI
def url
"#{@domain}/api/v2/users/resubscribe.json"
def api_url
'users/resubscribe.json'
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/track_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Users
class TrackAPI < BaseAPI
def url
"#{@domain}/api/v2/users/track.json"
def api_url
'users/track.json'
end

def request
Expand Down
4 changes: 2 additions & 2 deletions lib/vero/api/users/unsubscribe_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ module Api
module Workers
module Users
class UnsubscribeAPI < BaseAPI
def url
"#{@domain}/api/v2/users/unsubscribe.json"
def api_url
'users/unsubscribe.json'
end

def request
Expand Down

0 comments on commit 5cad5d2

Please sign in to comment.