green-button-data 0.2.1 → 0.3.0
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 +13 -5
 - data/README.md +116 -8
 - data/green-button-data.gemspec +6 -1
 - data/lib/green-button-data.rb +26 -1
 - data/lib/green-button-data/application_information.rb +112 -0
 - data/lib/green-button-data/authorization.rb +35 -0
 - data/lib/green-button-data/configuration.rb +133 -0
 - data/lib/green-button-data/core_ext.rb +1 -0
 - data/lib/green-button-data/core_ext/string.rb +35 -0
 - data/lib/green-button-data/dst.rb +57 -0
 - data/lib/green-button-data/entry.rb +87 -0
 - data/lib/green-button-data/feed.rb +5 -0
 - data/lib/green-button-data/fetchable.rb +242 -0
 - data/lib/green-button-data/interval_block.rb +38 -0
 - data/lib/green-button-data/local_time_parameters.rb +31 -0
 - data/lib/green-button-data/meter_reading.rb +4 -0
 - data/lib/green-button-data/model_collection.rb +33 -0
 - data/lib/green-button-data/parser/application_information.rb +2 -11
 - data/lib/green-button-data/parser/authorization.rb +0 -4
 - data/lib/green-button-data/parser/interval.rb +8 -4
 - data/lib/green-button-data/parser/interval_reading.rb +4 -1
 - data/lib/green-button-data/parser/local_time_parameters.rb +0 -57
 - data/lib/green-button-data/parser/summary_measurement.rb +12 -0
 - data/lib/green-button-data/reading_type.rb +82 -0
 - data/lib/green-button-data/relations.rb +24 -0
 - data/lib/green-button-data/usage_point.rb +27 -0
 - data/lib/green-button-data/usage_summary.rb +36 -0
 - data/lib/green-button-data/utilities.rb +27 -0
 - data/lib/green-button-data/version.rb +1 -1
 - data/spec/fixtures.rb +5 -0
 - data/spec/fixtures/ESPIReadingType.xml +23 -535
 - data/spec/fixtures/ESPIReadingTypes.xml +535 -0
 - data/spec/fixtures/ESPIUsagePoint.xml +3 -3
 - data/spec/fixtures/ESPIUsagePointMeterReading.xml +13 -0
 - data/spec/fixtures/ESPIUsagePointMeterReadings.xml +21 -0
 - data/spec/fixtures/ESPIUsagePoints.xml +822 -0
 - data/spec/lib/green-button-data/application_information_spec.rb +389 -0
 - data/spec/lib/green-button-data/authorization_spec.rb +91 -0
 - data/spec/{green-button-data → lib/green-button-data}/core_ext/date_spec.rb +0 -0
 - data/spec/{green-button-data → lib/green-button-data}/core_ext/fixnum_spec.rb +0 -0
 - data/spec/lib/green-button-data/local_time_parameters_spec.rb +106 -0
 - data/spec/{green-button-data → lib/green-button-data}/parser/application_information_spec.rb +4 -4
 - data/spec/{green-button-data → lib/green-button-data}/parser/authorization_spec.rb +0 -12
 - data/spec/{green-button-data → lib/green-button-data}/parser/entry_spec.rb +1 -1
 - data/spec/{green-button-data → lib/green-button-data}/parser/interval_block_spec.rb +4 -4
 - data/spec/{green-button-data → lib/green-button-data}/parser/local_time_parameter_spec.rb +0 -0
 - data/spec/{green-button-data → lib/green-button-data}/parser/reading_type_spec.rb +0 -0
 - data/spec/{green-button-data → lib/green-button-data}/parser/usage_point_spec.rb +0 -0
 - data/spec/{green-button-data → lib/green-button-data}/parser/usage_summary_spec.rb +0 -0
 - data/spec/lib/green-button-data/reading_type_spec.rb +127 -0
 - data/spec/lib/green-button-data/usage_point_spec.rb +167 -0
 - data/spec/{green-button-data → lib/green-button-data}/utilities_spec.rb +1 -1
 - data/spec/spec_helper.rb +5 -0
 - metadata +70 -17
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
      
 2 
     | 
    
         
            +
            !binary "U0hBMQ==":
         
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 4 
     | 
    
         
            +
                MGE1ZDYxMWY2OWQ5ZjdiZTk1OWM2ZmEzZTdhMzg5OGVhMzRkZDk5Mw==
         
     | 
| 
      
 5 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 6 
     | 
    
         
            +
                M2I1ZjllMGUzOWEzMjk5MDgwODY0YjFiYTQxY2Y4M2Y2NTA0ZWNhZQ==
         
     | 
| 
       5 
7 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
      
 8 
     | 
    
         
            +
              metadata.gz: !binary |-
         
     | 
| 
      
 9 
     | 
    
         
            +
                YmVkYzZjMzFmNDYwMzY4NTE5MzM0ZGU3MTkzODI4ZjdjMDUwMGUzYjRiZjQ0
         
     | 
| 
      
 10 
     | 
    
         
            +
                ZjcwYzY3ZjYzOTJlNzE2YTYwYmY1OTVjMWQ2NTdmODQ1MTA1ZDg0MDhjM2Ni
         
     | 
| 
      
 11 
     | 
    
         
            +
                MjhjNTJiYzhlYzVmYTY4ZTFlZWM4YmUxZWE2ODA4ZTU5MjJmMjQ=
         
     | 
| 
      
 12 
     | 
    
         
            +
              data.tar.gz: !binary |-
         
     | 
| 
      
 13 
     | 
    
         
            +
                YmM1OTAzZjE4OTIzMzg4ZDQ5YWIxMWViY2ZjOGQ1M2RkMDc3ODY5ZTRlNDg0
         
     | 
| 
      
 14 
     | 
    
         
            +
                OWU5YzQwNzUwMjQ0OWEwNzZlMjJmMzJmY2RhNDNkODllNTI3Y2NjZDE1NTQ1
         
     | 
| 
      
 15 
     | 
    
         
            +
                NmZiMWJjMWI1YmE4YTc1MzNkZTgwNjUyNTJlYmVmOWJjNzZjZTc=
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,15 +1,15 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Green Button Data
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            [](https://circleci.com/gh/VerdigrisTech/green-button-data)
         
     | 
| 
       4 
3 
     | 
    
         
             
            [](https://rubygems.org/gems/green-button-data)
         
     | 
| 
      
 4 
     | 
    
         
            +
            [](https://circleci.com/gh/VerdigrisTech/green-button-data)
         
     | 
| 
       5 
5 
     | 
    
         
             
            [](https://gemnasium.com/VerdigrisTech/green-button-data)
         
     | 
| 
       6 
     | 
    
         
            -
            [](https://codecov.io/github/VerdigrisTech/green-button-data)
         
     | 
| 
       7 
6 
     | 
    
         
             
            [](https://codeclimate.com/github/VerdigrisTech/green-button-data)
         
     | 
| 
      
 7 
     | 
    
         
            +
            [](https://codecov.io/github/VerdigrisTech/green-button-data)
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
            Green Button Data is a Ruby gem that can  
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
            in memory.
         
     | 
| 
      
 9 
     | 
    
         
            +
            Green Button Data is a Ruby gem that can consume Green Button APIs and parse
         
     | 
| 
      
 10 
     | 
    
         
            +
            the Green Button data XML schema very quickly. It uses an event-driven
         
     | 
| 
      
 11 
     | 
    
         
            +
            <abbr title="Simple API for XML">SAX</abbr> parser which parses XML data without
         
     | 
| 
      
 12 
     | 
    
         
            +
            building an entire <abbr title="Document Object Model">DOM</abbr> in memory.
         
     | 
| 
       13 
13 
     | 
    
         | 
| 
       14 
14 
     | 
    
         
             
            ## Getting Started
         
     | 
| 
       15 
15 
     | 
    
         | 
| 
         @@ -25,7 +25,100 @@ Then run Bundler: 
     | 
|
| 
       25 
25 
     | 
    
         
             
            $ bundle
         
     | 
| 
       26 
26 
     | 
    
         
             
            ```
         
     | 
| 
       27 
27 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
      
 28 
     | 
    
         
            +
            Unless you have a project that auto loads all gems in the Gemfile (e.g. a Rails
         
     | 
| 
      
 29 
     | 
    
         
            +
            project), you will need to require it:
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 32 
     | 
    
         
            +
            require 'green-button-data'
         
     | 
| 
      
 33 
     | 
    
         
            +
            ```
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            This will expose the GreenButtonData module namespace.
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            ## Integrating GreenButtonData Into Your Application
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
            GreenButtonData gem provides a familiar interface to consuming API endpoints.
         
     | 
| 
      
 40 
     | 
    
         
            +
            Method names are similar to Rails' ActiveRecord models and can be easily
         
     | 
| 
      
 41 
     | 
    
         
            +
            integrated into existing applications.
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
            ### Configuration
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            You can add configuration options like the following:
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 48 
     | 
    
         
            +
            GreenButtonData.configure do |config|
         
     | 
| 
      
 49 
     | 
    
         
            +
              config.base_url = "https://api.example.com/DataCustodian/espi/1_1/resource/"
         
     | 
| 
      
 50 
     | 
    
         
            +
              config.application_information_path = "ApplicationInformation/"
         
     | 
| 
      
 51 
     | 
    
         
            +
              config.authorization_path = "Authorization/"
         
     | 
| 
      
 52 
     | 
    
         
            +
              config.subscription_path = "Subscription/"
         
     | 
| 
      
 53 
     | 
    
         
            +
              config.usage_point_path = "UsagePoint/"
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
| 
      
 55 
     | 
    
         
            +
            ```
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            Note that each path _must_ end with a trailing slash.
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
            #### Rails Integration
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
            If you are developing a Rails app, create a file at
         
     | 
| 
      
 62 
     | 
    
         
            +
            `config/initializers/green_button_data.rb` from your Rails project root and
         
     | 
| 
      
 63 
     | 
    
         
            +
            add the configuration there.
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
            ## Green Button Data API Client
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            Green Button Data specification states that all API endpoints be secured with
         
     | 
| 
      
 68 
     | 
    
         
            +
            OAuth2 which means most fetch operations will require auth tokens.
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
            Some endpoints are secured further by utilizing client SSL certificates (e.g.
         
     | 
| 
      
 71 
     | 
    
         
            +
            Pacific Gas & Electric). You may pass in `ssl` options in addition to
         
     | 
| 
      
 72 
     | 
    
         
            +
            the `token` option in this case.
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
            > **DISCLAIMER:** Green Button Data is **_NOT_** responsible for managing OAuth
         
     | 
| 
      
 75 
     | 
    
         
            +
            tokens to make authenticated requests. There are other gems that provide mature,
         
     | 
| 
      
 76 
     | 
    
         
            +
            production proven OAuth 2 functionalities such as [OmniAuth](https://github.com/intridea/omniauth).
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
            ### List all entries
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
            By default, the `.all` method attempts to use the URL path set by configuration:
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 83 
     | 
    
         
            +
            require 'green-button-data'
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            # Ideally obtained from OmniAuth gem
         
     | 
| 
      
 86 
     | 
    
         
            +
            access_token = "12345678-1024-2048-abcdef001234"
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
            # Return all usage points; URL is specified in GreenButtonData.configuration.usage_point_url
         
     | 
| 
      
 89 
     | 
    
         
            +
            usage_points = UsagePoint.all token: access_token
         
     | 
| 
      
 90 
     | 
    
         
            +
            ```
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
            You may override the global configuration by specifying the URL in the method:
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 95 
     | 
    
         
            +
            usage_points = UsagePoint.all "https://someotherapi.org/espi/Authorization",
         
     | 
| 
      
 96 
     | 
    
         
            +
                                          token: access_token
         
     | 
| 
      
 97 
     | 
    
         
            +
            ```
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
            ### Find an entry by ID
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            If you have URL defined in configuration, the `.find` method appends the ID to
         
     | 
| 
      
 102 
     | 
    
         
            +
            the URL:
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 105 
     | 
    
         
            +
            GreenButtonData.configure do |config|
         
     | 
| 
      
 106 
     | 
    
         
            +
              config.base_url = "https://services.greenbuttondata.org/"
         
     | 
| 
      
 107 
     | 
    
         
            +
              config.usage_point_path = "DataCustodian/espi/1_1/resource/UsagePoint/"
         
     | 
| 
      
 108 
     | 
    
         
            +
            end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
            # GET request to https://services.greenbuttondata.org/DataCustodian/espi/1_1/resource/UsagePoint/2
         
     | 
| 
      
 111 
     | 
    
         
            +
            usage_point = GreenButtonData::UsagePoint.find 2, token: access_token
         
     | 
| 
      
 112 
     | 
    
         
            +
            ```
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
            As with `.all` method, URL can be overridden per request in `.find`:
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 117 
     | 
    
         
            +
            usage_point = GreenButtonData::UsagePoint.find "https://someotherapi.org/espi/UsagePoint/1",
         
     | 
| 
      
 118 
     | 
    
         
            +
                                                           token: access_token
         
     | 
| 
      
 119 
     | 
    
         
            +
            ```
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
            ## Parsing
         
     | 
| 
       29 
122 
     | 
    
         | 
| 
       30 
123 
     | 
    
         
             
            Almost all of the functionality for parsing data is wrapped in the
         
     | 
| 
       31 
124 
     | 
    
         
             
            `GreenButtonData::Feed` class.
         
     | 
| 
         @@ -61,6 +154,21 @@ end 
     | 
|
| 
       61 
154 
     | 
    
         
             
            4. Push the branch: `git push origin my-awesome-feature`
         
     | 
| 
       62 
155 
     | 
    
         
             
            5. Submit a pull request
         
     | 
| 
       63 
156 
     | 
    
         | 
| 
      
 157 
     | 
    
         
            +
            ## Versioning
         
     | 
| 
      
 158 
     | 
    
         
            +
             
     | 
| 
      
 159 
     | 
    
         
            +
            Green Button Data gem follows [Semantic Versioning 2.0](http://semver.org/). As
         
     | 
| 
      
 160 
     | 
    
         
            +
            such, you can specify a pessimistic version constraint on this gem with two
         
     | 
| 
      
 161 
     | 
    
         
            +
            digits of precision and be guaranteed latest features and bug fixes without
         
     | 
| 
      
 162 
     | 
    
         
            +
            backwards breaking changes:
         
     | 
| 
      
 163 
     | 
    
         
            +
             
     | 
| 
      
 164 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 165 
     | 
    
         
            +
            gem 'green-button-data', '~> 0.1'
         
     | 
| 
      
 166 
     | 
    
         
            +
            ```
         
     | 
| 
      
 167 
     | 
    
         
            +
             
     | 
| 
      
 168 
     | 
    
         
            +
            Exception to this rule as per the SemVer specification is major version zero for
         
     | 
| 
      
 169 
     | 
    
         
            +
            initial development. This gem's API should NOT be considered stable until 1.0
         
     | 
| 
      
 170 
     | 
    
         
            +
            release.
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
       64 
172 
     | 
    
         
             
            ## License
         
     | 
| 
       65 
173 
     | 
    
         | 
| 
       66 
174 
     | 
    
         
             
            This software is distributed AS IS WITHOUT WARRANTY under [Simplified BSD](https://raw.githubusercontent.com/VerdigrisTech/green-button-data/master/LICENSE.txt)
         
     | 
| 
         @@ -70,4 +178,4 @@ Verdigris Technologies Inc. assumes NO RESPONSIBILITY OR LIABILITY 
     | 
|
| 
       70 
178 
     | 
    
         
             
            UNDER ANY CIRCUMSTANCES for usage of this software. See the [LICENSE.txt](https://raw.githubusercontent.com/VerdigrisTech/green-button-data/master/LICENSE.txt)
         
     | 
| 
       71 
179 
     | 
    
         
             
            file for detailed legal information.
         
     | 
| 
       72 
180 
     | 
    
         | 
| 
       73 
     | 
    
         
            -
            Copyright © 2015, Verdigris Technologies Inc. All rights reserved.
         
     | 
| 
      
 181 
     | 
    
         
            +
            Copyright © 2015, [Verdigris Technologies Inc](http://verdigris.co). All rights reserved.
         
     | 
    
        data/green-button-data.gemspec
    CHANGED
    
    | 
         @@ -10,7 +10,10 @@ Gem::Specification.new do |s| 
     | 
|
| 
       10 
10 
     | 
    
         
             
              s.licenses    = ['BSD-2-Clause']
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              s.summary     = 'Parser for Green Button data format'
         
     | 
| 
       13 
     | 
    
         
            -
              s.description = ' 
     | 
| 
      
 13 
     | 
    
         
            +
              s.description = 'Green Button Data is a Ruby gem that can consume Green ' +
         
     | 
| 
      
 14 
     | 
    
         
            +
                              'Button APIs and parse the Green Button data XML schema ' +
         
     | 
| 
      
 15 
     | 
    
         
            +
                              'very quickly. It uses an event-driven SAX parser which ' +
         
     | 
| 
      
 16 
     | 
    
         
            +
                              'parses XML data without building an entire DOM in memory.'
         
     | 
| 
       14 
17 
     | 
    
         | 
| 
       15 
18 
     | 
    
         
             
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
       16 
19 
     | 
    
         
             
              s.require_paths = ['lib']
         
     | 
| 
         @@ -20,7 +23,9 @@ Gem::Specification.new do |s| 
     | 
|
| 
       20 
23 
     | 
    
         | 
| 
       21 
24 
     | 
    
         
             
              s.add_dependency 'nokogiri', '~> 1.6'
         
     | 
| 
       22 
25 
     | 
    
         
             
              s.add_dependency 'sax-machine', '~> 1.3'
         
     | 
| 
      
 26 
     | 
    
         
            +
              s.add_dependency 'faraday', '~> 0.9'
         
     | 
| 
       23 
27 
     | 
    
         | 
| 
       24 
28 
     | 
    
         
             
              s.add_development_dependency 'rspec', '~> 3.0'
         
     | 
| 
      
 29 
     | 
    
         
            +
              s.add_development_dependency 'webmock', '~> 1.21'
         
     | 
| 
       25 
30 
     | 
    
         
             
              s.add_development_dependency 'guard', '~>2.13'
         
     | 
| 
       26 
31 
     | 
    
         
             
            end
         
     | 
    
        data/lib/green-button-data.rb
    CHANGED
    
    | 
         @@ -1,11 +1,36 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            require 'sax-machine'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'faraday'
         
     | 
| 
       2 
3 
     | 
    
         | 
| 
       3 
4 
     | 
    
         
             
            require 'green-button-data/core_ext'
         
     | 
| 
      
 5 
     | 
    
         
            +
            require 'green-button-data/configuration'
         
     | 
| 
      
 6 
     | 
    
         
            +
            require 'green-button-data/utilities'
         
     | 
| 
       4 
7 
     | 
    
         
             
            require 'green-button-data/dst'
         
     | 
| 
       5 
8 
     | 
    
         
             
            require 'green-button-data/enumerations'
         
     | 
| 
       6 
     | 
    
         
            -
            require 'green-button-data/utilities'
         
     | 
| 
       7 
9 
     | 
    
         
             
            require 'green-button-data/parser'
         
     | 
| 
       8 
10 
     | 
    
         
             
            require 'green-button-data/feed'
         
     | 
| 
      
 11 
     | 
    
         
            +
            require 'green-button-data/relations'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'green-button-data/model_collection'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'green-button-data/fetchable'
         
     | 
| 
      
 14 
     | 
    
         
            +
            require 'green-button-data/entry'
         
     | 
| 
      
 15 
     | 
    
         
            +
            require 'green-button-data/application_information'
         
     | 
| 
      
 16 
     | 
    
         
            +
            require 'green-button-data/authorization'
         
     | 
| 
      
 17 
     | 
    
         
            +
            require 'green-button-data/interval_block'
         
     | 
| 
      
 18 
     | 
    
         
            +
            require 'green-button-data/local_time_parameters'
         
     | 
| 
      
 19 
     | 
    
         
            +
            require 'green-button-data/meter_reading'
         
     | 
| 
      
 20 
     | 
    
         
            +
            require 'green-button-data/reading_type'
         
     | 
| 
      
 21 
     | 
    
         
            +
            require 'green-button-data/usage_point'
         
     | 
| 
      
 22 
     | 
    
         
            +
            require 'green-button-data/usage_summary'
         
     | 
| 
       9 
23 
     | 
    
         | 
| 
       10 
24 
     | 
    
         
             
            module GreenButtonData
         
     | 
| 
      
 25 
     | 
    
         
            +
              class << self
         
     | 
| 
      
 26 
     | 
    
         
            +
                attr_writer :configuration
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              def self.configuration
         
     | 
| 
      
 30 
     | 
    
         
            +
                @configuration ||= Configuration.new
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
              def self.configure
         
     | 
| 
      
 34 
     | 
    
         
            +
                yield configuration
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
       11 
36 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,112 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GreenButtonData
         
     | 
| 
      
 2 
     | 
    
         
            +
              class ApplicationInformation < Entry
         
     | 
| 
      
 3 
     | 
    
         
            +
                include Enumerations
         
     | 
| 
      
 4 
     | 
    
         
            +
                include Utilities
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                attr_accessor :authorization_server_authorization_endpoint,
         
     | 
| 
      
 7 
     | 
    
         
            +
                              :authorization_server_registration_endpoint,
         
     | 
| 
      
 8 
     | 
    
         
            +
                              :authorization_server_token_endpoint,
         
     | 
| 
      
 9 
     | 
    
         
            +
                              :authorization_server_uri,
         
     | 
| 
      
 10 
     | 
    
         
            +
                              :contacts,
         
     | 
| 
      
 11 
     | 
    
         
            +
                              :client_id,
         
     | 
| 
      
 12 
     | 
    
         
            +
                              :client_name,
         
     | 
| 
      
 13 
     | 
    
         
            +
                              :client_secret,
         
     | 
| 
      
 14 
     | 
    
         
            +
                              :data_custodian_bulk_request_uri,
         
     | 
| 
      
 15 
     | 
    
         
            +
                              :data_custodian_id,
         
     | 
| 
      
 16 
     | 
    
         
            +
                              :data_custodian_resource_endpoint,
         
     | 
| 
      
 17 
     | 
    
         
            +
                              :data_custodian_scope_selection_screen_uri,
         
     | 
| 
      
 18 
     | 
    
         
            +
                              :grant_types,
         
     | 
| 
      
 19 
     | 
    
         
            +
                              :redirect_uri,
         
     | 
| 
      
 20 
     | 
    
         
            +
                              :registration_access_token,
         
     | 
| 
      
 21 
     | 
    
         
            +
                              :registration_client_uri,
         
     | 
| 
      
 22 
     | 
    
         
            +
                              :response_types,
         
     | 
| 
      
 23 
     | 
    
         
            +
                              :scopes,
         
     | 
| 
      
 24 
     | 
    
         
            +
                              :software_id,
         
     | 
| 
      
 25 
     | 
    
         
            +
                              :software_version,
         
     | 
| 
      
 26 
     | 
    
         
            +
                              :third_party_application_description,
         
     | 
| 
      
 27 
     | 
    
         
            +
                              :third_party_notify_uri,
         
     | 
| 
      
 28 
     | 
    
         
            +
                              :third_party_phone,
         
     | 
| 
      
 29 
     | 
    
         
            +
                              :third_party_scope_selection_screen_uri,
         
     | 
| 
      
 30 
     | 
    
         
            +
                              :third_party_user_portal_screen_uri,
         
     | 
| 
      
 31 
     | 
    
         
            +
                              :token_endpoint_auth_method
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                def client_id_issued_at(kwargs = {})
         
     | 
| 
      
 34 
     | 
    
         
            +
                  epoch_to_time @client_id_issued_at, kwargs
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def client_secret_expires_at(kwargs = {})
         
     | 
| 
      
 38 
     | 
    
         
            +
                  if @client_secret_expires_at == 0
         
     | 
| 
      
 39 
     | 
    
         
            +
                    # Maximum Fixnum = 4611686018427387903
         
     | 
| 
      
 40 
     | 
    
         
            +
                    max_fixnum = 2 ** (@client_secret_expires_at.size * 8 - 2) - 1
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                    # Roughly 146 billion years into the future; Sun would be long dead by
         
     | 
| 
      
 43 
     | 
    
         
            +
                    # this time; so for all intents and purposes, never expires
         
     | 
| 
      
 44 
     | 
    
         
            +
                    time = Time.at(max_fixnum)
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                    if kwargs[:local] == true
         
     | 
| 
      
 47 
     | 
    
         
            +
                      return time.localtime
         
     | 
| 
      
 48 
     | 
    
         
            +
                    else
         
     | 
| 
      
 49 
     | 
    
         
            +
                      return time.utc
         
     | 
| 
      
 50 
     | 
    
         
            +
                    end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  else
         
     | 
| 
      
 52 
     | 
    
         
            +
                    epoch_to_time(@client_secret_expires_at, kwargs)
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
                end
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                def data_custodian_application_status
         
     | 
| 
      
 57 
     | 
    
         
            +
                  get_enum_symbol DATA_CUSTODIAN_APPLICATION_STATUS,
         
     | 
| 
      
 58 
     | 
    
         
            +
                                  @data_custodian_application_status
         
     | 
| 
      
 59 
     | 
    
         
            +
                end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                def third_party_application_type
         
     | 
| 
      
 62 
     | 
    
         
            +
                  get_enum_symbol THIRD_PARTY_APPLICATION_TYPE,
         
     | 
| 
      
 63 
     | 
    
         
            +
                                  @third_party_application_type
         
     | 
| 
      
 64 
     | 
    
         
            +
                end
         
     | 
| 
      
 65 
     | 
    
         
            +
             
     | 
| 
      
 66 
     | 
    
         
            +
                def third_party_application_use
         
     | 
| 
      
 67 
     | 
    
         
            +
                  get_enum_symbol THIRD_PARTY_APPLICATION_USE, @third_party_application_use
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                def to_h
         
     | 
| 
      
 71 
     | 
    
         
            +
                  {
         
     | 
| 
      
 72 
     | 
    
         
            +
                    authorization_server_authorization_endpoint:
         
     | 
| 
      
 73 
     | 
    
         
            +
                      authorization_server_authorization_endpoint,
         
     | 
| 
      
 74 
     | 
    
         
            +
                    authorization_server_registration_endpoint:
         
     | 
| 
      
 75 
     | 
    
         
            +
                      authorization_server_registration_endpoint,
         
     | 
| 
      
 76 
     | 
    
         
            +
                    authorization_server_token_endpoint:
         
     | 
| 
      
 77 
     | 
    
         
            +
                      authorization_server_token_endpoint,
         
     | 
| 
      
 78 
     | 
    
         
            +
                    authorization_server_uri: authorization_server_uri,
         
     | 
| 
      
 79 
     | 
    
         
            +
                    contacts: contacts,
         
     | 
| 
      
 80 
     | 
    
         
            +
                    client_id: client_id,
         
     | 
| 
      
 81 
     | 
    
         
            +
                    client_id_issued_at: client_id_issued_at,
         
     | 
| 
      
 82 
     | 
    
         
            +
                    client_name: client_name,
         
     | 
| 
      
 83 
     | 
    
         
            +
                    client_secret: client_secret,
         
     | 
| 
      
 84 
     | 
    
         
            +
                    client_secret_expires_at: client_secret_expires_at,
         
     | 
| 
      
 85 
     | 
    
         
            +
                    data_custodian_application_status: data_custodian_application_status,
         
     | 
| 
      
 86 
     | 
    
         
            +
                    data_custodian_bulk_request_uri: data_custodian_bulk_request_uri,
         
     | 
| 
      
 87 
     | 
    
         
            +
                    data_custodian_id: data_custodian_id,
         
     | 
| 
      
 88 
     | 
    
         
            +
                    data_custodian_resource_endpoint: data_custodian_resource_endpoint,
         
     | 
| 
      
 89 
     | 
    
         
            +
                    data_custodian_scope_selection_screen_uri:
         
     | 
| 
      
 90 
     | 
    
         
            +
                      data_custodian_scope_selection_screen_uri,
         
     | 
| 
      
 91 
     | 
    
         
            +
                    grant_types: grant_types,
         
     | 
| 
      
 92 
     | 
    
         
            +
                    redirect_uri: redirect_uri,
         
     | 
| 
      
 93 
     | 
    
         
            +
                    registration_access_token: registration_access_token,
         
     | 
| 
      
 94 
     | 
    
         
            +
                    registration_client_uri: registration_client_uri,
         
     | 
| 
      
 95 
     | 
    
         
            +
                    response_types: response_types,
         
     | 
| 
      
 96 
     | 
    
         
            +
                    scopes: scopes,
         
     | 
| 
      
 97 
     | 
    
         
            +
                    software_id: software_id,
         
     | 
| 
      
 98 
     | 
    
         
            +
                    software_version: software_version,
         
     | 
| 
      
 99 
     | 
    
         
            +
                    third_party_application_description:
         
     | 
| 
      
 100 
     | 
    
         
            +
                      third_party_application_description,
         
     | 
| 
      
 101 
     | 
    
         
            +
                    third_party_application_type: third_party_application_type,
         
     | 
| 
      
 102 
     | 
    
         
            +
                    third_party_application_use: third_party_application_use,
         
     | 
| 
      
 103 
     | 
    
         
            +
                    third_party_notify_uri: third_party_notify_uri,
         
     | 
| 
      
 104 
     | 
    
         
            +
                    third_party_phone: third_party_phone,
         
     | 
| 
      
 105 
     | 
    
         
            +
                    third_party_scope_selection_screen_uri:
         
     | 
| 
      
 106 
     | 
    
         
            +
                      third_party_scope_selection_screen_uri,
         
     | 
| 
      
 107 
     | 
    
         
            +
                    third_party_user_portal_screen_uri: third_party_user_portal_screen_uri,
         
     | 
| 
      
 108 
     | 
    
         
            +
                    token_endpoint_auth_method: token_endpoint_auth_method
         
     | 
| 
      
 109 
     | 
    
         
            +
                  }
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,35 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module GreenButtonData
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Authorization < Entry
         
     | 
| 
      
 3 
     | 
    
         
            +
                include Enumerations
         
     | 
| 
      
 4 
     | 
    
         
            +
                include Utilities
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
                attr_reader :id
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                attr_accessor :authorized_period,
         
     | 
| 
      
 9 
     | 
    
         
            +
                              :published_period,
         
     | 
| 
      
 10 
     | 
    
         
            +
                              :expires_at,
         
     | 
| 
      
 11 
     | 
    
         
            +
                              :status,
         
     | 
| 
      
 12 
     | 
    
         
            +
                              :resource_uri,
         
     | 
| 
      
 13 
     | 
    
         
            +
                              :authorization_uri
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
                def active?
         
     | 
| 
      
 16 
     | 
    
         
            +
                  @status > 0
         
     | 
| 
      
 17 
     | 
    
         
            +
                end
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
                def expires_at
         
     | 
| 
      
 20 
     | 
    
         
            +
                  if @expires_at.is_a? Numeric
         
     | 
| 
      
 21 
     | 
    
         
            +
                    epoch_to_time @expires_at
         
     | 
| 
      
 22 
     | 
    
         
            +
                  elsif @expires_at.is_a? String
         
     | 
| 
      
 23 
     | 
    
         
            +
                    parse_datetime(@expires_at).to_time
         
     | 
| 
      
 24 
     | 
    
         
            +
                  elsif @expires_at.respond_to? :to_time
         
     | 
| 
      
 25 
     | 
    
         
            +
                    @expires_at.to_time
         
     | 
| 
      
 26 
     | 
    
         
            +
                  else
         
     | 
| 
      
 27 
     | 
    
         
            +
                    raise "Invalid expires_at type"
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def status
         
     | 
| 
      
 32 
     | 
    
         
            +
                  get_enum_symbol AUTHORIZATION_STATUS, @status
         
     | 
| 
      
 33 
     | 
    
         
            +
                end
         
     | 
| 
      
 34 
     | 
    
         
            +
              end
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,133 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'uri'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            module GreenButtonData
         
     | 
| 
      
 4 
     | 
    
         
            +
              class Configuration
         
     | 
| 
      
 5 
     | 
    
         
            +
                attr_accessor :base_url,
         
     | 
| 
      
 6 
     | 
    
         
            +
                              :application_information_path,
         
     | 
| 
      
 7 
     | 
    
         
            +
                              :authorization_path,
         
     | 
| 
      
 8 
     | 
    
         
            +
                              :interval_block_path,
         
     | 
| 
      
 9 
     | 
    
         
            +
                              :local_time_parameters_path,
         
     | 
| 
      
 10 
     | 
    
         
            +
                              :meter_reading_path,
         
     | 
| 
      
 11 
     | 
    
         
            +
                              :reading_type_path,
         
     | 
| 
      
 12 
     | 
    
         
            +
                              :subscription_path,
         
     | 
| 
      
 13 
     | 
    
         
            +
                              :usage_point_path,
         
     | 
| 
      
 14 
     | 
    
         
            +
                              :usage_summary_path
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
                def application_information_url
         
     | 
| 
      
 17 
     | 
    
         
            +
                  return URI.join(@base_url, @application_information_path).to_s
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                def application_information_url=(url)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  uri = URI.parse url
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @base_url = "#{uri.scheme}://#{uri.host}"
         
     | 
| 
      
 23 
     | 
    
         
            +
                  @application_information_path = uri.path
         
     | 
| 
      
 24 
     | 
    
         
            +
                end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
                def authorization_url
         
     | 
| 
      
 27 
     | 
    
         
            +
                  return URI.join(@base_url, @authorization_path).to_s
         
     | 
| 
      
 28 
     | 
    
         
            +
                end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                def authorization_url=(url)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  uri = URI.parse url
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @base_url = "#{uri.scheme}://#{uri.host}"
         
     | 
| 
      
 33 
     | 
    
         
            +
                  @authorization_path = uri.path
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                def interval_block_url(kwargs = {})
         
     | 
| 
      
 37 
     | 
    
         
            +
                  subscription_id = kwargs[:subscription_id]
         
     | 
| 
      
 38 
     | 
    
         
            +
                  usage_point_id = kwargs[:usage_point_id]
         
     | 
| 
      
 39 
     | 
    
         
            +
                  meter_reading_id = kwargs[:meter_reading_id]
         
     | 
| 
      
 40 
     | 
    
         
            +
                  interval_block_id = kwargs[:interval_block_id]
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  uri = if subscription_id && usage_point_id && meter_reading_id
         
     | 
| 
      
 43 
     | 
    
         
            +
                    meter_reading_uri = meter_reading_url(
         
     | 
| 
      
 44 
     | 
    
         
            +
                      subscription_id: subscription_id,
         
     | 
| 
      
 45 
     | 
    
         
            +
                      usage_point_id: usage_point_id,
         
     | 
| 
      
 46 
     | 
    
         
            +
                      meter_reading_id: meter_reading_id
         
     | 
| 
      
 47 
     | 
    
         
            +
                    )
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                    URI.join meter_reading_uri, @interval_block_path
         
     | 
| 
      
 50 
     | 
    
         
            +
                  else
         
     | 
| 
      
 51 
     | 
    
         
            +
                    URI.join @base_url, @interval_block_path
         
     | 
| 
      
 52 
     | 
    
         
            +
                  end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                  uri = URI.join uri, "#{interval_block_id}/" if interval_block_id
         
     | 
| 
      
 55 
     | 
    
         
            +
             
     | 
| 
      
 56 
     | 
    
         
            +
                  return uri.to_s
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                def local_time_parameters_url
         
     | 
| 
      
 60 
     | 
    
         
            +
                  return URI.join @base_url, @local_time_parameters_path
         
     | 
| 
      
 61 
     | 
    
         
            +
                end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                def meter_reading_url(kwargs = {})
         
     | 
| 
      
 64 
     | 
    
         
            +
                  subscription_id = kwargs[:subscription_id]
         
     | 
| 
      
 65 
     | 
    
         
            +
                  usage_point_id = kwargs[:usage_point_id]
         
     | 
| 
      
 66 
     | 
    
         
            +
                  meter_reading_id = kwargs[:meter_reading_id]
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                  uri = if subscription_id && usage_point_id
         
     | 
| 
      
 69 
     | 
    
         
            +
                    usage_point_uri = usage_point_url(
         
     | 
| 
      
 70 
     | 
    
         
            +
                      subscription_id: subscription_id,
         
     | 
| 
      
 71 
     | 
    
         
            +
                      usage_point_id: usage_point_id
         
     | 
| 
      
 72 
     | 
    
         
            +
                    )
         
     | 
| 
      
 73 
     | 
    
         
            +
             
     | 
| 
      
 74 
     | 
    
         
            +
                    URI.join usage_point_uri, @meter_reading_path
         
     | 
| 
      
 75 
     | 
    
         
            +
                  else
         
     | 
| 
      
 76 
     | 
    
         
            +
                    URI.join @base_url, @meter_reading_path
         
     | 
| 
      
 77 
     | 
    
         
            +
                  end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
                  uri = URI.join uri, "#{meter_reading_id}/" if meter_reading_id
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                  return uri.to_s
         
     | 
| 
      
 82 
     | 
    
         
            +
                end
         
     | 
| 
      
 83 
     | 
    
         
            +
             
     | 
| 
      
 84 
     | 
    
         
            +
                def reading_type_url(id = nil)
         
     | 
| 
      
 85 
     | 
    
         
            +
                  uri = URI.join @base_url, @reading_type_path
         
     | 
| 
      
 86 
     | 
    
         
            +
                  uri = URI.join uri, "#{id}/" if id
         
     | 
| 
      
 87 
     | 
    
         
            +
             
     | 
| 
      
 88 
     | 
    
         
            +
                  return uri.to_s
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                def subscription_url(id)
         
     | 
| 
      
 92 
     | 
    
         
            +
                  uri = URI.join @base_url, @subscription_path
         
     | 
| 
      
 93 
     | 
    
         
            +
                  uri = URI.join uri, "#{id}/" if id
         
     | 
| 
      
 94 
     | 
    
         
            +
                  return uri.to_s
         
     | 
| 
      
 95 
     | 
    
         
            +
                end
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                def usage_point_url(kwargs = {})
         
     | 
| 
      
 98 
     | 
    
         
            +
                  subscription_id = kwargs[:subscription_id]
         
     | 
| 
      
 99 
     | 
    
         
            +
                  usage_point_id = kwargs[:usage_point_id]
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
                  uri = if subscription_id
         
     | 
| 
      
 102 
     | 
    
         
            +
                    subscription_uri = subscription_url subscription_id
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                    URI.join subscription_uri, @usage_point_path
         
     | 
| 
      
 105 
     | 
    
         
            +
                  else
         
     | 
| 
      
 106 
     | 
    
         
            +
                    URI.join @base_url, @usage_point_path
         
     | 
| 
      
 107 
     | 
    
         
            +
                  end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
                  uri = URI.join uri, "#{usage_point_id}/" if usage_point_id
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                  return uri.to_s
         
     | 
| 
      
 112 
     | 
    
         
            +
                end
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                def usage_summary_url(kwargs = {})
         
     | 
| 
      
 115 
     | 
    
         
            +
                  subscription_id = kwargs[:subscription_id]
         
     | 
| 
      
 116 
     | 
    
         
            +
                  usage_point_id = kwargs[:usage_point_id]
         
     | 
| 
      
 117 
     | 
    
         
            +
             
     | 
| 
      
 118 
     | 
    
         
            +
                  if subscription_id && usage_point_id
         
     | 
| 
      
 119 
     | 
    
         
            +
                    usage_point_uri = usage_point_url subscription_id: subscription_id,
         
     | 
| 
      
 120 
     | 
    
         
            +
                                                      usage_point_id: usage_point_id
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                    return URI.join(usage_point_uri, @usage_summary_path).to_s
         
     | 
| 
      
 123 
     | 
    
         
            +
                  elsif subscription_id
         
     | 
| 
      
 124 
     | 
    
         
            +
                    raise ArgumentError.new "Missing required argument: usage_point_id"
         
     | 
| 
      
 125 
     | 
    
         
            +
                  elsif usage_point_id
         
     | 
| 
      
 126 
     | 
    
         
            +
                    raise ArgumentError.new "Missing required argument: subscription_id"
         
     | 
| 
      
 127 
     | 
    
         
            +
                  else
         
     | 
| 
      
 128 
     | 
    
         
            +
                    raise ArgumentError.new "Missing required arguments: subscription_id," +
         
     | 
| 
      
 129 
     | 
    
         
            +
                                            " usage_point_id"
         
     | 
| 
      
 130 
     | 
    
         
            +
                  end
         
     | 
| 
      
 131 
     | 
    
         
            +
                end
         
     | 
| 
      
 132 
     | 
    
         
            +
              end
         
     | 
| 
      
 133 
     | 
    
         
            +
            end
         
     |