spark_api 1.4.8 → 1.4.9

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,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NTNkMGYyYTRmYTcwMDNhYzA5MmNiN2IwMGQyNDFlZjJjZGIxN2IwZg==
4
+ NmI5YzI0MDE2Mzk3M2JmYzc3ZDhhOTNlOTkyMmUyNWU1MzcxNWU1Mw==
5
5
  data.tar.gz: !binary |-
6
- YzE0ZGIwNzJmNjg5NDAxN2IzNTI3ZTdmN2JlMWM2MmE1YTQzZTE0MA==
6
+ NTI1Yjk3MWQzNjk4MWYwN2YwNzFlNDdjZTYzNTI4MTQ1ZDQzYmE1OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NzA4MGYyNWQ5YjQyYjU1ZTZjMTIzMmUxNjQzZDJjYmUxY2ViZDhkMGRiMGYx
10
- N2ZmMTZkZGY3Y2M4ZjkxYTA5YmY1Zjg1OWRiODNjMTBlYTM2ZTVkYmU2ZTU1
11
- NTkxZjQ5Y2M2ZTYyN2IyZmFhNzM5ZWJhNzBhMzVjNTZkMDI2ZjQ=
9
+ NWE2MGUxZmIyNTdlYzFkOGVmMGJiYWEzYzVjNjA0M2U5YzI5NmY3Njg5NDgx
10
+ ZGNmZjE5OGFiOTY1OTI5NDIzNmYzOWJmZTNmYThlYzhhYjQwMDI1MzhkZmRi
11
+ YTE1MjlhZTZhNDU3NDZlODRjNTlmNWQwNTBhY2FjMTJhMjQ2YTk=
12
12
  data.tar.gz: !binary |-
13
- NGI3ZTE1NTcxMmU2YjI3ZDMxZTVkZmIxZWFlOWZhMzljNjI5YjRhNjQ0M2Mz
14
- YmJmZDQ4OTUxZTliMjRiZjY5ODBkNjVmMTFjZjdlYzEyY2RhZWExNTI4N2Nk
15
- NjU1ZTVmZTIwNWMxN2VlOTkwNTg5N2JiZDZmZDJmYWQ5NzA1Yzc=
13
+ Zjg4MzFjNGI2NTAwNWU5MTcwZmVkMWMwNzQ4MzdlZWUwZjA5MzcxNDRmZTNh
14
+ YzdhODc5NmZhYzM3Mjg5YjA5ZDhmMzA1NDA0OTI1YTVkMTRhOGIxMTYwMzRm
15
+ MWUzNTcxNmZkOGQ5ZjljOGU5YWUwMDM1ZDVjMGJjNzc1MWExN2M=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.4.8
1
+ 1.4.9
@@ -7,6 +7,8 @@ require 'spark_api/models/subresource'
7
7
  require 'spark_api/models/concerns'
8
8
 
9
9
  require 'spark_api/models/account'
10
+ require 'spark_api/models/account_report'
11
+ require 'spark_api/models/account_roster'
10
12
  require 'spark_api/models/activity'
11
13
  require 'spark_api/models/connect_prefs'
12
14
  require 'spark_api/models/contact'
@@ -0,0 +1,31 @@
1
+ module SparkApi
2
+ module Models
3
+ class AccountReport < Account
4
+ def self.report(account_id, arguments={})
5
+ collect(connection.get("/accounts/#{account_id}/report", arguments)).first
6
+ end
7
+
8
+ def DisplayName
9
+ self.Name
10
+ end
11
+
12
+ def primary_email
13
+ if Array(emails).any? && emails.primary
14
+ emails.primary.Address
15
+ end
16
+ end
17
+
18
+ def primary_phone
19
+ if Array(phones).any? && phones.primary
20
+ phones.primary.Number
21
+ end
22
+ end
23
+
24
+ def logo
25
+ if images.kind_of? Array
26
+ images.find { |image| image.Type == "Logo" }
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,9 @@
1
+ module SparkApi
2
+ module Models
3
+ class AccountRoster < Account
4
+ def self.roster(account_id, arguments={})
5
+ collect(connection.get("/accounts/#{account_id}/roster", arguments)).first
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,77 @@
1
+ require './spec/spec_helper'
2
+
3
+ describe AccountReport do
4
+
5
+ let(:account_report) {
6
+ AccountReport.new({
7
+ "Id" => "12345",
8
+ "Name" => "Agent McAgentson",
9
+ "Office" => "Office Name",
10
+ "Emails"=> [],
11
+ "Phones"=> [],
12
+ "Websites"=> [],
13
+ "Addresses"=> []
14
+ })
15
+ }
16
+
17
+ describe 'primary_email' do
18
+
19
+ it 'returns the primary email address' do
20
+ account_report.emails << double(:Address => 'foo@foo.com', :primary? => true)
21
+ expect(account_report.primary_email).to eq account_report.emails.primary.Address
22
+ end
23
+
24
+ it 'returns nil when there is no primary email address' do
25
+ account_report.emails << double(:Address => 'foo@foo.com', :primary? => false)
26
+ expect(account_report.primary_email).to eq nil
27
+ end
28
+
29
+ it 'returns nil when there are no email addresses' do
30
+ allow(account_report).to receive(:emails).and_return nil
31
+ expect(account_report.primary_email).to eq nil
32
+ end
33
+
34
+ end
35
+
36
+ describe 'primary_phone' do
37
+
38
+ it 'returns the primary phone number' do
39
+ account_report.phones << double(:Number => '88', :primary? => true)
40
+ expect(account_report.primary_phone).to eq account_report.phones.primary.Number
41
+ end
42
+
43
+ it 'returns nil when there is no primary phone number' do
44
+ account_report.phones << double(:Number => '88', :primary? => false)
45
+ expect(account_report.primary_phone).to eq nil
46
+ end
47
+
48
+ it 'returns nil when there are no phone numbers' do
49
+ allow(account_report).to receive(:phones).and_return nil
50
+ expect(account_report.primary_phone).to eq nil
51
+ end
52
+
53
+ end
54
+
55
+ describe 'logo' do
56
+
57
+ it 'returns the logo' do
58
+ logo = SparkApi::Models::Base.new( {"Type" => "Logo"} )
59
+ not_logo = SparkApi::Models::Base.new( {"Type" => "Nope" } )
60
+ account_report.images = [logo, not_logo]
61
+ expect(account_report.logo).to be logo
62
+ end
63
+
64
+ it 'returns nil if there is no logo' do
65
+ not_logo = SparkApi::Models::Base.new( {"Type" => "Nope" } )
66
+ account_report.images = [not_logo]
67
+ expect(account_report.logo).to be nil
68
+ end
69
+
70
+ it 'returns nil if there are no images' do
71
+ expect(account_report.images).to be nil
72
+ expect(account_report.logo).to be nil
73
+ end
74
+
75
+ end
76
+
77
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spark_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.8
4
+ version: 1.4.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Hornseth
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-12-27 00:00:00.000000000 Z
12
+ date: 2017-01-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -317,6 +317,8 @@ files:
317
317
  - lib/spark_api/faraday_middleware.rb
318
318
  - lib/spark_api/models.rb
319
319
  - lib/spark_api/models/account.rb
320
+ - lib/spark_api/models/account_report.rb
321
+ - lib/spark_api/models/account_roster.rb
320
322
  - lib/spark_api/models/activity.rb
321
323
  - lib/spark_api/models/base.rb
322
324
  - lib/spark_api/models/comment.rb
@@ -518,6 +520,7 @@ files:
518
520
  - spec/unit/spark_api/configuration/yaml_spec.rb
519
521
  - spec/unit/spark_api/configuration_spec.rb
520
522
  - spec/unit/spark_api/faraday_middleware_spec.rb
523
+ - spec/unit/spark_api/models/account_report_spec.rb
521
524
  - spec/unit/spark_api/models/account_spec.rb
522
525
  - spec/unit/spark_api/models/activity_spec.rb
523
526
  - spec/unit/spark_api/models/base_spec.rb
@@ -749,6 +752,7 @@ test_files:
749
752
  - spec/unit/spark_api/models/account_spec.rb
750
753
  - spec/unit/spark_api/models/listing_spec.rb
751
754
  - spec/unit/spark_api/models/video_spec.rb
755
+ - spec/unit/spark_api/models/account_report_spec.rb
752
756
  - spec/unit/spark_api/models/sort_spec.rb
753
757
  - spec/unit/spark_api/models/saved_search_spec.rb
754
758
  - spec/unit/spark_api/models/contact_spec.rb