{"id":29287357,"url":"https://github.com/carwow/restful_resource","last_synced_at":"2026-03-05T16:48:07.699Z","repository":{"id":19440472,"uuid":"22684317","full_name":"carwow/restful_resource","owner":"carwow","description":"Simple and reliable ruby gem to retrieve structured Ruby objects out of JSON APIs","archived":false,"fork":false,"pushed_at":"2025-04-15T10:10:10.000Z","size":286,"stargazers_count":7,"open_issues_count":3,"forks_count":0,"subscribers_count":52,"default_branch":"main","last_synced_at":"2025-05-17T19:16:32.800Z","etag":null,"topics":["api-client","caching","rails","validations"],"latest_commit_sha":null,"homepage":"http://rubygems.org/gems/restful_resource","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/carwow.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-08-06T13:52:29.000Z","updated_at":"2025-04-15T10:10:12.000Z","dependencies_parsed_at":"2024-03-04T17:14:26.362Z","dependency_job_id":"c268f8af-6209-41a5-81d0-a3fce8a5fdcb","html_url":"https://github.com/carwow/restful_resource","commit_stats":{"total_commits":209,"total_committers":32,"mean_commits":6.53125,"dds":0.8421052631578947,"last_synced_commit":"59e1a0f018c0ef5931cbf1179232387fbf209b1c"},"previous_names":[],"tags_count":108,"template":false,"template_full_name":null,"purl":"pkg:github/carwow/restful_resource","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Frestful_resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Frestful_resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Frestful_resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Frestful_resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/carwow","download_url":"https://codeload.github.com/carwow/restful_resource/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/carwow%2Frestful_resource/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263833416,"owners_count":23517374,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-client","caching","rails","validations"],"created_at":"2025-07-06T01:07:01.861Z","updated_at":"2026-03-05T16:48:07.656Z","avatar_url":"https://github.com/carwow.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RestfulResource ![build status](https://circleci.com/gh/carwow/restful_resource.svg?style=shield\u0026circle-token=0558310359000e8786d1fe42774b0e30b2b0e12c) [![Maintainability](https://api.codeclimate.com/v1/badges/61c85db718d559aa97c5/maintainability)](https://codeclimate.com/github/carwow/restful_resource/maintainability)\n\nProvides an ActiveResource like interface to JSON API's\n\n## Caching\n\nCaching using [faraday-http-cache](https://github.com/plataformatec/faraday-http-cache)\n\nEnabled by passing an initialsed cache object (eg Rails.cache)\n\n```\nRestfulResource::Base.configure(\n  base_url: \"http://my.api.com/\",\n  cache_store: Rails.cache\n)\n```\n\n### Bypassing the cache\n\nTo make requests that bypass the local HTTP cache use the `no_cache: true` option eg:\n\n```\nObject.find(1, no_cache: true)\n```\n\n\n## Metrics\n\n### HTTP Metrics\n\nHttp requests are automatically instrumented using ActiveSupport::Notifications\n\nA Metrics class can be provided that RestfulResource will use to emit metrics. This class needs to respond to `count, sample, measure` methods.\n\neg\n\n```\nRestfulResource::Base.configure(\n  base_url: \"http://my.api.com/\",\n  instrumentation: {\n    metric_class: Metrics,  # Required\n    app_name: 'rails_site', # Required\n    api_name: 'api'         # Optional, defaults to 'api'\n  }\n)\n```\n\nWhere the `Metrics` class has in interface like:\n\n```\nclass Metrics\n  module_function\n\n  def count(name, i)\n  end\n\n  def sample(name, i)\n  end\n\n  def measure(name, i)\n  end\nend\n```\n\nThis will call the methods on the Metrics class with:\n```\nMetrics.measure('rails_site.api.time', 215.161237) # Time taken\nMetrics.sample('rails_site.api.status', 200) # HTTP status code\nMetrics.count('rails_site.api.called, 1)\n```\n\nNote: To customize the names we can specify `:app_name` and `:api_name` options to `RestfulResource::Base.configure`\n\n### HTTP Cache Metrics\n\nEnable Http caching:\n\n```\nRestfulResource::Base.configure(\n  base_url: \"http://my.api.com/\",\n  cache_store: Rails.cache,\n  instrumentation: {\n    metric_class: Metrics,\n    app_name: 'rails_site',\n    api_name: 'api'\n  }\n)\n```\n\nThis will call the methods on the Metrics class with:\n```\nMetrics.sample('rails_site.api.cache_hit', 1) # When a request is served from the cache\nMetrics.sample('rails_site.api.cache_miss', 1) # When a request is fetched from the remote API\nMetrics.sample('rails_site.api.cache_bypass', 1) # When a request did not go through the cache at all\n```\n\n## Contributing\n\n1. Fork it\n2. Create your feature branch (`git checkout -b my-new-feature`)\n3. Commit your changes (`git commit -am 'Add some feature'`)\n4. Push to the branch (`git push origin my-new-feature`)\n5. Create new Pull Request\n\n## Releasing new version\n\n1. Amend the `version.rb` to your desired version on your Pull Request \u0026 get it merged\n2. Pull latest `main` \u0026 create a matching tag e.g.: `git tag -a v2.15.0 -m \"Bump Faraday to a minimum 1.10\"`\n3. Push the tag e.g.: ` git push origin v2.15.0`\n4. Run `bundle exec rake release`\n    - You'll need to authenticate with RubyGems, the credentials are in [Bitwarden](https://vault.bitwarden.com/#/vault?search=ruby\u0026itemId=54601528-29be-494f-ba3c-aa3300d5dd18)\n\n## Planned Features\n\n### Core\n  - Test that has_many and has_one pick correct class for children (if defined)\n  - Make base_url resilient when missing trailing slash\n  - Implement http authentication\n\n### Active record style validation\n\n### Constraints(mandatory fields)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarwow%2Frestful_resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcarwow%2Frestful_resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcarwow%2Frestful_resource/lists"}