girlscout 0.2.3 → 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 +4 -4
- data/lib/girlscout.rb +1 -0
- data/lib/girlscout/concerns/has_attributes.rb +10 -0
- data/lib/girlscout/error.rb +10 -0
- data/lib/girlscout/object.rb +1 -7
- data/lib/girlscout/resource.rb +6 -15
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9ccc0c560938afb43d3438904fa99f116cb366d0
|
|
4
|
+
data.tar.gz: 0a60b0d92d6ffe2b91e5a28b1ac0a55068d8fbf3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb33333214ed4f1ba9732220d444d48242be7931019237ca2d3d62d74780e27bc1d2f2417b6456376bad4f55ca764a3632fca46e870578c090859dd8a1d264ec
|
|
7
|
+
data.tar.gz: d1d0a9c6af2aef765e0152938941f9d533a42a67681b4b1a063dcae9ee4516e6071a38ecabe7c1aba8743dd8a457384122ea5e8924fe7e242cfee6b63887deab
|
data/lib/girlscout.rb
CHANGED
|
@@ -34,6 +34,16 @@ module GirlScout
|
|
|
34
34
|
|
|
35
35
|
protected
|
|
36
36
|
|
|
37
|
+
def normalize_attributes(attr)
|
|
38
|
+
attr = attr || @attributes
|
|
39
|
+
attr = attr.attributes if attr.respond_to?(:attributes)
|
|
40
|
+
|
|
41
|
+
attr.inject({}) do |hash,(k,v)|
|
|
42
|
+
hash[attr_key(k)] = v
|
|
43
|
+
hash
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
37
47
|
def attr_key(sym)
|
|
38
48
|
parts = sym.to_s.split('_') # camelize w/o active support
|
|
39
49
|
parts[0] + parts[1..-1].map(&:capitalize).join('')
|
data/lib/girlscout/object.rb
CHANGED
|
@@ -4,13 +4,7 @@ module GirlScout
|
|
|
4
4
|
include GirlScout::Concerns::HasResource
|
|
5
5
|
|
|
6
6
|
def initialize(attr={}, options={})
|
|
7
|
-
|
|
8
|
-
attr = attr.inject({}) do |hash,(k,v)|
|
|
9
|
-
hash[attr_key(k)] = v
|
|
10
|
-
hash
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
@attributes = attr
|
|
7
|
+
@attributes = normalize_attributes(attr)
|
|
14
8
|
@resource = options[:resource] if options[:resource]
|
|
15
9
|
end
|
|
16
10
|
end
|
data/lib/girlscout/resource.rb
CHANGED
|
@@ -34,22 +34,13 @@ module GirlScout
|
|
|
34
34
|
|
|
35
35
|
def request(options={})
|
|
36
36
|
auth = { user: Config.api_key, password: 'X' }
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
# opts = { }
|
|
42
|
-
# opts[:headers] = { params: query } if query
|
|
43
|
-
|
|
44
|
-
# parse(rest_resource.get(opts))
|
|
45
|
-
# end
|
|
37
|
+
response = Excon.new(url, auth).request(options)
|
|
38
|
+
if response.status != 200
|
|
39
|
+
raise GirlScout::Error.new(JSON.parse(response.body))
|
|
40
|
+
end
|
|
46
41
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
# payload = serialize(payload) if payload
|
|
50
|
-
# parse(rest_resource.send(method, payload, content_type: :json))
|
|
51
|
-
# end
|
|
52
|
-
# end
|
|
42
|
+
JSON.parse(response.body)
|
|
43
|
+
end
|
|
53
44
|
|
|
54
45
|
private
|
|
55
46
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: girlscout
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chakrit Wichian
|
|
@@ -163,6 +163,7 @@ files:
|
|
|
163
163
|
- lib/girlscout/config.rb
|
|
164
164
|
- lib/girlscout/conversation.rb
|
|
165
165
|
- lib/girlscout/customer.rb
|
|
166
|
+
- lib/girlscout/error.rb
|
|
166
167
|
- lib/girlscout/folder.rb
|
|
167
168
|
- lib/girlscout/list.rb
|
|
168
169
|
- lib/girlscout/mailbox.rb
|