Class: EStat::API
- Inherits:
-
Object
- Object
- EStat::API
- Defined in:
- lib/e_stat/api.rb
Constant Summary collapse
- BASE_URL =
'http://api.e-stat.go.jp/rest/2.0/app/json/'
Instance Method Summary collapse
- #get_meta_info(stats_data_id) ⇒ Object
- #get_stats_data(stats_data_id) ⇒ Object
- #get_stats_list(stats_field, stats_code, options = {}) ⇒ Object
-
#initialize(key, options = {}) ⇒ API
constructor
A new instance of API.
Constructor Details
#initialize(key, options = {}) ⇒ API
Returns a new instance of API.
8 9 10 11 |
# File 'lib/e_stat/api.rb', line 8 def initialize(key, ={}) @key = key @lang = [:lang] end |
Instance Method Details
#get_meta_info(stats_data_id) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/e_stat/api.rb', line 31 def (stats_data_id) response = Faraday.get("#{BASE_URL}getMetaInfo", { appId: @key, lang: @lang, statsDataId: stats_data_id }) attributes = JSON.parse(response.body) attributes['GET_META_INFO'] end |
#get_stats_data(stats_data_id) ⇒ Object
41 42 43 44 45 46 47 48 49 |
# File 'lib/e_stat/api.rb', line 41 def get_stats_data(stats_data_id) response = Faraday.get("#{BASE_URL}getStatsData", { appId: @key, lang: @lang, statsDataId: stats_data_id }) attributes = JSON.parse(response.body) attributes['GET_STATS_DATA'] end |
#get_stats_list(stats_field, stats_code, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/e_stat/api.rb', line 13 def get_stats_list(stats_field, stats_code, ={}) response = Faraday.get("#{BASE_URL}getStatsList", { appId: @key, lang: @lang, statsField: stats_field, statsCode: stats_code, surveyYears: [:survey_years], openYears: [:open_years], searchWord: [:search_word], searchKind: [:search_kind], statsNameList: [:stats_name_list], startPosition: [:start_position], updatedDate: [:updated_date] }) attributes = JSON.parse(response.body) attributes['GET_STATS_LIST'] end |