Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kurenn/cic-rb
A library built in ruby to communicate with the CIC Api
https://github.com/kurenn/cic-rb
api cic cic-api gem hashie ruby sdk
Last synced: about 1 month ago
JSON representation
A library built in ruby to communicate with the CIC Api
- Host: GitHub
- URL: https://github.com/kurenn/cic-rb
- Owner: kurenn
- License: mit
- Created: 2013-02-21T22:33:14.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2017-12-06T15:58:59.000Z (about 7 years ago)
- Last Synced: 2024-03-15T01:55:51.139Z (10 months ago)
- Topics: api, cic, cic-api, gem, hashie, ruby, sdk
- Language: Ruby
- Size: 25.4 KB
- Stars: 4
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[![Code Climate](https://codeclimate.com/github/IcaliaLabs/cic-rb/badges/gpa.svg)](https://codeclimate.com/github/IcaliaLabs/cic-rb)
[![Test Coverage](https://codeclimate.com/github/IcaliaLabs/cic-rb/badges/coverage.svg)](https://codeclimate.com/github/IcaliaLabs/cic-rb/coverage)
[![Issue Count](https://codeclimate.com/github/IcaliaLabs/cic-rb/badges/issue_count.svg)](https://codeclimate.com/github/IcaliaLabs/cic-rb)# CIC Ruby Gem
cic-rb is a client which communicates with the CIC API, and interact
with itIt was developed for usage in Ruby on Rails web applications, but it
also works as a standalone library## Installation
Add this line to your application's Gemfile:
gem 'cic'
Living on the edge
gem 'cic', git: '[email protected]:IcaliaLabs/cic-rb.git'
And then execute:
$ bundle
Or install it yourself as:
$ gem install cic
Request for reports
---```ruby
Cic::Report.all
```
It will output:
```ruby
#"#7LZA",
"content"=>
"ACCIDENTE* en Vasconcelos lateral para tomar el t\u00FAnel SP #mtyfollow 16:26 v\u00EDa @Monitores_SPGG cc @SanPedroen72",
"state"=>"read",
"created_at"=>"2013-02-21T16:29:30-06:00",
"updated_at"=>"2013-02-21T16:34:15-06:00",
"lat"=>"25.65419634916782",
"lng"=>"-100.33913254737848",
"is_public"=>true,
"votes"=>0,
"stars"=>0.0,
"address_detail"=>{...},
"group"=>"Vialidad y Transito (SS)",
"categories"=>["ACCIDENTE"]},
@raw_attributes=
{"ticket"=>"#7LZA",
"content"=>
"ACCIDENTE* en Vasconcelos lateral para tomar el t\u00FAnel SP #mtyfollow 16:26 v\u00EDa @Monitores_SPGG cc @SanPedroen72",
"state"=>"read",
"created_at"=>"2013-02-21T16:29:30-06:00",
"updated_at"=>"2013-02-21T16:34:15-06:00",
"lat"=>"25.65419634916782",
"lng"=>"-100.33913254737848",
"is_public"=>true,
"votes"=>0,
"stars"=>0.0,
"address_detail"=>
{"formatted_address"=>
"Jos\u00E9 Vasconcelos 419, Residencial San Agust\u00EDn 1er Sector, 66260 San Pedro Garza Garc\u00EDa, Nuevo Le\u00F3n, Mexico",
"zipcode"=>"66260",
"county"=>
{"long_name"=>"San Pedro Garza Garc\u00EDa",
"short_name"=>"San Pedro Garza Garc\u00EDa"},
"state"=>{"long_name"=>"Nuevo Leon", "short_name"=>"NL"},
"neighborhood"=>
{"long_name"=>"Residencial San Agust\u00EDn 1er Sector",
"short_name"=>"Residencial San Agust\u00EDn 1er Sector"}},
"group"=>"Vialidad y Transito (SS)",
"categories"=>["ACCIDENTE"]}>
```We have a where clause to embrace em all!
```ruby
Cic::Report.where(for_group: 142)
```Heads up!, the params you can send are, for_group, for_category, limit, until
It will have the same output as above.
Request for categories
---```ruby
Cic::Category.all
```
It will output:
```ruby
#420,
"name"=>"AVISOS",
"metadata"=>false,
"type"=>"blackbox",
"group"=>["Comunidad"]},
@raw_attributes=
{"id"=>420,
"name"=>"AVISOS",
"metadata"=>false,
"type"=>"blackbox",
"group"=>["Comunidad"]}>,
#412,
"name"=>"BACHE O VIA DA\u00D1ADA",
"metadata"=>false,
"type"=>"blackbox",
"group"=>["Servicios Publicos (CS)"]},
@raw_attributes=
{"id"=>412,
"name"=>"BACHE O VIA DA\u00D1ADA",
"metadata"=>false,
"type"=>"blackbox",
"group"=>["Servicios Publicos (CS)"]}>
```Request for groups
---
```ruby
Cic::Group.all
```
It will output:
```ruby
#142, "name"=>"Asesorias Generales", "categories"=>[["OTROS", 424]]},
@raw_attributes=
{"id"=>142, "name"=>"Asesorias Generales", "categories"=>[["OTROS", 424]]}>,
#258, "name"=>"CFE", "categories"=>[["FALTA ELECTRICIDAD", 423]]},
@raw_attributes=
{"id"=>258, "name"=>"CFE", "categories"=>[["FALTA ELECTRICIDAD", 423]]}>,
```## Hashie that out!
Thanks to Hashie library you can access the report attributes by the key value and/or chaining them
```ruby
report = Cic::Report.find('#Y1UI')report.ticket
#=> '#Y1UI'category = Cic::Category.all.first
category.name
#=> "AVISOS"group = Cic::Group.all.first
group.name
#=> "Asesorias Generales"
```
## Contributing1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Added some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request## Changelog
- Current gem version 1.0.0
- Previous gem version 0.0.1
- Add post method to create reports
- Refactor for code reuse
- GET requests for all entities
## Devs
- Abraham Kuri Vargas (@kurenn)
## Future
- Add post method to create reports
## Credits
Icalia Labs - [email protected]
[Follow us](http://twitter.com/icalialabs "Follow us")
[Like us on Facebook](https://www.facebook.com/icalialab "Like us on Facebook")
## License
Copyright (c) 2011 Icalia Labs
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/gpl.html.