plangrade-ruby 0.3.5 → 0.3.6

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: 9249c243f590f0369494c5226dfef8ba2ba15d18
4
- data.tar.gz: 8583a9c899eb7a6eb950af43533737a4de493453
3
+ metadata.gz: 5790385b5c3f4a15cf42160db4f75ed4ab030f3e
4
+ data.tar.gz: 4f8db0f0962bf2211ebaa644f589794abc401f74
5
5
  SHA512:
6
- metadata.gz: 0928141d9374ff3900a48b0bb72f5fc9ab18bfeb976672c349f897bd20eeec2e14e66d9fc71f69cdc387a703263da27db36395236706eb23777edb12546e17b9
7
- data.tar.gz: 9520386cf7b6e5c57f732bfe1a4a93399ba2e34b88c2f30b2237302a92b2e33532d2034d8b963e79f4bf1817de36c3942c8a67d0f06c66d2bb074240d87f00c9
6
+ metadata.gz: 8fd54b71bbd5dd0cf80bc96ed8e768939a1897491f8ecaa5b8fde465f306535a9bbde0d082b479d15ded3550248af5f36568629aef4c55d87dd1f2c3884c1c05
7
+ data.tar.gz: 04e54e3f059074ac266a42b14407888e832f488d3effd99e6613125207c07b60e899b574a07cfc032af5ae54288fa787727e42b3f355cb00e364c5c2e6c2b451
checksums.yaml.gz.sig CHANGED
@@ -1,2 +1,3 @@
1
- |��dƳfa_~����8?Z؜|:��f��Qv�|���Po_?0h�~��w��Lp І���a��J
2
- QV}mgd�I�;M4�H[�Պv���58�F�0��L�/������LD�b��%��ݝ�n&^6��żԆu��L���T�)�-�]�t� a�%{���?��P�@��d�
1
+ SA�^�m_����!�GZ��)�T)xFA�.0�@�6M��B#h)8T�T�};+�*�{KA^v�`�U�1���ZKR��BS/�
2
+ Re÷ڜ*��v��l]����
3
+ [����������U� ��{z��d ���$09�k�~j~X��y���Ab�5� �
data.tar.gz.sig CHANGED
Binary file
@@ -1,25 +1,36 @@
1
1
  module Plangrade
2
2
  module Resources
3
3
  class Company < Plangrade::Resources::Base
4
+ attr_reader :id, :name, :ein, :grade
4
5
 
5
- def self.create(ein, name)
6
- result = api_handler.create_company(:ein => ein, :name => name)
6
+ def initialize(attributes)
7
+ @id = attirbutes["id"]
8
+ @name = attributes["name"]
9
+ @ein = attributes["ein"]
10
+ @grade = attributes["grade"]
11
+ end
12
+
13
+ def self.create(new_ein, new_name)
14
+ result = api_handler.create_company(:ein => new_ein, :name => new_name)
7
15
  return nil unless result.created?
8
16
  id = result.headers[:location].split('/').last.to_i
9
17
  new(:id => id)
10
18
  end
11
19
 
12
- attr_accessor_deffered :name, :ein, :grade
13
-
14
- def self.get(id)
15
- result = api_handler.get_company(id)
16
- return nil unless result.success?
17
- new(result.body[:company])
20
+ def self.get(get_id)
21
+ result = api_handler.get_company(get_id)
22
+ attributes = JSON.parse(result.body[:company])
23
+ new(attributes)
18
24
  end
19
25
 
20
- def self.all(*opts)
21
- result = api_handler.all_companies(opts)
22
- new(result.body[:companies])
26
+ def self.all(opts={})
27
+ if opts
28
+ result = api_handler.all_companies(opts)
29
+ else
30
+ result = api_handler.all_companies
31
+ end
32
+ companies = JSON.parse(result.body[:companies])
33
+ companies.map{ |attributes| new(attributes) }
23
34
  end
24
35
 
25
36
  def update!(params)
@@ -18,10 +18,11 @@ module Plangrade
18
18
  new(result.body[:participant])
19
19
  end
20
20
 
21
- def self.all(company_id, *opts)
21
+ def self.all(company_id, opts={})
22
22
  opts ||= {}
23
23
  opts[:company_id] = company_id
24
24
  result = api_handler.all_participants(opts)
25
+ return nil unless result.success?
25
26
  new(result.body[:participants])
26
27
  end
27
28
 
@@ -1,5 +1,5 @@
1
1
  module Plangrade
2
2
  module Ruby
3
- VERSION = "0.3.5"
3
+ VERSION = "0.3.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plangrade-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Reynoso
metadata.gz.sig CHANGED
Binary file