tops_connect 0.1.3 → 0.1.4

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: c12dc89e03b14593d72f2eb5e7d784b39ee2c994
4
- data.tar.gz: 1432be52961935df235d278c6b068139414c7395
3
+ metadata.gz: 88806cf795346b8b63cbf0ea928fed4f6605b5df
4
+ data.tar.gz: 1dc68fd22180ba05ec4b12ddabe2d480149fd8ae
5
5
  SHA512:
6
- metadata.gz: a39e2abd5217e9c3dce0177f67d08a59cf53a35416bf48dc57ae66fec2d66aa0c06b0013e54ab6fe665e2ccd62480ed63c925ff1469f2bb2d94763287e584fa5
7
- data.tar.gz: 85ebb9698513db3964d6a5c14f3e9b02fe6a1befefa09700c05aa945ac2a88ca219f7933ea980928825bf89de94f5e929d9f73551dc8fd5cbc9fe81a07ca8ea8
6
+ metadata.gz: e46fe7e62ec1b245523965b72f1d87ad8f4e8b72e9fbc9843b649b4bf84ed4d017734d825cf7429801f2144f0a0a94272d4b0552aef04f1541de52d28c7553dd
7
+ data.tar.gz: 56e3910e297e441ecf19430ad9c35a364f546e32afdf6e04628c46de0204c9fd46c3a4d6528fbff0e2d5474974b68520d36ebff6da85d1806238c6da94abd32f
data/lib/tops_connect.rb CHANGED
@@ -7,6 +7,7 @@ require 'tops_connect/communities'
7
7
  require 'tops_connect/owners'
8
8
 
9
9
  require 'tops_connect/base'
10
+ require 'tops_connect/community'
10
11
  require 'tops_connect/owner'
11
12
 
12
13
  require 'tops_connect/configuration'
@@ -4,13 +4,15 @@ module TopsConnect
4
4
  # Method: GET
5
5
  # Endpoint: Community_GetList
6
6
  def communities
7
- get '/community'
7
+ get('/community').map do |community|
8
+ TopsConnect::Community.new community['CommunityKey'], community
9
+ end
8
10
  end
9
11
 
10
12
  # Method: GET
11
13
  # Endpoint: Community_Get
12
14
  def community(community_id)
13
- get "/community/#{community_id.to_i}"
15
+ TopsConnect::Community.new community_id
14
16
  end
15
17
  end
16
18
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+ module TopsConnect
3
+ class Community < Base
4
+ attr_reader :id
5
+
6
+ def initialize(id, data = nil)
7
+ @id = id.to_i
8
+ @data = data
9
+ end
10
+
11
+ def data
12
+ @data || reload!
13
+ end
14
+
15
+ def reload!
16
+ @data = get "/community/#{@id}"
17
+ end
18
+
19
+ def code
20
+ data['CommunityID']
21
+ end
22
+
23
+ def name
24
+ data['Name']
25
+ end
26
+
27
+ def city
28
+ data['DefaultCity']
29
+ end
30
+
31
+ def state
32
+ data['DefaultState']
33
+ end
34
+
35
+ def zip
36
+ data['DefaultZip']
37
+ end
38
+
39
+ def last_synced_at
40
+ DateTime.parse data['LastSyncTime'] if data['LastSyncTime']
41
+ end
42
+
43
+ def updated_at
44
+ return nil unless data['Metadata']['ModifiedDate']
45
+
46
+ DateTime.parse data['Metadata']['ModifiedDate']
47
+ end
48
+
49
+ # Method: GET
50
+ # Endpoint: ChargeCode_GetList
51
+ def charge_codes
52
+ get('/chargecode').map do |charge_code|
53
+ {
54
+ key: charge_code['ChargeCodeKey'],
55
+ code: charge_code['Code'],
56
+ description: charge_code['Description']
57
+ }
58
+ end
59
+ end
60
+ end
61
+ end
@@ -9,7 +9,11 @@ module TopsConnect
9
9
  end
10
10
 
11
11
  def data
12
- @data ||= get "/owner/#{@id}"
12
+ @data || reload!
13
+ end
14
+
15
+ def reload!
16
+ @data = get "/owner/#{@id}"
13
17
  end
14
18
 
15
19
  def alternate_mailing_addresses
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module TopsConnect
3
- VERSION = '0.1.3'
3
+ VERSION = '0.1.4'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tops_connect
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Hoffman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-04 00:00:00.000000000 Z
11
+ date: 2016-04-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,6 +100,7 @@ files:
100
100
  - lib/tops_connect/base.rb
101
101
  - lib/tops_connect/client.rb
102
102
  - lib/tops_connect/communities.rb
103
+ - lib/tops_connect/community.rb
103
104
  - lib/tops_connect/configuration.rb
104
105
  - lib/tops_connect/owner.rb
105
106
  - lib/tops_connect/owners.rb