rsqoot 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -11,7 +11,9 @@ module RSqoot
11
11
  @rsqoot_categories = get('categories', options, SqootCategory)
12
12
  @rsqoot_categories = @rsqoot_categories.categories.map(&:category) if @rsqoot_categories
13
13
  end
14
- query.present? ? query_categories(query) : @rsqoot_categories
14
+ result = query.present? ? query_categories(query) : @rsqoot_categories
15
+ logger({uri: sqoot_query_uri, records: result, type: 'categories', opts: options})
16
+ result
15
17
  end
16
18
 
17
19
  end
data/lib/rsqoot/click.rb CHANGED
@@ -13,6 +13,7 @@ module RSqoot
13
13
  @rsqoot_clicks = get('clicks', options, SqootClick)
14
14
  @rsqoot_clicks = @rsqoot_clicks.clicks if @rsqoot_clicks
15
15
  end
16
+ logger({uri: sqoot_query_uri, records: @rsqoot_clicks, type: 'clicks', opts: options})
16
17
  @rsqoot_clicks
17
18
  end
18
19
 
data/lib/rsqoot/client.rb CHANGED
@@ -6,6 +6,7 @@ require "rsqoot/commission"
6
6
  require "rsqoot/click"
7
7
  require "rsqoot/deal"
8
8
  require "rsqoot/request"
9
+ require "rsqoot/logger"
9
10
 
10
11
  module RSqoot
11
12
  class Client
@@ -17,8 +18,9 @@ module RSqoot
17
18
  include Merchant
18
19
  include Provider
19
20
  include Request
21
+ include Logger
20
22
 
21
- attr_reader :public_api_key, :private_api_key, :base_api_url, :authentication_method, :read_timeout, :query_options, :expired_in
23
+ attr_reader :public_api_key, :private_api_key, :base_api_url, :authentication_method, :read_timeout, :query_options, :expired_in, :sqoot_query_uri
22
24
 
23
25
  def initialize(options={})
24
26
  @public_api_key = options[:public_api_key] || RSqoot.public_api_key
@@ -13,6 +13,7 @@ module RSqoot
13
13
  @rsqoot_commissions = get('commissions', options, SqootCommission)
14
14
  @rsqoot_commissions = @rsqoot_commissions.commissions if @rsqoot_commissions
15
15
  end
16
+ logger({uri: sqoot_query_uri, records: @rsqoot_commissions, type: 'commissions', opts: options})
16
17
  @rsqoot_commissions
17
18
  end
18
19
 
data/lib/rsqoot/deal.rb CHANGED
@@ -16,6 +16,7 @@ module RSqoot
16
16
  @rsqoot_deals = @rsqoot_deals.deals.map(&:deal) if !@rsqoot_deals.empty?
17
17
  @rsqoot_deals = uniq_deals(@rsqoot_deals) if uniq
18
18
  end
19
+ logger({uri: sqoot_query_uri, records: @rsqoot_deals, type: 'deals', opts: options})
19
20
  @rsqoot_deals
20
21
  end
21
22
 
@@ -27,6 +28,7 @@ module RSqoot
27
28
  @rsqoot_deal = get("deals/#{id}", options, SqootDeal)
28
29
  @rsqoot_deal = @rsqoot_deal.deal if @rsqoot_deal
29
30
  end
31
+ logger({uri: sqoot_query_uri, records: [@rsqoot_deal], type: 'deal', opts: options})
30
32
  @rsqoot_deal
31
33
  end
32
34
 
@@ -0,0 +1,36 @@
1
+ module RSqoot
2
+ module Logger
3
+ def logger(options = {records: [], uri: '', error: '', type: '', opts: {}})
4
+ records = options[:records].nil? ? [] : options[:records]
5
+ error = options[:error]
6
+ uri = options[:uri]
7
+ type = options[:type]
8
+ opts = options[:opts]
9
+
10
+ if defined? Rails
11
+ if error.present?
12
+ Rails.logger.info ">>> Error: #{error}"
13
+ else
14
+ Rails.logger.info ">>> Querying Sqoot API V2: #{type}"
15
+ Rails.logger.info ">>> #{uri}"
16
+ Rails.logger.info ">>> #{opts}"
17
+ Rails.logger.info ">>> Hit #{records.count} records"
18
+ end
19
+ else
20
+ if error.present?
21
+ puts ">>> Error: #{error}"
22
+ puts ""
23
+ else
24
+ puts ">>> Querying Sqoot API V2: #{type}"
25
+ puts ""
26
+ puts ">>> #{uri}"
27
+ puts ""
28
+ puts ">>> #{opts}"
29
+ puts ""
30
+ puts ">>> Hit #{records.count} records"
31
+ puts ""
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -12,6 +12,7 @@ module RSqoot
12
12
  @rsqoot_merchant = get("merchants/#{id}", options, SqootMerchant)
13
13
  @rsqoot_merchant = @rsqoot_merchant.merchant if @rsqoot_merchant
14
14
  end
15
+ logger({uri: sqoot_query_uri, records: [@rsqoot_merchant], type: 'merchants', opts: options})
15
16
  @rsqoot_merchant
16
17
  end
17
18
 
@@ -10,7 +10,9 @@ module RSqoot
10
10
  @rsqoot_providers = get('providers', options, SqootProvider)
11
11
  @rsqoot_providers = @rsqoot_providers.providers.map(&:provider) if @rsqoot_providers
12
12
  end
13
- query.present? ? query_providers(query) : @rsqoot_providers
13
+ result = query.present? ? query_providers(query) : @rsqoot_providers
14
+ logger({uri: sqoot_query_uri, records: result, type: 'providers', opts: options})
15
+ result
14
16
  end
15
17
 
16
18
  end
@@ -11,7 +11,8 @@ module RSqoot
11
11
  result = wrapper.new json
12
12
  @query_options = result.query
13
13
  result
14
- rescue
14
+ rescue => e
15
+ logger({error: e})
15
16
  nil
16
17
  end
17
18
  end
@@ -30,6 +31,7 @@ module RSqoot
30
31
  query = query + "&api_key=#{api_key(endpoint)}"
31
32
  end
32
33
  uri.query = query
34
+ @sqoot_query_uri = uri
33
35
  [uri, headers]
34
36
  end
35
37
 
@@ -1,3 +1,3 @@
1
1
  module RSqoot
2
- VERSION = '0.5.1'
2
+ VERSION = '0.5.2'
3
3
  end
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsqoot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Felix Liu
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-11-14 00:00:00.000000000 Z
12
+ date: 2013-11-18 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: hashie
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ! '>='
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ! '>='
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: json
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ! '>='
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ! '>='
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: activesupport
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ! '>='
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ! '>='
53
60
  - !ruby/object:Gem::Version
@@ -75,6 +82,7 @@ files:
75
82
  - lib/rsqoot/commission.rb
76
83
  - lib/rsqoot/deal.rb
77
84
  - lib/rsqoot/helper.rb
85
+ - lib/rsqoot/logger.rb
78
86
  - lib/rsqoot/merchant.rb
79
87
  - lib/rsqoot/provider.rb
80
88
  - lib/rsqoot/request.rb
@@ -83,25 +91,26 @@ files:
83
91
  homepage: https://github.com/lyfeyaj/rsqoot
84
92
  licenses:
85
93
  - MIT
86
- metadata: {}
87
94
  post_install_message:
88
95
  rdoc_options: []
89
96
  require_paths:
90
97
  - lib
91
98
  required_ruby_version: !ruby/object:Gem::Requirement
99
+ none: false
92
100
  requirements:
93
101
  - - ! '>='
94
102
  - !ruby/object:Gem::Version
95
103
  version: '0'
96
104
  required_rubygems_version: !ruby/object:Gem::Requirement
105
+ none: false
97
106
  requirements:
98
107
  - - ! '>='
99
108
  - !ruby/object:Gem::Version
100
109
  version: '0'
101
110
  requirements: []
102
111
  rubyforge_project:
103
- rubygems_version: 2.1.10
112
+ rubygems_version: 1.8.26
104
113
  signing_key:
105
- specification_version: 4
114
+ specification_version: 3
106
115
  summary: Wrapper for Sqoot API V2
107
116
  test_files: []
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- N2ZkZWFlMGQ1ZDhlMWVjYzhkY2I2NzUzNzU1MGU4Yzc2YzU0ZDMwZQ==
5
- data.tar.gz: !binary |-
6
- ODYxNGQzY2VjNTM5ZTgzMDVjNDliNmQ4YjI4ODg2MjE0Mjk3NWNkOA==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- Yjk0NmU2MjdjNDY0YTM5YzMyOGY0NDcxMmE4N2ViZDAyZjUxNzNlOTg0NGEy
10
- ZWI2M2U2Mjc3ZjMwYWIxMzQ1ZTk0MjE1MWJkMzk1ZDNhMWQ2YzA5MDZmOGRk
11
- YmRmNjcyYWI5MzYwMmVlMjE0MTZkMTRlOTg2NzE2MDFmYjgwMjk=
12
- data.tar.gz: !binary |-
13
- YzRmOGM1YTMzZTc2NmI0Yjc4NjUxZmI1NWE0Nzg5OGRlNDBiYmVmYjRjOGI0
14
- YzFjNjE4NWY5NGVhODNlZTYxOGRjZjA3NDg1MjVhN2I3YjQzN2M5NmE5MTQ2
15
- YWUzZTg1YmQ5MjlkZGM1NTQ5ZTA3OTFlNDc5N2ZkYWU3ZDIwOGY=