geostellar_client 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +40 -6
- data/lib/geostellar_client.rb +1 -0
- data/lib/geostellar_client/exceptions.rb +5 -0
- data/lib/geostellar_client/user.rb +18 -0
- data/lib/geostellar_client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1791a78e5924e88bb802f6a936664411e97aa0a3
|
4
|
+
data.tar.gz: ee1492b2c1562dd341794541e08f08f72a3cd4bb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7bfc30cabe84773de22b860d4430f9934738b3017768d8f27fed85f5e58b34ef8a116e766ab4437ccf067c6ec8a9c6c22e1c731eb6d0daac4dc92a9e1462c2a
|
7
|
+
data.tar.gz: d7eddc7475ac0875ced1b711ffe8b5181f11c146cc4ac0b9ad0bc587f25e5a64c6b0ab95350abf339c2d2c7c224990b93090fb84243f24c7e575d6488a10855c
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -24,14 +24,10 @@ Or install it yourself as:
|
|
24
24
|
Configure the client with your API key:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
GeostellarClient = YOURAPIKEY
|
27
|
+
GeostellarClient.api_key = YOURAPIKEY
|
28
28
|
```
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
```ruby
|
33
|
-
user = GeostellarClient::User.find(1)
|
34
|
-
```
|
30
|
+
### User
|
35
31
|
|
36
32
|
A user has the following attributes:
|
37
33
|
|
@@ -46,8 +42,38 @@ street_address_2, String
|
|
46
42
|
city, String
|
47
43
|
state, String
|
48
44
|
zip_code, String
|
45
|
+
password, String
|
49
46
|
```
|
50
47
|
|
48
|
+
`password` is only used internally when talking to the user creation API. The User object returned by `User#create` has a password value of `nil`.
|
49
|
+
|
50
|
+
#### To fetch a user:
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
user = GeostellarClient::User.find(1)
|
54
|
+
```
|
55
|
+
|
56
|
+
#### To create a user:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
attributes = {
|
60
|
+
email: 'someemail@example.com',
|
61
|
+
password: 'password',
|
62
|
+
phone: '123456789',
|
63
|
+
first_name: 'Foo',
|
64
|
+
last_name: 'Bar',
|
65
|
+
street_address_1: '1 Street',
|
66
|
+
street_address_2: 'Address',
|
67
|
+
city: 'The City',
|
68
|
+
state: 'OR',
|
69
|
+
zip_code: '12345',
|
70
|
+
}
|
71
|
+
|
72
|
+
user = GeostellarClient::User.create(attributes)
|
73
|
+
```
|
74
|
+
|
75
|
+
When successful this returns a `User` object. Otherwise a `GeostellarClient::UserCreationError` is raised, with the message returned by the API.
|
76
|
+
|
51
77
|
|
52
78
|
## Development
|
53
79
|
|
@@ -57,6 +83,14 @@ Then, run `rake rspec` to run the tests. You can also run `bin/console` for an i
|
|
57
83
|
|
58
84
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
59
85
|
|
86
|
+
### To-do
|
87
|
+
|
88
|
+
- Update user
|
89
|
+
- Log-in
|
90
|
+
- Log-out
|
91
|
+
- PV Module, Incentive, Solar estimate models and API calls
|
92
|
+
- Address and monthly bill search
|
93
|
+
|
60
94
|
|
61
95
|
## Contributing
|
62
96
|
|
data/lib/geostellar_client.rb
CHANGED
@@ -13,6 +13,7 @@ module GeostellarClient
|
|
13
13
|
attribute :city, String
|
14
14
|
attribute :state, String
|
15
15
|
attribute :zip_code, String
|
16
|
+
attribute :password, String
|
16
17
|
|
17
18
|
def self.find(id)
|
18
19
|
response = HTTParty.get(
|
@@ -22,6 +23,23 @@ module GeostellarClient
|
|
22
23
|
new(JSON.parse(response.body))
|
23
24
|
end
|
24
25
|
|
26
|
+
def self.create(attrs)
|
27
|
+
valid_attrs = User.new(attrs).attributes.reject { |k, v| v.nil? }
|
28
|
+
options = {
|
29
|
+
api_key: GeostellarClient.api_key,
|
30
|
+
body: { user: valid_attrs },
|
31
|
+
}
|
32
|
+
|
33
|
+
response = HTTParty.post(api_url, options)
|
34
|
+
|
35
|
+
if response.success?
|
36
|
+
new(response.parsed_response)
|
37
|
+
else
|
38
|
+
message = response["errors"].join(', ')
|
39
|
+
raise GeostellarClient::UserCreationError, message
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
25
43
|
private
|
26
44
|
|
27
45
|
def self.find_url(id)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: geostellar_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JP Moral
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: virtus
|
@@ -169,6 +169,7 @@ files:
|
|
169
169
|
- bin/setup
|
170
170
|
- geostellar_client.gemspec
|
171
171
|
- lib/geostellar_client.rb
|
172
|
+
- lib/geostellar_client/exceptions.rb
|
172
173
|
- lib/geostellar_client/user.rb
|
173
174
|
- lib/geostellar_client/version.rb
|
174
175
|
homepage: https://github.com/jpmoral/geostellar_client
|