pipekit 2.0.0 → 2.1.1

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: c29f137ec674dd92e5458ec82f4a637f4571da25
4
- data.tar.gz: 0bca608dc9986d0549efd1a79c0dd7deb3cd8d0c
3
+ metadata.gz: 94dc04bff37594cd94b7ed1affd416a8275cc128
4
+ data.tar.gz: 0a25fdb3e60cf81fe1392076d90e2b5d38e65f2c
5
5
  SHA512:
6
- metadata.gz: 341d2b409dda391fdd27a25fb2c215d8956910c99f6f2402f72cc1ef9991c47c67899903bd2cb6f7084a7d16ebe416d3b63f54de11e4e8c7afe0292f5076275d
7
- data.tar.gz: 5e792c6a7523980c5a3ef917a7bebfe283f2e3ba80313dddc1f43d4f361c6587b2273cb662f792312936885f8341407ba1d0a2cf8399253533484a5ba0d27028
6
+ metadata.gz: 51e03e6d8f2c8e114e3af55a41c2c8beee47ea96a24fc7f39c1e35222301996ce207247f0039a2145eedc9e8d9a7747084b2863252ee676bafa6f148e3e1cbf8
7
+ data.tar.gz: 2978c25a5ce9faf34fd03950b642f6373bf5ef7d796ee4aae6b572486ca485033cb616f77a5ee6e16b487cbd5454102e636e01e157a46a6695afe532ad09dc84
data/README.md CHANGED
@@ -36,6 +36,7 @@ The interface of Pipekit is organised around *repositories*. The available repos
36
36
  - Organization
37
37
  - Person
38
38
  - PersonField
39
+ - Activity
39
40
 
40
41
  ### Resource repositories
41
42
 
@@ -91,6 +92,17 @@ note_repo = Pipekit::Note.new
91
92
  note_repo.update(123, {content: "Hey"})
92
93
  ```
93
94
 
95
+ Add an Activity
96
+
97
+ ```ruby
98
+ activity_repo.create(deal_id: 123,
99
+ subject: "Interview Completed",
100
+ done: 1,
101
+ type: "pairing_session",
102
+ duration: "00:45",
103
+ note: "This was a fantastic interview")
104
+ ```
105
+
94
106
  ### Field repositories
95
107
 
96
108
  Pipedrive stores custom fields as key-value pairs. E.g. when you add an "Address" field to Persons Pipderive will store it as something like "050280e9bed01e55e25532f0b6e6228c748bf994"
@@ -144,4 +156,3 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERN
144
156
  ## License
145
157
 
146
158
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
147
-
@@ -13,6 +13,8 @@ require "pipekit/person_field"
13
13
  require "pipekit/deal_field"
14
14
  require "pipekit/note"
15
15
  require "pipekit/user"
16
+ require "pipekit/activity"
17
+ require "pipekit/resource_label"
16
18
 
17
19
  module Pipekit
18
20
 
@@ -25,4 +27,3 @@ module Pipekit
25
27
  Config.file_path = path
26
28
  end
27
29
  end
28
-
@@ -0,0 +1,7 @@
1
+ module Pipekit
2
+ class Activity
3
+ include Repository
4
+ SINGULAR_CLASSNAME = "activity".freeze
5
+ PLURALIZED_CLASSNAME = "activities".freeze
6
+ end
7
+ end
@@ -1,6 +1,8 @@
1
1
  module Pipekit
2
2
  class Deal
3
3
  include Repository
4
+ SINGULAR_CLASSNAME = "deal".freeze
5
+ PLURALIZED_CLASSNAME = "deals".freeze
4
6
 
5
7
  def get_by_person_id(person_id, person_repo: Person.new)
6
8
  raise UnknownPersonError, "No person ID supplied when getting deals by person ID" unless person_id
@@ -1,5 +1,8 @@
1
1
  module Pipekit
2
2
  class DealField
3
3
  include FieldRepository
4
+ # Pipedrive requires camelcase for resources
5
+ SINGULAR_CLASSNAME = "dealField".freeze
6
+ PLURALIZED_CLASSNAME = "dealFields".freeze
4
7
  end
5
8
  end
@@ -1,6 +1,7 @@
1
1
  module Pipekit
2
2
  module FieldRepository
3
3
  include Repository
4
+
4
5
  def get_by_key(key)
5
6
  key = Config.field_id(parent_resource, key)
6
7
  search_fields("key", key)
@@ -34,7 +35,7 @@ module Pipekit
34
35
  end
35
36
 
36
37
  def parent_resource
37
- resource.chomp("Field")
38
+ resource.pluralized.chomp("Fields")
38
39
  end
39
40
 
40
41
  end
@@ -1,5 +1,7 @@
1
1
  module Pipekit
2
2
  class Note
3
3
  include Repository
4
+ SINGULAR_CLASSNAME = "note".freeze
5
+ PLURALIZED_CLASSNAME = "notes".freeze
4
6
  end
5
7
  end
@@ -1,5 +1,7 @@
1
1
  module Pipekit
2
2
  class Organization
3
3
  include Repository
4
+ SINGULAR_CLASSNAME = "organization".freeze
5
+ PLURALIZED_CLASSNAME = "organizations".freeze
4
6
  end
5
7
  end
@@ -1,6 +1,8 @@
1
1
  module Pipekit
2
2
  class Person
3
3
  include Repository
4
+ SINGULAR_CLASSNAME = "person".freeze
5
+ PLURALIZED_CLASSNAME = "persons".freeze
4
6
 
5
7
  def get_by_email(email)
6
8
  request.get("find", term: email, search_by_email: 1)
@@ -1,5 +1,8 @@
1
1
  module Pipekit
2
2
  class PersonField
3
3
  include FieldRepository
4
+ # Pipedrive requires camelcase for resources
5
+ SINGULAR_CLASSNAME = "personField".freeze
6
+ PLURALIZED_CLASSNAME = "personFields".freeze
4
7
  end
5
8
  end
@@ -94,7 +94,9 @@ module Pipekit
94
94
  end
95
95
 
96
96
  def resource
97
- self.class.to_s.split("::").last.tap { |name| name[0] = name[0].downcase }
97
+ singular_resource = self.class::SINGULAR_CLASSNAME
98
+ pluralized_resource = self.class::PLURALIZED_CLASSNAME
99
+ ResourceLabel.new(singular_label: singular_resource, pluralized_label: pluralized_resource)
98
100
  end
99
101
 
100
102
  def email_key?(options)
@@ -25,7 +25,6 @@ module Pipekit
25
25
  # value - The value of the field.
26
26
  #
27
27
  # Examples
28
- #
29
28
  # search_by_field(field: :cohort, value: 119)
30
29
  # search_by_field(field: :github_username, value: "octocat")
31
30
  #
@@ -73,15 +72,15 @@ module Pipekit
73
72
 
74
73
  def get_request(uri, query, start = 0)
75
74
  response = self.class.get(uri, options(query: {limit: pagination_limit, start: start}.merge(query)))
76
- Result.new(resource, response)
75
+ Result.new(resource.singular, response)
77
76
  end
78
77
 
79
78
  def response_from(response_data)
80
- Result.response(resource, response_data)
79
+ Result.response(resource.singular, response_data)
81
80
  end
82
81
 
83
82
  def uri(id = "")
84
- "/#{resource}s/#{id}".chomp("/")
83
+ "/#{resource.pluralized}/#{id}".chomp("/")
85
84
  end
86
85
 
87
86
  def options(query: {}, body: {})
@@ -106,8 +105,8 @@ module Pipekit
106
105
  # meaning you don't have to worry about the custom IDs
107
106
  def parse_body(body)
108
107
  body.reduce({}) do |result, (field, value)|
109
- value = Config.field_value_id(resource, field, value)
110
- field = Config.field_id(resource, field)
108
+ value = Config.field_value_id(resource.singular, field, value)
109
+ field = Config.field_id(resource.singular, field)
111
110
  result.tap { |result| result[field] = value }
112
111
  end
113
112
  end
@@ -118,10 +117,10 @@ module Pipekit
118
117
 
119
118
  def search_by_field_query(field = nil, value = nil)
120
119
  {
121
- field_type: "#{resource}Field",
122
- field_key: Config.field_id(resource, field),
120
+ field_type: "#{resource.singular}Field",
121
+ field_key: Config.field_id(resource.singular, field),
123
122
  return_item_ids: true,
124
- term: Config.field_value_id(resource, field, value),
123
+ term: Config.field_value_id(resource.singular, field, value),
125
124
  exact_match: 1
126
125
  }
127
126
  end
@@ -0,0 +1,12 @@
1
+ module Pipekit
2
+ class ResourceLabel
3
+
4
+ attr_reader :singular, :pluralized
5
+
6
+ def initialize(singular_label:, pluralized_label:)
7
+ @singular = singular_label
8
+ @pluralized = pluralized_label
9
+ end
10
+
11
+ end
12
+ end
@@ -1,6 +1,8 @@
1
1
  module Pipekit
2
2
  class User
3
3
  include Repository
4
+ SINGULAR_CLASSNAME = "user".freeze
5
+ PLURALIZED_CLASSNAME = "users".freeze
4
6
 
5
7
  def get_by_email(email)
6
8
  request.get('find', term: email, search_by_email: 1)
@@ -1,3 +1,3 @@
1
1
  module Pipekit
2
- VERSION = "2.0.0"
2
+ VERSION = "2.1.1"
3
3
  end
@@ -1,24 +1,24 @@
1
1
  # coding: utf-8
2
- lib = File.expand_path('../lib', __FILE__)
2
+ lib = File.expand_path("../lib", __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'pipekit/version'
4
+ require "pipekit/version"
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "pipekit"
8
8
  spec.version = Pipekit::VERSION
9
- spec.authors = ["jafrog", "pitchinvasion", "spike01", "danldb"]
10
- spec.email = ["irina@makersacademy.com", "leo@makersacademy.com", "spike@makersacademy.com", "dan@makersacademy.com"]
9
+ spec.authors = ["jafrog", "pitchinvasion", "spike01", "dbugsy", "roidriscoll"]
10
+ spec.email = ["dev@makersacademy.com"]
11
11
 
12
12
  spec.summary = %q{Pipedrive API client for Ruby.}
13
- spec.description = %q{Pipedrive API client for Ruby.}
13
+ spec.description = %q{Pipedrive API client for Ruby. Full API NOT implemented currently.}
14
14
  spec.homepage = "https://github.com/makersacademy/pipekit"
15
15
  spec.license = "MIT"
16
- spec.required_ruby_version = '>= 1.9.1'
16
+ spec.required_ruby_version = ">= 1.9.1"
17
17
 
18
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the "allowed_push_host"
19
19
  # to allow pushing to a single host or delete this section to allow pushing to any host.
20
20
  if spec.respond_to?(:metadata)
21
- spec.metadata['allowed_push_host'] = "https://rubygems.org"
21
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
22
22
  else
23
23
  raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
24
24
  end
@@ -34,6 +34,6 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency "bundler", "~> 1.12"
35
35
  spec.add_development_dependency "rake", "~> 10.0"
36
36
  spec.add_development_dependency "rspec", "~> 3.0"
37
- spec.add_development_dependency "webmock", "~> 2.1.0"
37
+ spec.add_development_dependency "webmock"
38
38
  spec.add_development_dependency "pry"
39
39
  end
metadata CHANGED
@@ -1,17 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipekit
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - jafrog
8
8
  - pitchinvasion
9
9
  - spike01
10
- - danldb
10
+ - dbugsy
11
+ - roidriscoll
11
12
  autorequire:
12
13
  bindir: exe
13
14
  cert_chain: []
14
- date: 2017-05-19 00:00:00.000000000 Z
15
+ date: 2017-11-13 00:00:00.000000000 Z
15
16
  dependencies:
16
17
  - !ruby/object:Gem::Dependency
17
18
  name: httparty
@@ -87,16 +88,16 @@ dependencies:
87
88
  name: webmock
88
89
  requirement: !ruby/object:Gem::Requirement
89
90
  requirements:
90
- - - "~>"
91
+ - - ">="
91
92
  - !ruby/object:Gem::Version
92
- version: 2.1.0
93
+ version: '0'
93
94
  type: :development
94
95
  prerelease: false
95
96
  version_requirements: !ruby/object:Gem::Requirement
96
97
  requirements:
97
- - - "~>"
98
+ - - ">="
98
99
  - !ruby/object:Gem::Version
99
- version: 2.1.0
100
+ version: '0'
100
101
  - !ruby/object:Gem::Dependency
101
102
  name: pry
102
103
  requirement: !ruby/object:Gem::Requirement
@@ -111,12 +112,9 @@ dependencies:
111
112
  - - ">="
112
113
  - !ruby/object:Gem::Version
113
114
  version: '0'
114
- description: Pipedrive API client for Ruby.
115
+ description: Pipedrive API client for Ruby. Full API NOT implemented currently.
115
116
  email:
116
- - irina@makersacademy.com
117
- - leo@makersacademy.com
118
- - spike@makersacademy.com
119
- - dan@makersacademy.com
117
+ - dev@makersacademy.com
120
118
  executables: []
121
119
  extensions: []
122
120
  extra_rdoc_files: []
@@ -132,6 +130,7 @@ files:
132
130
  - bin/console
133
131
  - bin/setup
134
132
  - lib/pipekit.rb
133
+ - lib/pipekit/activity.rb
135
134
  - lib/pipekit/config.rb
136
135
  - lib/pipekit/deal.rb
137
136
  - lib/pipekit/deal_field.rb
@@ -142,6 +141,7 @@ files:
142
141
  - lib/pipekit/person_field.rb
143
142
  - lib/pipekit/repository.rb
144
143
  - lib/pipekit/request.rb
144
+ - lib/pipekit/resource_label.rb
145
145
  - lib/pipekit/response.rb
146
146
  - lib/pipekit/result.rb
147
147
  - lib/pipekit/user.rb
@@ -168,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
168
168
  version: '0'
169
169
  requirements: []
170
170
  rubyforge_project:
171
- rubygems_version: 2.6.8
171
+ rubygems_version: 2.6.14
172
172
  signing_key:
173
173
  specification_version: 4
174
174
  summary: Pipedrive API client for Ruby.