monkey-business 1.0.3 → 1.0.4

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: e7f1109a46b4a4a04942c094bde6ce3bbef2683c
4
- data.tar.gz: 4bffec75ad3beb6d3dbd16b7e46570535ec89321
3
+ metadata.gz: cbb05e51da48ad496cb83d19a12b467be7959eff
4
+ data.tar.gz: 73d7f61f555ac5c3e142e34bb4666789030c1073
5
5
  SHA512:
6
- metadata.gz: 2142f874d4d0c8248f0ee5f520fa63dae2b3fd1d6c23bf4e09f8d3a01ef8052ee6267a88e3160b7884077307137738014d99abd1920e0742173a8f722a3d7ddc
7
- data.tar.gz: 7befab103d4461a98d478a07abc356ab858e6d470f3c0f379f846a3843fcbfddcf6c71d4606308895043dd90cffda3f0a63c6e21282064364a3c97340347554c
6
+ metadata.gz: f5f3f139f3cb158971f281bc160131e8886d149bd029d75b9f5a2b23d918335ee01fbe154407a3e58db5a801c61f98210fabfa26260ea4fec98f0e496bc129f5
7
+ data.tar.gz: 35a4fbef3fc585a1da6882e02a9109d9371d16738dd18afe1432b9f4a8974aee851f8970290913666c645d681fa2dabf7e6ddc36c928b10d21cdee0d3727e994
@@ -30,8 +30,7 @@ module MonkeyBusiness
30
30
 
31
31
  def fail_without_id
32
32
  return if @id
33
- raise MonkeyBusiness::ApiMethodError.new(
34
- <<~MESSAGE
33
+ raise MonkeyBusiness::ApiMethodError, <<~MESSAGE
35
34
  ID must be provided for the following method:
36
35
  #{caller_locations(1, 1)[0].label}
37
36
  Expected:
@@ -39,7 +38,6 @@ module MonkeyBusiness
39
38
  Received:
40
39
  #{@path}
41
40
  MESSAGE
42
- )
43
41
  end
44
42
  end
45
43
  end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module MonkeyBusiness
4
+ # Abstraction of the Surveymonkey benchmark_bundle resource
5
+ # and associated methods
6
+ class BenchmarkBundles < ApiResource
7
+ def analyze(options = {})
8
+ fail_without_id
9
+ @options.merge!(options)
10
+ @path += '/details'
11
+ end
12
+ end
13
+ end
@@ -2,12 +2,25 @@
2
2
 
3
3
  require_relative 'api_resource.rb'
4
4
  require_relative 'responses.rb'
5
+ require_relative 'messages.rb'
6
+ require_relative 'recipients.rb'
5
7
 
6
8
  module MonkeyBusiness
7
9
  # Abstraction of the Surveymonkey collectors resource and associated methods
8
10
  class Collectors < ApiResource
9
11
  def responses(options = {})
12
+ fail_without_id
10
13
  Responses.new(@api, @options.merge(options), @path)
11
14
  end
15
+
16
+ def messages(options = {})
17
+ fail_without_id
18
+ Messages.new(@api, @options.merge(options), @path)
19
+ end
20
+
21
+ def recipients(options = {})
22
+ fail_without_id
23
+ Recipients.new(@api, @options.merge(options), @path)
24
+ end
12
25
  end
13
26
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+ require_relative 'contacts.rb'
5
+
6
+ module MonkeyBusiness
7
+ # Abstraction of the Surveymonkey contact_field resource & associated methods
8
+ class ContactFields < ApiResource
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+ require_relative 'contacts.rb'
5
+
6
+ module MonkeyBusiness
7
+ # Abstraction of the Surveymonkey contact_list resource and associated methods
8
+ class ContactLists < ApiResource
9
+ def copy(options = {})
10
+ fail_without_id
11
+ @options.merge!(options)
12
+ @path += '/copy'
13
+ self
14
+ end
15
+
16
+ def merge(options = {})
17
+ fail_without_id
18
+ @options.merge!(options)
19
+ @path += '/merge'
20
+ self
21
+ end
22
+
23
+ def contacts(options = {})
24
+ fail_without_id
25
+ Contacts.new(@api, @options.merge(options), @path)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+
5
+ module MonkeyBusiness
6
+ # Abstraction of the Surveymonkey contact resource and associated methods
7
+ class Contacts < ApiResource
8
+ def bulk(options = {})
9
+ @options.merge!(options)
10
+ @path += '/bulk'
11
+ self
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+
5
+ module MonkeyBusiness
6
+ # Abstraction of the Surveymonkey error resource and associated methods
7
+ class Errors < ApiResource
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+ require_relative 'members.rb'
5
+
6
+ module MonkeyBusiness
7
+ # Abstraction of the Surveymonkey group resource and associated methods
8
+ class Groups < ApiResource
9
+ def members(options = {})
10
+ fail_without_id
11
+ Members.new(@api, @options.merge(options), @path)
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+
5
+ module MonkeyBusiness
6
+ # Abstraction of the Surveymonkey user resource in the context of API
7
+ # endpoints for groups
8
+ class Members < ApiResource
9
+ end
10
+ end
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'recipients'
4
+
5
+ module MonkeyBusiness
6
+ # Abstraction of the Surveymonkey message resource and associated methods
7
+ class Messages < ApiResource
8
+ def send
9
+ fail_without_id
10
+ @options.merge!(options)
11
+ @path += '/send'
12
+ end
13
+
14
+ def recipients
15
+ fail_without_id
16
+ @options.merge!(options)
17
+ Recipients.new(@api, @options.merge(options), @path)
18
+ end
19
+ end
20
+ end
@@ -5,5 +5,11 @@ require_relative 'api_resource.rb'
5
5
  module MonkeyBusiness
6
6
  # Abstraction of the Surveymonkey question resource and associated methods
7
7
  class Questions < ApiResource
8
+ def benchmark(options = {})
9
+ fail_without_id
10
+ @options.merge!(options)
11
+ @path += '/benchmark'
12
+ self
13
+ end
8
14
  end
9
15
  end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+
5
+ module MonkeyBusiness
6
+ # Abstraction of the Surveymonkey recipient resource and associated methods
7
+ class Recipients < ApiResource
8
+ def bulk(options = {})
9
+ @options.merge!(options)
10
+ @path += '/bulk'
11
+ self
12
+ end
13
+ end
14
+ end
@@ -24,7 +24,7 @@ module MonkeyBusiness
24
24
  end
25
25
 
26
26
  def self.get
27
- params = @options.map { |k, v| "#{k}=#{v}" }.join('&')
27
+ params = @options.map { |k, v| "#{k}=#{URI.encode(v)}" }.join('&')
28
28
 
29
29
  request = Net::HTTP::Get.new("#{@uri.request_uri}?#{params}")
30
30
  request['Authorization'] = "bearer #{@access_token}"
@@ -36,7 +36,42 @@ module MonkeyBusiness
36
36
  end
37
37
 
38
38
  def self.post
39
- raise NotImplementedError, 'Not Yet Implemented'
39
+ request = Net::HTTP::Post.new(@uri.request_uri)
40
+ request.body = @options.to_json
41
+
42
+ request['Authorization'] = "bearer #{@access_token}"
43
+ request['Content-Type'] = 'application/json'
44
+
45
+ @http.request(request)
46
+ end
47
+
48
+ def self.put
49
+ request = Net::HTTP::Put.new(@uri.request_uri)
50
+ request.body = @options.to_json
51
+
52
+ request['Authorization'] = "bearer #{@access_token}"
53
+ request['Content-Type'] = 'application/json'
54
+
55
+ @http.request(request)
56
+ end
57
+
58
+ def self.patch
59
+ request = Net::HTTP::Patch.new(@uri.request_uri)
60
+ request.body = @options.to_json
61
+
62
+ request['Authorization'] = "bearer #{@access_token}"
63
+ request['Content-Type'] = 'application/json'
64
+
65
+ @http.request(request)
66
+ end
67
+
68
+ def self.delete
69
+ request = Net::HTTP::Delete.new(@uri.request_uri)
70
+
71
+ request['Authorization'] = "bearer #{@access_token}"
72
+ request['Content-Type'] = 'application/json'
73
+
74
+ @http.request(request)
40
75
  end
41
76
 
42
77
  def self.head
@@ -3,7 +3,8 @@
3
3
  require_relative 'api_resource.rb'
4
4
 
5
5
  module MonkeyBusiness
6
- # Abstraction of the Surveymonkey survey_category resource and associated methods
6
+ # Abstraction of the Surveymonkey survey_category resource
7
+ # and associated methods
7
8
  class SurveyCategories < ApiResource
8
9
  end
9
10
  end
@@ -3,7 +3,8 @@
3
3
  require_relative 'api_resource.rb'
4
4
 
5
5
  module MonkeyBusiness
6
- # Abstraction of the Surveymonkey survey_template resource and associated methods
6
+ # Abstraction of the Surveymonkey survey_template resource
7
+ # and associated methods
7
8
  class SurveyTemplates < ApiResource
8
9
  end
9
10
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'api_resource.rb'
4
+
5
+ module MonkeyBusiness
6
+ # Abstraction of the Surveymonkey webhook resource and associated methods
7
+ class Webhooks < ApiResource
8
+ end
9
+ end
@@ -5,6 +5,13 @@ require_relative 'api/surveys.rb'
5
5
  require_relative 'api/survey_categories.rb'
6
6
  require_relative 'api/survey_templates.rb'
7
7
  require_relative 'api/users.rb'
8
+ require_relative 'api/groups.rb'
9
+ require_relative 'api/contact_lists.rb'
10
+ require_relative 'api/contacts.rb'
11
+ require_relative 'api/contact_fields.rb'
12
+ require_relative 'api/webhooks.rb'
13
+ require_relative 'api/benchmark_bundles.rb'
14
+ require_relative 'api/errors.rb'
8
15
 
9
16
  module MonkeyBusiness
10
17
  API_VERSION = 'v3'
@@ -32,6 +39,38 @@ module MonkeyBusiness
32
39
  Users.new(self, options)
33
40
  end
34
41
 
42
+ def groups(options = {})
43
+ Groups.new(self, options)
44
+ end
45
+
46
+ def contact_lists(options = {})
47
+ ContactLists.new(self, options)
48
+ end
49
+
50
+ def contacts(options = {})
51
+ Contacts.new(self, options)
52
+ end
53
+
54
+ def contact_fields(options = {})
55
+ ContactFields.new(self, options)
56
+ end
57
+
58
+ def collectors(options = {})
59
+ Collectors.new(self, options)
60
+ end
61
+
62
+ def webhooks(options = {})
63
+ Webhooks.new(self, options)
64
+ end
65
+
66
+ def benchmark_bundles(options = {})
67
+ BenchmarkBundles.new(self, options)
68
+ end
69
+
70
+ def errors(options = {})
71
+ Errors.new(self, options)
72
+ end
73
+
35
74
  def request(resource_path, options = {})
36
75
  HttpRequest.request(
37
76
  @access_token,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey-business
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Escue
@@ -17,15 +17,25 @@ extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
19
  - lib/api/api_resource.rb
20
+ - lib/api/benchmark_bundles.rb
20
21
  - lib/api/collectors.rb
22
+ - lib/api/contact_fields.rb
23
+ - lib/api/contact_lists.rb
24
+ - lib/api/contacts.rb
25
+ - lib/api/errors.rb
26
+ - lib/api/groups.rb
27
+ - lib/api/members.rb
28
+ - lib/api/messages.rb
21
29
  - lib/api/pages.rb
22
30
  - lib/api/questions.rb
31
+ - lib/api/recipients.rb
23
32
  - lib/api/request.rb
24
33
  - lib/api/responses.rb
25
34
  - lib/api/survey_categories.rb
26
35
  - lib/api/survey_templates.rb
27
36
  - lib/api/surveys.rb
28
37
  - lib/api/users.rb
38
+ - lib/api/webhooks.rb
29
39
  - lib/exceptions.rb
30
40
  - lib/monkey_business.rb
31
41
  homepage: https://github.com/cescue/monkey-business