contactually-rb 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +19 -0
- data/.gitignore +51 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1158 -0
- data/.travis.yml +6 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +70 -0
- data/LICENSE +21 -0
- data/README.md +76 -0
- data/Rakefile +6 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/contactually-api.gemspec +38 -0
- data/lib/contactually.rb +72 -0
- data/lib/contactually/base.rb +88 -0
- data/lib/contactually/buckets.rb +14 -0
- data/lib/contactually/client.rb +36 -0
- data/lib/contactually/collection.rb +33 -0
- data/lib/contactually/contacts.rb +14 -0
- data/lib/contactually/interface.rb +50 -0
- data/lib/contactually/me.rb +18 -0
- data/lib/contactually/middleware/error_middleware.rb +47 -0
- data/lib/contactually/models/address.rb +17 -0
- data/lib/contactually/models/bucket.rb +17 -0
- data/lib/contactually/models/contact.rb +33 -0
- data/lib/contactually/models/email_address.rb +11 -0
- data/lib/contactually/models/model.rb +95 -0
- data/lib/contactually/models/phone_number.rb +11 -0
- data/lib/contactually/models/social_media_profile.rb +11 -0
- data/lib/contactually/models/tag.rb +13 -0
- data/lib/contactually/models/task.rb +33 -0
- data/lib/contactually/models/user.rb +19 -0
- data/lib/contactually/models/website.rb +11 -0
- data/lib/contactually/response.rb +55 -0
- data/lib/contactually/tags.rb +14 -0
- data/lib/contactually/tasks.rb +14 -0
- data/lib/contactually/version.rb +3 -0
- metadata +197 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
module Contactually
|
2
|
+
module Models
|
3
|
+
class Task
|
4
|
+
include Model
|
5
|
+
|
6
|
+
field :assigned_to_id, :string
|
7
|
+
field :contact_id, :string
|
8
|
+
field :created_at, :datetime
|
9
|
+
field :due_at, :datetime
|
10
|
+
field :id, :string
|
11
|
+
field :title, :string
|
12
|
+
field :updated_at, :datetime
|
13
|
+
|
14
|
+
field :extra_data, Hash
|
15
|
+
|
16
|
+
def contact
|
17
|
+
@contact ||= begin
|
18
|
+
if contact_included?
|
19
|
+
Contact.new(extra_data[CONTACT_KEY])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
CONTACT_KEY = 'contact'.freeze
|
27
|
+
|
28
|
+
def contact_included?
|
29
|
+
extra_data.has_key? CONTACT_KEY
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Contactually
|
2
|
+
module Models
|
3
|
+
class User
|
4
|
+
include Model
|
5
|
+
|
6
|
+
field :avatar_url, :string
|
7
|
+
field :created_at, :datetime
|
8
|
+
field :email, :string
|
9
|
+
field :id, :string
|
10
|
+
field :first_name, :string
|
11
|
+
field :last_name, :string
|
12
|
+
field :role, :string
|
13
|
+
field :status, :string
|
14
|
+
field :updated_at, :datetime
|
15
|
+
|
16
|
+
field :extra_data, Hash
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
module Contactually
|
2
|
+
class Response
|
3
|
+
extend Forwardable
|
4
|
+
|
5
|
+
attr_reader :model_type, :raw_response, :interface
|
6
|
+
|
7
|
+
def_delegator :raw_response, :body
|
8
|
+
def_delegator :raw_response, :headers
|
9
|
+
def_delegator :raw_response, :status
|
10
|
+
|
11
|
+
def initialize(response, resource)
|
12
|
+
@raw_response = response
|
13
|
+
@model_type = resource.model
|
14
|
+
@interface = resource.interface
|
15
|
+
end
|
16
|
+
|
17
|
+
def data
|
18
|
+
@data ||= begin
|
19
|
+
if is_a_collection?
|
20
|
+
collection = raw_data.map { |item| build_from_model_type(item) }
|
21
|
+
|
22
|
+
Collection.new(collection, meta: meta)
|
23
|
+
else
|
24
|
+
build_from_model_type(raw_data)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def raw_data
|
30
|
+
body.fetch(DATA_KEY, {})
|
31
|
+
end
|
32
|
+
|
33
|
+
def errors
|
34
|
+
body.fetch(ERROR_KEY, {})
|
35
|
+
end
|
36
|
+
|
37
|
+
def meta
|
38
|
+
body.fetch(META_KEY, {})
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
DATA_KEY = 'data'.freeze
|
44
|
+
ERROR_KEY = 'errors'.freeze
|
45
|
+
META_KEY = 'meta'.freeze
|
46
|
+
|
47
|
+
def build_from_model_type(item)
|
48
|
+
model_type.new(item)
|
49
|
+
end
|
50
|
+
|
51
|
+
def is_a_collection?
|
52
|
+
raw_data.is_a?(Array)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
metadata
ADDED
@@ -0,0 +1,197 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: contactually-rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nick Blumenthal
|
8
|
+
- Nic Cavigliano
|
9
|
+
autorequire:
|
10
|
+
bindir: exe
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-09-22 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: faraday
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: 0.9.2
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: 0.9.2
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: faraday_middleware
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.10.0
|
35
|
+
type: :runtime
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 0.10.0
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: bundler
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '1.12'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '1.12'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: codeclimate-test-reporter
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 0.6.0
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 0.6.0
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rake
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '10.0'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '10.0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rspec
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '3.0'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.0'
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: pry
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0'
|
112
|
+
- !ruby/object:Gem::Dependency
|
113
|
+
name: webmock
|
114
|
+
requirement: !ruby/object:Gem::Requirement
|
115
|
+
requirements:
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
description: ''
|
127
|
+
email:
|
128
|
+
- nick@realscout.com
|
129
|
+
- ncavig@gmail.com
|
130
|
+
executables: []
|
131
|
+
extensions: []
|
132
|
+
extra_rdoc_files: []
|
133
|
+
files:
|
134
|
+
- ".codeclimate.yml"
|
135
|
+
- ".gitignore"
|
136
|
+
- ".rspec"
|
137
|
+
- ".rubocop.yml"
|
138
|
+
- ".travis.yml"
|
139
|
+
- CODE_OF_CONDUCT.md
|
140
|
+
- Gemfile
|
141
|
+
- Gemfile.lock
|
142
|
+
- LICENSE
|
143
|
+
- README.md
|
144
|
+
- Rakefile
|
145
|
+
- bin/console
|
146
|
+
- bin/setup
|
147
|
+
- contactually-api.gemspec
|
148
|
+
- lib/contactually.rb
|
149
|
+
- lib/contactually/base.rb
|
150
|
+
- lib/contactually/buckets.rb
|
151
|
+
- lib/contactually/client.rb
|
152
|
+
- lib/contactually/collection.rb
|
153
|
+
- lib/contactually/contacts.rb
|
154
|
+
- lib/contactually/interface.rb
|
155
|
+
- lib/contactually/me.rb
|
156
|
+
- lib/contactually/middleware/error_middleware.rb
|
157
|
+
- lib/contactually/models/address.rb
|
158
|
+
- lib/contactually/models/bucket.rb
|
159
|
+
- lib/contactually/models/contact.rb
|
160
|
+
- lib/contactually/models/email_address.rb
|
161
|
+
- lib/contactually/models/model.rb
|
162
|
+
- lib/contactually/models/phone_number.rb
|
163
|
+
- lib/contactually/models/social_media_profile.rb
|
164
|
+
- lib/contactually/models/tag.rb
|
165
|
+
- lib/contactually/models/task.rb
|
166
|
+
- lib/contactually/models/user.rb
|
167
|
+
- lib/contactually/models/website.rb
|
168
|
+
- lib/contactually/response.rb
|
169
|
+
- lib/contactually/tags.rb
|
170
|
+
- lib/contactually/tasks.rb
|
171
|
+
- lib/contactually/version.rb
|
172
|
+
homepage: https://github.com/RealScout/contactually-api
|
173
|
+
licenses: []
|
174
|
+
metadata:
|
175
|
+
allowed_push_host: https://rubygems.org
|
176
|
+
post_install_message:
|
177
|
+
rdoc_options: []
|
178
|
+
require_paths:
|
179
|
+
- lib
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
181
|
+
requirements:
|
182
|
+
- - ">="
|
183
|
+
- !ruby/object:Gem::Version
|
184
|
+
version: '0'
|
185
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - ">="
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
requirements: []
|
191
|
+
rubyforge_project:
|
192
|
+
rubygems_version: 2.5.1
|
193
|
+
signing_key:
|
194
|
+
specification_version: 4
|
195
|
+
summary: ''
|
196
|
+
test_files: []
|
197
|
+
has_rdoc:
|