lib/tops_connect/community.rb in tops_connect-0.2.0 vs lib/tops_connect/community.rb in tops_connect-0.3.0

- old
+ new

@@ -1,24 +1,19 @@ # frozen_string_literal: true module TopsConnect - class Community < Base - attr_reader :id + class Community + attr_reader :data - def initialize(client, data = nil) + def initialize(data) @data = data - - super client end - def data - @data || reload! + def id + data['CommunityKey'] end + alias community_key id - def reload! - @data = get "/community/#{@client.community_id}" - end - def code data['CommunityID'] end def name @@ -40,23 +35,12 @@ def last_synced_at DateTime.parse data['LastSyncTime'] if data['LastSyncTime'] end def updated_at - return nil unless data['Metadata']['ModifiedDate'] + return unless data['Metadata']['ModifiedDate'] DateTime.parse data['Metadata']['ModifiedDate'] end - - # Method: GET - # Endpoint: ChargeCode_GetList - def charge_codes - get('/chargecode').map do |charge_code| - { - key: charge_code['ChargeCodeKey'], - code: charge_code['Code'], - description: charge_code['Description'] - } - end - end + alias modified_date updated_at end end