{"id":26430787,"url":"https://github.com/rukomoynikov/act_as_api_client","last_synced_at":"2025-09-08T07:40:24.375Z","repository":{"id":40697897,"uuid":"507370243","full_name":"Rukomoynikov/act_as_api_client","owner":"Rukomoynikov","description":"Templates for popular API's and reliable way to create your own clients","archived":false,"fork":false,"pushed_at":"2024-12-01T17:32:42.000Z","size":554,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-30T14:49:32.932Z","etag":null,"topics":["api-rest","ruby"],"latest_commit_sha":null,"homepage":"https://rukomoynikov.github.io/act_as_api_client/","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/Rukomoynikov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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}},"created_at":"2022-06-25T17:05:37.000Z","updated_at":"2024-12-02T14:00:28.000Z","dependencies_parsed_at":"2024-11-29T19:25:27.817Z","dependency_job_id":"3520f758-2b64-4b50-8765-641a9e3064b7","html_url":"https://github.com/Rukomoynikov/act_as_api_client","commit_stats":{"total_commits":27,"total_committers":2,"mean_commits":13.5,"dds":0.07407407407407407,"last_synced_commit":"374ce425078bce1a1cd261ea1d261144808e8ba1"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/Rukomoynikov/act_as_api_client","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rukomoynikov%2Fact_as_api_client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rukomoynikov%2Fact_as_api_client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rukomoynikov%2Fact_as_api_client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rukomoynikov%2Fact_as_api_client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Rukomoynikov","download_url":"https://codeload.github.com/Rukomoynikov/act_as_api_client/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Rukomoynikov%2Fact_as_api_client/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274152765,"owners_count":25231293,"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","status":"online","status_checked_at":"2025-09-08T02:00:09.813Z","response_time":121,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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-rest","ruby"],"created_at":"2025-03-18T05:34:25.535Z","updated_at":"2025-09-08T07:40:24.347Z","avatar_url":"https://github.com/Rukomoynikov.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# act_as_api_client\n\nHow to create api clients for your application? What is a better way to encapsualte interactions with third party APIs? My answer is `act_as_api_client`.\n\nLet's assume you have a typical Rails or any ruby application and want to play around with an API, Github for example. See the [Usage](https://github.com/Rukomoynikov/act_as_api_client#usage) section to find how to use existing preconfigured API's and encapsulate all logic inside `APIClient` classes.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'act_as_api_client'\n```\n\nAnd then execute:\n\n    $ bundle install\n\nOr install it yourself as:\n\n    $ gem install act_as_api_client\n\n## Usage\n\n### Folder for clients:\nCreate a folder in your app for examples `api_clients`. This will be the place where you will keep all servies responsible for communication with external HTTP APIs.\n\n### Create API client class:\nFor example, you need to fetch and update Github repositories, then you class may have a form like this:\n\n```ruby\nclass GithubClient \u003c ApiClient\n  act_as_api_client for: :github_repositories\nend\n```\n\nIn case you want to provide and use authorization token for Github: \n\n```ruby\nclass GithubClient \u003c ApiClient\n  act_as_api_client for: :github_repositories,\n                    with: {\n                      token: \u003cyour_token\u003e # ENV variable of secret\n                    }\nend\n```\nbtw, all values from `with` hash will be availabe in tour clients as instance variable `@options`\n\n### Use it:\nLet's fetch all repositories from Rails organization:\n\n```ruby\ngithub_client = GithubClient.new()\n\ngithub_client.find('Rukomoynikov/tabled')\ngithub_client.find_by(organization: 'rails')\ngithub_client.where('rails', per_page: 100)\n```\n\nVoila.\n\n## List of supported API clients\n1. [Github Repositories](https://rubydoc.info/github/Rukomoynikov/act_as_api_client/ActAsApiClient/Clients/GithubClient)\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frukomoynikov%2Fact_as_api_client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frukomoynikov%2Fact_as_api_client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frukomoynikov%2Fact_as_api_client/lists"}