startupstats 0.0.4 → 0.0.5

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.
@@ -1,5 +1,6 @@
1
1
  require 'startupstats/formd/models/filing'
2
2
  require 'startupstats/formd/models/company'
3
+ require 'startupstats/response/api_result'
3
4
  module StartupStats
4
5
  module Formd
5
6
  module Filings
@@ -8,18 +9,35 @@ module StartupStats
8
9
  #
9
10
  # @authentication_required This is a protected API call
10
11
  # @raise [StartupStats::Error::Unauthorized] Error raised when supplied
11
- # @return [Array<StartupStats::Filing>] The requested Filings.
12
12
  # @param start [Integer] default is 0
13
13
  # @param limit [Integer] default is 100
14
14
  # @param industry [String] not required
15
+ # @return [Array<StartupStats::Filing>] The requested Filings.
15
16
  def filings( start , limit , industry )
16
17
  begin
17
- parse_filings_from_response(:get , "filings", {start: start , limit: limit , industry: industry} )
18
+ result = parse_filings_from_response(:get , "filings", {start: start , limit: limit , industry: industry} )
19
+ result.result_set
18
20
  rescue StartupStats::Error::Unauthorized => error
19
21
  raise
20
22
  end
21
23
  end
22
24
 
25
+ # Returns filings
26
+ #
27
+ # @authentication_required This is a protected API call
28
+ # @raise [StartupStats::Error::Unauthorized] Error raised when supplied
29
+ # @param start [Integer] default is 0
30
+ # @param limit [Integer] default is 100
31
+ # @param industry [String] not required
32
+ # @return [StartupStats::ApiResult] The requested Filings with count.
33
+ def filings_with_count( start , limit , industry )
34
+ begin
35
+ parse_filings_from_response(:get , "filings", {start: start , limit: limit , industry: industry} )
36
+ rescue StartupStats::Error::Unauthorized => error
37
+ raise
38
+ end
39
+ end
40
+
23
41
  =begin (Comes later)
24
42
  def create_filing
25
43
  end
@@ -42,14 +60,16 @@ module StartupStats
42
60
  # @param method [Symbol]
43
61
  # @param path [String]
44
62
  # @param params [Array]
45
- # @return [Array<StartupStats::Filing>]
46
- def parse_filings_from_response(method , path , params )
63
+ # @return [StartupStats::ApiResult]
64
+ def parse_filings_from_response( method , path , params )
47
65
  response = send(method.to_sym, path, params)
48
- filings = []
49
- response[:body].each{|filing|
50
- filings.push( StartupStats::Formd::Filing.new filing )
66
+ body = response[:body]
67
+ parsed_filings = []
68
+ body[:filings].each{|filing|
69
+ parsed_filings.push( StartupStats::Formd::Filing.new filing )
51
70
  }
52
- filings
71
+
72
+ StartupStats::ApiResult.new( { :result_set => parsed_filings , :total_count => body[:total_count] , :start => body[:start] , :limit => body[:limit] } )
53
73
  end
54
74
  end
55
75
  end
@@ -0,0 +1,10 @@
1
+ module StartupStats
2
+ class ApiResult
3
+ attr_accessor :result_set , :total_count , :start , :limit
4
+ def initialize args = {}
5
+ args.each do |k, v|
6
+ instance_variable_set("@#{k}",v) unless v.nil?
7
+ end
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module StartupStats
2
- VERSION = '0.0.4'
2
+ VERSION = '0.0.5'
3
3
  end
@@ -31,5 +31,11 @@ describe StartupStats::Formd::Filings do
31
31
  expect(filings.first.company).to be_a StartupStats::Formd::Company
32
32
  #end
33
33
  end
34
+
35
+ it "gets filings with count" do
36
+ filings = client.filings_with_count( start = 0 , limit = 5 , industry = nil )
37
+ expect(filings).to be_a StartupStats::ApiResult
38
+ expect(filings.total_count).to be > 0
39
+ end
34
40
  end
35
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: startupstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-11-29 00:00:00.000000000 Z
12
+ date: 2012-11-30 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
@@ -156,6 +156,7 @@ files:
156
156
  - lib/startupstats/formd/models/company.rb
157
157
  - lib/startupstats/formd/models/filing.rb
158
158
  - lib/startupstats/requestable.rb
159
+ - lib/startupstats/response/api_result.rb
159
160
  - lib/startupstats/response/parse_json.rb
160
161
  - lib/startupstats/response/raise_error.rb
161
162
  - lib/startupstats/version.rb