dotloop-ruby 0.1.7 → 0.1.8

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
- SHA1:
3
- metadata.gz: 6f243206bbd7e8534d8584bfae61e8feb6aac5d0
4
- data.tar.gz: e834d7898d84910a106ea0c305dc424e3bcd0b88
2
+ SHA256:
3
+ metadata.gz: 7884459d70d1f78417e6c3cee8e0b7221e4381fe7cca5be5590d57e5816b78c1
4
+ data.tar.gz: b1e7ce24efec71e5b26fd30075a3d4049ccb0896583d81213f86b1215da888e0
5
5
  SHA512:
6
- metadata.gz: c816eab21937a748587da7e08697af8b6bc1f3c1ae234d7164242e84fd2595efe358f9c41b1c97d486b7f1b0fef69645b93f9df76b4e1c64022f8074cb440783
7
- data.tar.gz: c09982a87eda21bf3ecdb72761d915e799a85c3f7309977d014053d09a92aa9ff7e0bc30858314e9a97308fd3cf021e9ae9e6f0ed3fd95e5776269cdfd83d3a8
6
+ metadata.gz: e06a7edb641a94d793bb3da25003140ca449517bfb9a8d0e0b1f1817432689c3050dbf99ceaf8d9f8f2ccd03da6ed8a140f35c496dde1716c5214922cea0aad6
7
+ data.tar.gz: c57f2d3ea23fabd1ed1d8bcd6b4abe8d99ef70a2f845dd2bebef88173d02a3a13d5142d79972102fe0226908fac363475f517dff9ed669ffcf7e9b787af2bc7d
data/.gitignore CHANGED
@@ -10,3 +10,5 @@
10
10
 
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
+ .byebug_history
14
+ .DS_Store
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Ruby library for Dotloop API v2
2
2
 
3
+ [![Build Status](https://semaphoreci.com/api/v1/sampat-badhe/dotloop-ruby/branches/master/badge.svg)](https://semaphoreci.com/sampat-badhe/dotloop-ruby)
4
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/a03408e2791211b8b816/test_coverage)](https://codeclimate.com/github/sampatbadhe/dotloop-ruby/test_coverage)
5
+
3
6
  * [Homepage](https://www.dotloop.com)
4
7
  * [API Documentation](https://dotloop.github.io/public-api)
5
8
  * [Sign Up](https://www.dotloop.com/#/signup)
@@ -280,7 +283,15 @@ Dotloop uses OAuth2 for authentication (https://dotloop.github.io/public-api/#au
280
283
  params = {
281
284
  "fullName": "Brian Erwin",
282
285
  "email": "brian@gmail.com",
283
- "role": "BUYER"
286
+ "role": "BUYER",
287
+ "Street Name": "123",
288
+ "Street Number": "Main St.",
289
+ "City": "Cincinnati",
290
+ "Zip/Postal Code": "45123",
291
+ "Country": "USA",
292
+ "Phone": "(555) 555-5555",
293
+ "Cell Phone": "(555) 555-4444",
294
+ "Company Name": "Buyer's Company"
284
295
  }
285
296
 
286
297
  #=> update participant
@@ -391,8 +402,9 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
391
402
 
392
403
  Bug reports and pull requests are welcome on GitHub at https://github.com/sampatbadhe/dotloop-ruby.
393
404
 
394
-
395
405
  ## License
396
406
 
397
407
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
398
408
 
409
+ ## Statement
410
+ `dotloop-ruby` part of reference [Loft47/dotloop](https://github.com/Loft47/dotloop) project.
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require "bundler/setup"
4
- require "dotloop"
4
+ require "dotloop-ruby"
5
5
 
6
6
  # You can add fixtures and/or initialization code here to make experimenting
7
7
  # with your gem easier. You can also use a different console, if you like.
@@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
32
32
 
33
33
  spec.add_runtime_dependency 'httparty', '~> 0.13'
34
34
  spec.add_runtime_dependency 'virtus', '~> 1.0'
35
- spec.add_runtime_dependency 'plissken', '~> 0.2'
35
+ spec.add_runtime_dependency 'plissken', '~> 1.2'
36
36
  spec.add_development_dependency 'bundler', '~> 1.14'
37
37
  spec.add_development_dependency 'rake', '~> 10.0'
38
38
  spec.add_development_dependency 'rspec', '~> 3.0'
@@ -6,6 +6,7 @@ require 'dotloop/version'
6
6
  require 'dotloop/authenticate'
7
7
  require 'dotloop/client'
8
8
  require 'dotloop/query_param_helpers'
9
+ require 'dotloop/parse_data'
9
10
  require 'dotloop/contact'
10
11
  require 'dotloop/document'
11
12
  require 'dotloop/exceptions'
@@ -116,14 +116,24 @@ module Dotloop
116
116
 
117
117
  def self.snakify(hash)
118
118
  if hash.is_a? Array
119
- hash.map(&:to_snake_keys)
119
+ hash.map{ |item| symbolize(item.to_snake_keys) }
120
120
  else
121
- hash.to_snake_keys
121
+ symbolize(hash.to_snake_keys)
122
122
  end
123
123
  end
124
124
 
125
125
  private
126
126
 
127
+ def self.symbolize(obj)
128
+ return obj.reduce({}) do |memo, (k, v)|
129
+ memo.tap { |m| m[k.to_sym] = symbolize(v) }
130
+ end if obj.is_a? Hash
131
+ return obj.reduce([]) do |memo, v|
132
+ memo << symbolize(v); memo
133
+ end if obj.is_a? Array
134
+ obj
135
+ end
136
+
127
137
  def download_headers
128
138
  {
129
139
  'Authorization' => "Bearer #{@access_token}",
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Dotloop
4
4
  class LoopDetail
5
+ include Dotloop::ParseData
5
6
  attr_accessor :details
6
7
  FIXED_SECTIONS = %i[
7
8
  contract_dates contract_info financials geographic_description
@@ -13,26 +14,10 @@ module Dotloop
13
14
  parse_data(data)
14
15
  end
15
16
 
16
- def parse_data(data)
17
- fix_hash_keys(data).each { |item| build_section(item[0], item[1]) }
18
- end
19
-
20
17
  private
21
18
 
22
- def build_section(key, section_data)
23
- return unless FIXED_SECTIONS.include?(key)
24
- values = fix_hash_keys(section_data)
25
- @details[key] = values
26
- end
27
-
28
- def index_to_key(index)
29
- index.to_s.downcase.delete(%(')).gsub(/%/, ' percent ').gsub(/\$/, ' doller ').gsub(/[^a-z]/, '_').squeeze('_').gsub(/^_*/, '').gsub(/_*$/, '').to_sym
30
- end
31
-
32
- def fix_hash_keys(bad_hash)
33
- bad_hash.each_with_object({}) do |item, memo|
34
- memo[index_to_key(item[0])] = item[1]
35
- end
19
+ def fields
20
+ FIXED_SECTIONS
36
21
  end
37
22
  end
38
23
  end
@@ -4,14 +4,24 @@ module Dotloop
4
4
  module Models
5
5
  class Participant
6
6
  include Virtus.model
7
+ attribute :cell_phone
8
+ attribute :city
9
+ attribute :company_name
10
+ attribute :country
7
11
  attribute :email
8
12
  attribute :full_name
9
13
  attribute :id, Integer
14
+ attribute :phone
10
15
  attribute :role
16
+ attribute :state_prov
17
+ attribute :street_name
18
+ attribute :street_number
19
+ attribute :unit_number
20
+ attribute :zip_postal_code
11
21
 
12
22
  attr_accessor :client
13
- attr_accessor :profile_id
14
23
  attr_accessor :loop_id
24
+ attr_accessor :profile_id
15
25
  end
16
26
  end
17
27
  end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Dotloop
4
+ module ParseData
5
+ def parse_data(data)
6
+ fix_hash_keys(data).each { |item| build_section(item[0], item[1]) }
7
+ end
8
+
9
+ private
10
+
11
+ def build_section(key, section_data)
12
+ return unless fields.include?(key)
13
+ values = fix_hash_keys(section_data)
14
+ @details[key] = values
15
+ end
16
+
17
+ def index_to_key(index)
18
+ index.to_s.downcase.delete(%(')).gsub(/%/, ' percent ').gsub(/\$/, ' doller ').gsub(/[^a-z]/, '_').squeeze('_').gsub(/^_*/, '').gsub(/_*$/, '').to_sym
19
+ end
20
+
21
+ def fix_hash_keys(bad_hash)
22
+ bad_hash.each_with_object({}) do |item, memo|
23
+ memo[index_to_key(item[0])] = item[1]
24
+ end
25
+ end
26
+ end
27
+ end
@@ -2,9 +2,24 @@
2
2
 
3
3
  module Dotloop
4
4
  class Participant
5
+ include Dotloop::ParseData
5
6
  attr_accessor :client
6
7
 
7
- PARTICIPANT_FIELDS = %w[fullName email role].freeze
8
+ PARTICIPANT_FIELDS = [
9
+ 'fullName',
10
+ 'email',
11
+ 'role',
12
+ 'Street Name',
13
+ 'Street Number',
14
+ 'City',
15
+ 'State/Prov',
16
+ 'Zip/Postal Code',
17
+ 'Unit Number',
18
+ 'Country',
19
+ 'Phone',
20
+ 'Cell Phone',
21
+ 'Company Name'
22
+ ].freeze
8
23
 
9
24
  def initialize(client:)
10
25
  @client = client
@@ -12,6 +27,7 @@ module Dotloop
12
27
 
13
28
  def all(profile_id:, loop_id:)
14
29
  @client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant")[:data].map do |participant_attrs|
30
+ participant_data = parse_data(participant_attrs)
15
31
  participant = Dotloop::Models::Participant.new(participant_attrs)
16
32
  participant.client = client
17
33
  participant.profile_id = profile_id.to_i
@@ -22,6 +38,7 @@ module Dotloop
22
38
 
23
39
  def find(profile_id:, loop_id:, participant_id:)
24
40
  participant_data = @client.get("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}")[:data]
41
+ participant_data = parse_data(participant_data)
25
42
  participant = Dotloop::Models::Participant.new(participant_data)
26
43
  participant.client = client
27
44
  participant.profile_id = profile_id.to_i
@@ -35,8 +52,8 @@ module Dotloop
35
52
  PARTICIPANT_FIELDS.include?(key.to_s) || next
36
53
  data[key] = value.to_s
37
54
  end
38
-
39
55
  participant_data = @client.post("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant", data)[:data]
56
+ participant_data = parse_data(participant_data)
40
57
  participant = Dotloop::Models::Participant.new(participant_data)
41
58
  participant.client = client
42
59
  participant.profile_id = profile_id.to_i
@@ -50,8 +67,8 @@ module Dotloop
50
67
  PARTICIPANT_FIELDS.include?(key.to_s) || next
51
68
  data[key] = value.to_s
52
69
  end
53
-
54
70
  participant_data = @client.patch("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}", data)[:data]
71
+ participant_data = parse_data(participant_data)
55
72
  participant = Dotloop::Models::Participant.new(participant_data)
56
73
  participant.client = client
57
74
  participant.profile_id = profile_id.to_i
@@ -62,5 +79,11 @@ module Dotloop
62
79
  def delete(profile_id:, loop_id:, participant_id:)
63
80
  @client.delete("/profile/#{profile_id.to_i}/loop/#{loop_id.to_i}/participant/#{participant_id.to_i}")
64
81
  end
82
+
83
+ private
84
+
85
+ def fields
86
+ PARTICIPANT_FIELDS
87
+ end
65
88
  end
66
89
  end
@@ -1,3 +1,3 @@
1
1
  module Dotloop
2
- VERSION = "0.1.7"
2
+ VERSION = "0.1.8"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dotloop-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - sampatbadhe
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-17 00:00:00.000000000 Z
11
+ date: 2019-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0.2'
47
+ version: '1.2'
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: '0.2'
54
+ version: '1.2'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -241,6 +241,7 @@ files:
241
241
  - lib/dotloop/models/task.rb
242
242
  - lib/dotloop/models/tasklist.rb
243
243
  - lib/dotloop/models/template.rb
244
+ - lib/dotloop/parse_data.rb
244
245
  - lib/dotloop/participant.rb
245
246
  - lib/dotloop/profile.rb
246
247
  - lib/dotloop/query_param_helpers.rb
@@ -268,8 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
268
269
  - !ruby/object:Gem::Version
269
270
  version: '0'
270
271
  requirements: []
271
- rubyforge_project:
272
- rubygems_version: 2.6.14
272
+ rubygems_version: 3.0.3
273
273
  signing_key:
274
274
  specification_version: 4
275
275
  summary: Dotloop library