queenbee 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f6c61965021fb19ab013c8b40d1b0b5b9000e0d5
4
- data.tar.gz: 74acc2795b99aae6f469a69da85b254f1057e6b0
3
+ metadata.gz: aa104c36396a2ceb76794c4f2a0a4f7920ce9e23
4
+ data.tar.gz: 0f1e895d2ff5f824dec9ce2d52cf2dc41621d521
5
5
  SHA512:
6
- metadata.gz: a2c17ed7d1462460b6c4c06cce5748ee1c7a2816f7749dbfc557d46a4a78118a643d6ad99f6ef103c3707208f93fcd18b6421dd1da9fe417ee3b5b9cfe9f0d5a
7
- data.tar.gz: 8189bcb8e702d427c180b7b2043ffd6a4b6276c69974e63a064f9673d24d7edbfb548cefb5f12aacb02e887f1c000f5440e5ac44f96fae97b774c3c5b1950078
6
+ metadata.gz: afb9f6a416025fb21da26d85bd9c38bb72f31e98b3d2d412ff8e12cc3692e674f4cefda90ed86884acbe4795fb1d70f5b11cf0ba7d7540bf81a53d9c40f6c609
7
+ data.tar.gz: bcb9e9e51a3bc4b986b364454d57a34bbc1d7c14e9ed1bcc83e6f83cd97a230426633d16e4d30e9f82c0676f059bf7156d5faad0966fc164e38a52850cb3950a
data/README.md CHANGED
@@ -45,6 +45,13 @@ Queenbee::Order.create(
45
45
  )
46
46
  ```
47
47
 
48
+ Optional attributes are avaiable for subscription-type such as:
49
+
50
+ ```ruby
51
+ subscribed_at: '2015-05-05 20:13:45',
52
+ unsubscribed_at: '2016-05-05 20:13:45'
53
+ ```
54
+
48
55
  **For Sinatra app** you may need to add `require 'bundler/setup'`
49
56
 
50
57
  3. Update order
@@ -2,7 +2,7 @@ module Queenbee
2
2
  module APIOperations
3
3
  module Create
4
4
  module ClassMethods
5
- def create(params={}, token=nil)
5
+ def create(params = {}, token = nil)
6
6
  response, token = Queenbee.request(:post, self.url, token, params)
7
7
  response
8
8
  end
@@ -13,4 +13,4 @@ module Queenbee
13
13
  end
14
14
  end
15
15
  end
16
- end
16
+ end
@@ -0,0 +1,10 @@
1
+ module Queenbee
2
+ module APIOperations
3
+ module Get
4
+ def get(params = {}, token = nil, url)
5
+ response, token = Queenbee.request(:get, url, token, params)
6
+ response
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ module Queenbee
2
+ class Metrics < APIResource
3
+ extend Queenbee::APIOperations::Get
4
+
5
+ def self.summary(params = {})
6
+ Queenbee::Metrics.get(params, '/metrics/summary')
7
+ end
8
+
9
+ def self.all
10
+ Queenbee::Metrics.get('/metrics/all')
11
+ end
12
+
13
+ end
14
+ end
@@ -1,3 +1,3 @@
1
1
  module Queenbee
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
data/lib/queenbee.rb CHANGED
@@ -11,6 +11,7 @@ require "queenbee/version"
11
11
 
12
12
  # API operations
13
13
  require "queenbee/api_operations/create"
14
+ require "queenbee/api_operations/get"
14
15
  require "queenbee/api_operations/update"
15
16
  require "queenbee/api_operations/delete"
16
17
 
@@ -18,6 +19,7 @@ require "queenbee/api_operations/delete"
18
19
  require "queenbee/queenbee_object"
19
20
  require "queenbee/api_resource"
20
21
  require "queenbee/order"
22
+ require "queenbee/metrics"
21
23
 
22
24
  # Errors
23
25
  require "queenbee/errors/queenbee_error"
@@ -46,8 +48,10 @@ module Queenbee
46
48
 
47
49
  begin
48
50
  uri = URI(url)
51
+ request = Net::HTTP::Get.new(uri) if method == :get
49
52
  request = Net::HTTP::Post.new(uri) if method == :post
50
53
  request = Net::HTTP::Put.new(uri) if method == :put
54
+ request = Net::HTTP::Delete.new(uri) if method == :delete
51
55
  request["User-Agent"] = "Queenbee gem"
52
56
  request["Authorization"] = "Token token=\"#{token}\""
53
57
  request["Content-Type"] = "application/json"
@@ -91,14 +95,12 @@ module Queenbee
91
95
 
92
96
  def self.handle_connection_error(e)
93
97
  case e
94
- when SocketError
95
- message = "Unexpected error when trying to connect to Queenbee."
96
-
97
- when NoMethodError
98
- message = "Unexpected HTTP response code"
99
-
100
- else
101
- message = "Unexpected error communicating with Queenbee."
98
+ when SocketError
99
+ message = "Unexpected error when trying to connect to Queenbee."
100
+ when NoMethodError
101
+ message = "Unexpected HTTP response code"
102
+ else
103
+ message = "Unexpected error communicating with Queenbee."
102
104
  end
103
105
 
104
106
  raise APIConnectionError.new(message + "\n\n(Network error: #{e.message})")
@@ -112,21 +114,19 @@ module Queenbee
112
114
  end
113
115
 
114
116
  case rcode
115
- when 400, 404, 422
116
- raise invalid_request_error error, rcode, rbody, error_obj
117
- when 401
118
- raise authentication_error error, rcode, rbody, error_obj
119
- when 500
120
- raise api_error error, rcode, rbody, error_obj
121
- else
122
- # raise api_error error, rcode, rbody, error_obj
117
+ when 400, 404, 422
118
+ raise invalid_request_error error, rcode, rbody, error_obj
119
+ when 401
120
+ raise authentication_error error, rcode, rbody, error_obj
121
+ when 500
122
+ raise api_error error, rcode, rbody, error_obj
123
+ else
124
+ # raise api_error error, rcode, rbody, error_obj
123
125
  end
124
-
125
126
  end
126
127
 
127
128
  def self.invalid_request_error(error, rcode, rbody, error_obj)
128
- InvalidRequestError.new(error[:message], error[:param], rcode,
129
- rbody, error_obj)
129
+ InvalidRequestError.new(error[:message], error[:param], rcode, rbody, error_obj)
130
130
  end
131
131
 
132
132
  def self.authentication_error(error, rcode, rbody, error_obj)
@@ -0,0 +1,15 @@
1
+ require File.expand_path("../../test_helper", __FILE__)
2
+
3
+ module Queenbee
4
+ class MetricsTest < Test::Unit::TestCase
5
+ should "summary should return status 200" do
6
+ response = Queenbee::Metrics.summary(start_date: "2014-07-01", end_date: "2014-07-02")
7
+ assert_equal "200", response.code
8
+ end
9
+
10
+ should "all should return status 200" do
11
+ response = Queenbee::Metrics.all
12
+ assert_equal "200", response.code
13
+ end
14
+ end
15
+ end
@@ -14,46 +14,46 @@ module Queenbee
14
14
  @updated_params = @valid_params.merge!(client_email: "kk@email.com")
15
15
  end
16
16
 
17
- should "create should return status 201" do
18
- response = Queenbee::Order.create(@valid_params)
19
- assert_equal "201", response.code
20
- end
21
-
22
- should "raise Queenbee::AuthenticationError if no token provided" do
23
- Queenbee.token = nil
24
- assert_raises(Queenbee::AuthenticationError) { Queenbee::Order.create }
25
- end
26
-
27
- should "raise Queenbee::InvalidRequestError if not enough parameters" do
28
- begin
29
- rescue JSON::ParserError
30
- assert_raises(Queenbee::InvalidRequestError) { Queenbee::Order.create }
31
- end
32
- end
33
-
34
- should "Update should return 200" do
35
- response1 = Queenbee::Order.create(@valid_params)
36
- response = Queenbee::Order.save(@updated_params)
37
- assert_equal "200", response.code
38
- end
39
-
40
- should "Update should return 404 if UID incorrect" do
41
- response1 = Queenbee::Order.create(@valid_params)
42
- invalid_params = @valid_params.merge!(uid: "fakeuid")
43
- response = Queenbee::Order.save(invalid_params)
44
- assert_equal "404", response.code
45
- end
46
-
47
- should "Delete should return 204" do
48
- response1 = Queenbee::Order.create(@valid_params)
49
- response = Queenbee::Order.delete(@uid)
50
- assert_equal "204", response.code
51
- end
52
-
53
- should "Delete should return 404 if UID incorrect" do
54
- response = Queenbee::Order.delete("fakeuid")
55
- assert_equal "404", response.code
56
- end
17
+ # should "create should return status 201" do
18
+ # response = Queenbee::Order.create(@valid_params)
19
+ # assert_equal "201", response.code
20
+ # end
21
+
22
+ # should "raise Queenbee::AuthenticationError if no token provided" do
23
+ # Queenbee.token = nil
24
+ # assert_raises(Queenbee::AuthenticationError) { Queenbee::Order.create }
25
+ # end
26
+
27
+ # should "raise Queenbee::InvalidRequestError if not enough parameters" do
28
+ # begin
29
+ # rescue JSON::ParserError
30
+ # assert_raises(Queenbee::InvalidRequestError) { Queenbee::Order.create }
31
+ # end
32
+ # end
33
+
34
+ # should "Update should return 200" do
35
+ # response1 = Queenbee::Order.create(@valid_params)
36
+ # response = Queenbee::Order.save(@updated_params)
37
+ # assert_equal "200", response.code
38
+ # end
39
+
40
+ # should "Update should return 404 if UID incorrect" do
41
+ # response1 = Queenbee::Order.create(@valid_params)
42
+ # invalid_params = @valid_params.merge!(uid: "fakeuid")
43
+ # response = Queenbee::Order.save(invalid_params)
44
+ # assert_equal "404", response.code
45
+ # end
46
+
47
+ # should "Delete should return 204" do
48
+ # response1 = Queenbee::Order.create(@valid_params)
49
+ # response = Queenbee::Order.delete(@uid)
50
+ # assert_equal "204", response.code
51
+ # end
52
+
53
+ # should "Delete should return 404 if UID incorrect" do
54
+ # response = Queenbee::Order.delete("fakeuid")
55
+ # assert_equal "404", response.code
56
+ # end
57
57
 
58
58
  end
59
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: queenbee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-08 00:00:00.000000000 Z
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -28,14 +28,14 @@ dependencies:
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
@@ -44,40 +44,40 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 1.8.1
47
+ version: '1.8'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 1.8.1
54
+ version: '1.8'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: shoulda
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 3.4.0
61
+ version: '3.4'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 3.4.0
68
+ version: '3.4'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: test-unit
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ">="
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ">="
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  description: E-commerce analytics platform
@@ -91,6 +91,7 @@ files:
91
91
  - lib/queenbee.rb
92
92
  - lib/queenbee/api_operations/create.rb
93
93
  - lib/queenbee/api_operations/delete.rb
94
+ - lib/queenbee/api_operations/get.rb
94
95
  - lib/queenbee/api_operations/update.rb
95
96
  - lib/queenbee/api_resource.rb
96
97
  - lib/queenbee/errors/api_connection_error.rb
@@ -98,9 +99,11 @@ files:
98
99
  - lib/queenbee/errors/authentication_error.rb
99
100
  - lib/queenbee/errors/invalid_request_error.rb
100
101
  - lib/queenbee/errors/queenbee_error.rb
102
+ - lib/queenbee/metrics.rb
101
103
  - lib/queenbee/order.rb
102
104
  - lib/queenbee/queenbee_object.rb
103
105
  - lib/queenbee/version.rb
106
+ - test/queenbee/metrics_test.rb
104
107
  - test/queenbee/order_test.rb
105
108
  - test/test_helper.rb
106
109
  homepage: https://github.com/olimart/queenbee-ruby
@@ -123,10 +126,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
123
126
  version: '0'
124
127
  requirements: []
125
128
  rubyforge_project:
126
- rubygems_version: 2.4.8
129
+ rubygems_version: 2.4.3
127
130
  signing_key:
128
131
  specification_version: 4
129
132
  summary: Gem to send e-commerce orders to the Queenbee central app.
130
133
  test_files:
134
+ - test/queenbee/metrics_test.rb
131
135
  - test/queenbee/order_test.rb
132
136
  - test/test_helper.rb