Class: Gosquared::Account
- Inherits:
-
Object
- Object
- Gosquared::Account
- Defined in:
- lib/gosquared/account.rb
Constant Summary collapse
- BASEURL =
'https://api.gosquared.com/account/v1/'.freeze
- DIMENSIONS =
%w[blocked feeds reportPreferences sharedUsers sites taggedVisitors triggerTypes webhooks].freeze
- DIMENSION_FILTER =
%w[token webhookID visitorID triggerType].freeze
- @@filters =
{ presenter: @presenter, ip: @ip, url: @url, email: @email }
Instance Method Summary collapse
- #bots ⇒ Object
- #build_url(ips = @ips) ⇒ Object
- #delete ⇒ Object
- #fetch ⇒ Object
-
#initialize(api_key, site_token, client = Gosquared::Client.new) ⇒ Account
constructor
A new instance of Account.
- #ips ⇒ Object
- #post ⇒ Object
- #visitors(id = '') ⇒ Object
Constructor Details
#initialize(api_key, site_token, client = Gosquared::Client.new) ⇒ Account
Returns a new instance of Account.
10 11 12 13 14 15 16 17 18 |
# File 'lib/gosquared/account.rb', line 10 def initialize(api_key, site_token, client = Gosquared::Client.new) @site_token = site_token @api_key = api_key @client = client @bots = '' @ips = '' @visitor = '' @dimension_filter = '' end |
Instance Method Details
#bots ⇒ Object
60 61 62 |
# File 'lib/gosquared/account.rb', line 60 def bots @bots = '/bots' end |
#build_url(ips = @ips) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/gosquared/account.rb', line 74 def build_url(ips = @ips) array = [''] @url = BASEURL + @dimension + @dimension_filter + @visitor + @bots + ips + "?api_key=#{@api_key}" + "&site_token=#{@site_token}" @@filters.each { |key, value| array << "#{key}=#{value}" if value } parameters = array.join('&') @url = @url.concat(parameters) end |
#delete ⇒ Object
54 55 56 57 58 |
# File 'lib/gosquared/account.rb', line 54 def delete response = @client.post(build_url, @data) @@filters.each { |key, _value| @@filters[key] = nil } if response.code === '200' response end |
#fetch ⇒ Object
42 43 44 45 46 |
# File 'lib/gosquared/account.rb', line 42 def fetch data = @client.get(build_url) @@filters.each { |key, _value| @@filters[key] = nil } if data data end |
#ips ⇒ Object
64 65 66 67 |
# File 'lib/gosquared/account.rb', line 64 def ips @ips = '/ips' self end |
#post ⇒ Object
48 49 50 51 52 |
# File 'lib/gosquared/account.rb', line 48 def post response = @client.post(build_url, @data) @@filters.each { |key, _value| @@filters[key] = nil } if response.code === '200' response end |
#visitors(id = '') ⇒ Object
69 70 71 72 |
# File 'lib/gosquared/account.rb', line 69 def visitors(id = '') @visitor = "/visitors/#{id}" self end |