rdgem 0.2.0 → 0.2.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f024ec2854a6aeff4e6faa2edfd1d41396f8e554
4
- data.tar.gz: 3be8dd7d25a0ba1a40a7cc2a78d47ada8dcdcf21
3
+ metadata.gz: 25291b355f23ab7f3bcef9f07d830ef4794cbe3a
4
+ data.tar.gz: 366f57d5d875d91457976a612399ca782ad7b3ff
5
5
  SHA512:
6
- metadata.gz: ab1ee3cc4c55353a8eb19919121451dc0695793f6dc6984235ce63b64384694cd3a02817a1a3b30ebe0d99d26da75bdc361545a588d16521912a6e15784091f9
7
- data.tar.gz: 4c227b5ef3e3b165cfbeba804252e005644824cecbbb224b7f65e462e5d258041021ecd5f25a33a05e68463221b7c3b90e6e21094a727367ef1be09309865eaa
6
+ metadata.gz: 705a64b12ae1d085bda4168285c5b9a681677428d1a0f118de7332bd55ac52ee18387fad0d518198d3c7aa80648e34dae92c7ea146baa2fdf24814c092d4aeb2
7
+ data.tar.gz: a6b22506690f6374599aee4e16d7c63ffa1ca621b09fb756feafc6d2e6d148325b99018359e15d112e74de2118ce80aa3e41d96450a74d9380a826ceceb48ce3
data/Rakefile CHANGED
@@ -1 +1 @@
1
- require "bundler/gem_tasks"
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,52 @@
1
+ require 'rdgem'
2
+
3
+ module Rdgem
4
+ class Companies
5
+ #queries for a company name. creates when it doesn't exist.
6
+ def self.get_or_create_company(app_key, company)
7
+ org_app_id = false
8
+
9
+ query = PIPEDRIVE_API + 'organizations/find?term=' \
10
+ + company + '&start=0&' + TOKEN + app_key
11
+
12
+ response = HTTParty.get(query)
13
+ #if successfull and with content, get the company app_key
14
+ #so as not to create another with the same name
15
+ if response["success"]
16
+ unless response["data"] == nil
17
+ response["data"].each do |search|
18
+ if search['name'] == company
19
+ org_app_id = search['id']
20
+ #not caring about duplicates.
21
+ #we will ensure we at least won't create any
22
+ break
23
+ end
24
+ end
25
+ else
26
+ #didn't find, create one
27
+ input_query = PIPEDRIVE_API + 'organizations?' + TOKEN + app_key
28
+
29
+ org_response = HTTParty.post(input_query,
30
+ :body => {:name =>company},
31
+ :headers => HEADERS )
32
+
33
+ unless org_response["data"] == nil
34
+ org_app_id = org_response["data"]["id"]
35
+ end
36
+ end
37
+ else
38
+ #error getting company
39
+ end
40
+ return org_app_id
41
+ end
42
+
43
+ #fow now, just used for testing
44
+ def self.delete_company(app_key, company_id)
45
+
46
+ query = "#{PIPEDRIVE_API}organizations/#{company_id}?#{TOKEN}#{app_key}"
47
+ response = HTTParty.delete(query)
48
+
49
+ return response["success"]
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,15 @@
1
+ require 'rdgem'
2
+
3
+ module Rdgem
4
+ class People
5
+ #pushes the lead to pipedrive
6
+ def self.send_lead(app_key, lead_to_person)
7
+ query = PIPEDRIVE_API + 'persons?' + TOKEN + app_key
8
+
9
+ response = HTTParty.post(query,
10
+ :body => lead_to_person,
11
+ :headers => HEADERS)
12
+ return response["success"]
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,118 @@
1
+ require 'rdgem'
2
+
3
+ module Rdgem
4
+ class PeopleFields
5
+
6
+ ## even if populated the field key will always be replaced
7
+ def self.create_field(app_key, field_name, testing=0)
8
+ field_api_key = false
9
+ field_api_id = false
10
+
11
+ input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
12
+
13
+ response = HTTParty.post(input_query,
14
+ :body => {:name =>"#{field_name}",
15
+ :field_type => "varchar"},
16
+ :headers => HEADERS )
17
+
18
+ unless response["data"] == nil
19
+ field_api_id = response["data"]["id"]
20
+
21
+
22
+ #for testing we just need the ID to delete it right away
23
+ if testing == "create"
24
+ return field_api_id
25
+ end
26
+
27
+ key_query = PIPEDRIVE_API + 'personFields/'\
28
+ + field_api_id.to_s + "?" + TOKEN + app_key
29
+
30
+ field_key_response = HTTParty.get(key_query)
31
+
32
+ unless field_key_response["data"] == nil
33
+ field_api_key = field_key_response["data"]["key"]
34
+ end
35
+ end
36
+ return field_api_key
37
+ end
38
+
39
+ #checks if the key is valid and if the custom fields are created in the acc
40
+ # if any field is missing, create it
41
+ def self.assert_fields(fields, app_key, testing=0)
42
+ @field_key = []
43
+ query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
44
+
45
+ response = HTTParty.get(query)
46
+ if response["success"]
47
+ #Assert: looks for the desired fields
48
+ fields.each_with_index do |assert, index|
49
+ response["data"].each do |search|
50
+ if search['name'] == assert
51
+ @field_key[index] = search['key']
52
+ end
53
+ end
54
+ end
55
+ if testing == "assert"
56
+ return @field_key
57
+ end
58
+
59
+ # Integrate: create missing fields
60
+ fields.each_with_index do |create, index|
61
+ if @field_key[index].nil?
62
+ @field_key[index] = create_field(app_key, create, testing)
63
+ end
64
+ end
65
+ if testing == "create"
66
+ return @field_key
67
+ end
68
+
69
+ #Hash the info
70
+ custom_field = Hash[fields.zip(@field_key.map \
71
+ {|i| i.include?(',') ? (i.split /, /) : i})] #/
72
+ else
73
+ if response["error"] == "You need to be authorized to make this request."
74
+ return false
75
+ end
76
+ end
77
+ #ship it back
78
+ return custom_field
79
+ end
80
+
81
+ # # adds a new field to the owner app_key's account
82
+ # def self.add_field_to_user(app_key, field_name)
83
+ # field_api_key = false
84
+ #
85
+ # input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
86
+ #
87
+ # response = HTTParty.post(input_query,
88
+ # :body => {:name =>"#{field_name}",
89
+ # :field_type => "varchar"},
90
+ # :headers => HEADERS )
91
+ #
92
+ # unless response["data"] == nil
93
+ # field_api_id = response["data"]["id"]
94
+ #
95
+ # key_query = PIPEDRIVE_API + 'personFields/'\
96
+ # + field_api_id.to_s + "?" + TOKEN + app_key
97
+ #
98
+ #
99
+ # field_key_response = HTTParty.get(key_query)
100
+ #
101
+ # unless field_key_response["data"] == nil
102
+ # field_api_key = field_key_response["data"]["key"]
103
+ # end
104
+ # end
105
+ # return field_api_key
106
+ # end
107
+ #
108
+ # removes a field from the owner app_key's account (used for testing only)
109
+ def self.delete_field(app_key, field_id)
110
+
111
+ query = "#{PIPEDRIVE_API}personFields/#{field_id}?#{TOKEN}#{app_key}"
112
+ response = HTTParty.delete(query)
113
+
114
+ return response["success"]
115
+ end
116
+
117
+ end
118
+ end
data/lib/rdgem/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Rdgem
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.5"
3
3
  end
data/lib/rdgem.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  require "rdgem/version"
2
+ require "rdgem/people_fields"
3
+ require "rdgem/companies"
4
+ require "rdgem/people"
2
5
 
3
6
  require 'json'
4
7
  require 'httparty'
@@ -6,147 +9,147 @@ require 'httparty'
6
9
  module Rdgem
7
10
  # Your code goes here...
8
11
  # global declarations
9
- PIPEDRIVE_API = "https://api.pipedrive.com/v1/"
12
+ PIPEDRIVE_API = "https://api.pipedrive.com/v1/"
10
13
  TOKEN = "api_token="
11
14
  HEADERS = {'Accept'=>'application/json',
12
15
  'Content-Type'=>'application/x-www-form-urlencoded',
13
16
  'User-Agent'=>'Ruby.Pipedrive.Api' }
14
17
 
15
18
  #pushes the lead to pipedrive
16
- def self.send_lead(app_key, lead_to_person)
17
- query = PIPEDRIVE_API + 'persons?' + TOKEN + app_key
18
-
19
- response = HTTParty.post(query,
20
- :body => lead_to_person,
21
- :headers => HEADERS)
22
- end
19
+ #def self.send_lead(app_key, lead_to_person)
20
+ # query = PIPEDRIVE_API + 'persons?' + TOKEN + app_key
21
+ #
22
+ # # response = HTTParty.post(query,
23
+ # # :body => lead_to_person,
24
+ # # :headers => HEADERS)
25
+ #end
23
26
 
24
27
  #queries for a company name. creates when it doesn't exist.
25
- def self.get_or_create_company(app_key, company)
26
- org_app_id = ""
27
-
28
- query = PIPEDRIVE_API + 'organizations/find?term=' \
29
- + company + '&start=0&' + TOKEN + app_key
30
-
31
- response = HTTParty.get(query)
32
- #if successfull and with content, get the company app_key
33
- #so as not to create another with the same name
34
- if response["success"]
35
- unless response["data"] == nil
36
- response["data"].each do |search|
37
- if search['name'] == company
38
- org_app_id = search['id']
39
- #not caring about duplicates.
40
- #we will ensure we at least won't create any
41
- break
42
- end
43
- end
44
- else
45
- #didn't find, create one
46
- input_query = PIPEDRIVE_API + 'organizations?' + TOKEN + app_key
47
-
48
- org_response = HTTParty.post(input_query,
49
- :body => {:name =>company},
50
- :headers => HEADERS )
51
-
52
- unless org_response["data"] == nil
53
- org_app_id = org_response["data"]["id"]
54
- end
55
- end
56
- else
57
- #error getting company
58
- end
59
- return org_app_id
60
- end
28
+ # def self.get_or_create_company(app_key, company)
29
+ # org_app_id = ""
30
+ #
31
+ # query = PIPEDRIVE_API + 'organizations/find?term=' \
32
+ # + company + '&start=0&' + TOKEN + app_key
33
+ #
34
+ # response = HTTParty.get(query)
35
+ # #if successfull and with content, get the company app_key
36
+ # #so as not to create another with the same name
37
+ # if response["success"]
38
+ # unless response["data"] == nil
39
+ # response["data"].each do |search|
40
+ # if search['name'] == company
41
+ # org_app_id = search['id']
42
+ # #not caring about duplicates.
43
+ # #we will ensure we at least won't create any
44
+ # break
45
+ # end
46
+ # end
47
+ # else
48
+ # #didn't find, create one
49
+ # input_query = PIPEDRIVE_API + 'organizations?' + TOKEN + app_key
50
+ #
51
+ # org_response = HTTParty.post(input_query,
52
+ # :body => {:name =>company},
53
+ # :headers => HEADERS )
54
+ #
55
+ # unless org_response["data"] == nil
56
+ # org_app_id = org_response["data"]["id"]
57
+ # end
58
+ # end
59
+ # else
60
+ # #error getting company
61
+ # end
62
+ # return org_app_id
63
+ # end
61
64
 
62
65
  # adds a new field to the owner app_key's account
63
- def self.add_field_to_user(app_key, field_name)
64
- field_api_key = false
65
-
66
- input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
67
-
68
- response = HTTParty.post(input_query,
69
- :body => {:name =>"#{field_name}",
70
- :field_type => "varchar"},
71
- :headers => HEADERS )
72
-
73
- unless response["data"] == nil
74
- field_api_id = response["data"]["id"]
75
-
76
- key_query = PIPEDRIVE_API + 'personFields/'\
77
- + field_api_id.to_s + "?" + TOKEN + app_key
78
-
79
-
80
- field_key_response = HTTParty.get(key_query)
81
-
82
- unless field_key_response["data"] == nil
83
- field_api_key = field_key_response["data"]["key"]
84
- end
85
- end
86
- return field_api_key
87
- end
66
+ # def self.add_field_to_user(app_key, field_name)
67
+ # field_api_key = false
68
+ #
69
+ # input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
70
+ #
71
+ # response = HTTParty.post(input_query,
72
+ # :body => {:name =>"#{field_name}",
73
+ # :field_type => "varchar"},
74
+ # :headers => HEADERS )
75
+ #
76
+ # unless response["data"] == nil
77
+ # field_api_id = response["data"]["id"]
78
+ #
79
+ # key_query = PIPEDRIVE_API + 'personFields/'\
80
+ # + field_api_id.to_s + "?" + TOKEN + app_key
81
+ #
82
+ #
83
+ # field_key_response = HTTParty.get(key_query)
84
+ #
85
+ # unless field_key_response["data"] == nil
86
+ # field_api_key = field_key_response["data"]["key"]
87
+ # end
88
+ # end
89
+ # return field_api_key
90
+ # end
88
91
 
89
92
  #checks if the key is valid and if the custom fields are created in the acc
90
93
  # if any field is missing, create it
91
- def self.assert_fields(fields, app_key)
92
- @field_key = []
93
-
94
- query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
95
-
96
- response = HTTParty.get(query)
97
-
98
- if response["success"]
99
- #Assert: looks for the desired fields
100
- fields.each_with_index do |assert, index|
101
- response["data"].each do |search|
102
- if search['name'] == assert
103
- @field_key[index] = search['key']
104
- end
105
- end
106
- end
107
-
108
- # Integrate: create missing fields
109
- fields.each_with_index do |create, index|
110
- if @field_key[index].blank?
111
- @field_key[index] = create_field(app_key, create)
112
- end
113
- end
114
-
115
- #Hash the info
116
- custom_field = Hash[fields.zip(@field_key.map \
117
- {|i| i.include?(',') ? (i.split /, /) : i})] #/
118
- else
119
- if response["error"] == "You need to be authorized to make this request."
120
- return false
121
- end
122
- end
123
- #ship it back
124
- return custom_field
125
- end
94
+ # def self.assert_fields(fields, app_key)
95
+ # @field_key = []
96
+ #
97
+ # query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
98
+ #
99
+ # response = HTTParty.get(query)
100
+ #
101
+ # if response["success"]
102
+ # #Assert: looks for the desired fields
103
+ # fields.each_with_index do |assert, index|
104
+ # response["data"].each do |search|
105
+ # if search['name'] == assert
106
+ # @field_key[index] = search['key']
107
+ # end
108
+ # end
109
+ # end
110
+ #
111
+ # # Integrate: create missing fields
112
+ # fields.each_with_index do |create, index|
113
+ # if @field_key[index].blank?
114
+ # @field_key[index] = create_field(app_key, create)
115
+ # end
116
+ # end
117
+ #
118
+ # #Hash the info
119
+ # custom_field = Hash[fields.zip(@field_key.map \
120
+ # {|i| i.include?(',') ? (i.split /, /) : i})] #/
121
+ # else
122
+ # if response["error"] == "You need to be authorized to make this request."
123
+ # return false
124
+ # end
125
+ # end
126
+ # #ship it back
127
+ # return custom_field
128
+ # end
126
129
 
127
- ## even if populated the field key will always be replaced
128
- def self.create_field(app_key, field_name)
129
- field_api_key = false
130
-
131
- input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
132
-
133
- response = HTTParty.post(input_query,
134
- :body => {:name =>"#{field_name}",
135
- :field_type => "varchar"},
136
- :headers => HEADERS )
137
-
138
- unless response["data"] == nil
139
- field_api_id = response["data"]["id"]
140
-
141
- key_query = PIPEDRIVE_API + 'personFields/'\
142
- + field_api_id.to_s + "?" + TOKEN + app_key
143
-
144
- field_key_response = HTTParty.get(key_query)
145
-
146
- unless field_key_response["data"] == nil
147
- field_api_key = field_key_response["data"]["key"]
148
- end
149
- end
150
- return field_api_key
151
- end
130
+ # ## even if populated the field key will always be replaced
131
+ # def self.create_field(app_key, field_name)
132
+ # field_api_key = false
133
+ #
134
+ # input_query = PIPEDRIVE_API + 'personFields?' + TOKEN + app_key
135
+ #
136
+ # response = HTTParty.post(input_query,
137
+ # :body => {:name =>"#{field_name}",
138
+ # :field_type => "varchar"},
139
+ # :headers => HEADERS )
140
+ #
141
+ # unless response["data"] == nil
142
+ # field_api_id = response["data"]["id"]
143
+ #
144
+ # key_query = PIPEDRIVE_API + 'personFields/'\
145
+ # + field_api_id.to_s + "?" + TOKEN + app_key
146
+ #
147
+ # field_key_response = HTTParty.get(key_query)
148
+ #
149
+ # unless field_key_response["data"] == nil
150
+ # field_api_key = field_key_response["data"]["key"]
151
+ # end
152
+ # end
153
+ # return field_api_key
154
+ # end
152
155
  end
data/rdgem-0.2.0.gem ADDED
Binary file
data/rdgem-0.2.1.gem ADDED
Binary file
data/rdgem-0.2.2.gem ADDED
Binary file
data/rdgem.gemspec CHANGED
@@ -2,6 +2,9 @@
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
  require 'rdgem/version'
5
+ require 'rdgem/people'
6
+ require 'rdgem/people_fields'
7
+ require 'rdgem/companies'
5
8
 
6
9
  Gem::Specification.new do |spec|
7
10
  spec.name = "rdgem"
@@ -20,5 +23,6 @@ Gem::Specification.new do |spec|
20
23
 
21
24
  spec.add_development_dependency "bundler", "~> 1.9"
22
25
  spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.2"
23
27
  spec.add_dependency('httparty')
24
28
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rdgem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - gabriel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-04-06 00:00:00.000000000 Z
11
+ date: 2015-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.2'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: httparty
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -62,12 +76,17 @@ files:
62
76
  - ".gitignore"
63
77
  - ".travis.yml"
64
78
  - Gemfile
65
- - README.md
66
79
  - Rakefile
67
80
  - bin/console
68
81
  - bin/setup
69
82
  - lib/rdgem.rb
83
+ - lib/rdgem/companies.rb
84
+ - lib/rdgem/people.rb
85
+ - lib/rdgem/people_fields.rb
70
86
  - lib/rdgem/version.rb
87
+ - rdgem-0.2.0.gem
88
+ - rdgem-0.2.1.gem
89
+ - rdgem-0.2.2.gem
71
90
  - rdgem.gemspec
72
91
  homepage: ''
73
92
  licenses: []
data/README.md DELETED
@@ -1,39 +0,0 @@
1
- # Rdgem
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rdgem`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
6
-
7
- ## Installation
8
-
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'rdgem'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
18
-
19
- Or install it yourself as:
20
-
21
- $ gem install rdgem
22
-
23
- ## Usage
24
-
25
- TODO: Write usage instructions here
26
-
27
- ## Development
28
-
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
30
-
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
-
33
- ## Contributing
34
-
35
- 1. Fork it ( https://github.com/[my-github-username]/rdgem/fork )
36
- 2. Create your feature branch (`git checkout -b my-new-feature`)
37
- 3. Commit your changes (`git commit -am 'Add some feature'`)
38
- 4. Push to the branch (`git push origin my-new-feature`)
39
- 5. Create a new Pull Request