{"id":17598937,"url":"https://github.com/wolox/wor-requests","last_synced_at":"2025-04-30T06:40:32.906Z","repository":{"id":56898553,"uuid":"83826791","full_name":"Wolox/wor-requests","owner":"Wolox","description":"Make external requests in you service objects, with easy logging and error handling!","archived":false,"fork":false,"pushed_at":"2020-02-12T20:01:19.000Z","size":104,"stargazers_count":12,"open_issues_count":2,"forks_count":7,"subscribers_count":27,"default_branch":"master","last_synced_at":"2025-04-14T02:34:27.784Z","etag":null,"topics":["api","rails","requests","ruby","ruby-gem","services","wolox","wor"],"latest_commit_sha":null,"homepage":"https://wolox.github.io/wor-requests/","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/Wolox.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-03T18:03:21.000Z","updated_at":"2023-05-19T14:38:27.000Z","dependencies_parsed_at":"2022-08-21T02:20:37.523Z","dependency_job_id":null,"html_url":"https://github.com/Wolox/wor-requests","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fwor-requests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fwor-requests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fwor-requests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Wolox%2Fwor-requests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Wolox","download_url":"https://codeload.github.com/Wolox/wor-requests/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251657405,"owners_count":21622813,"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","rails","requests","ruby","ruby-gem","services","wolox","wor"],"created_at":"2024-10-22T10:08:19.304Z","updated_at":"2025-04-30T06:40:32.871Z","avatar_url":"https://github.com/Wolox.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Wolox on Rails - Requests\n[![Gem Version](https://badge.fury.io/rb/wor-requests.svg)](https://badge.fury.io/rb/wor-requests)\n[![Build Status](https://travis-ci.org/Wolox/wor-requests.svg)](https://travis-ci.org/Wolox/wor-requests)\n[![Code Climate](https://codeclimate.com/github/Wolox/wor-requests/badges/gpa.svg)](https://codeclimate.com/github/Wolox/wor-requests)\n\nMake external requests in you service objects, with easy logging and error handling!\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'wor-requests'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install wor-requests\n\nThen you can run `rails generate wor:requests:install` to create the initializer:\n\n```ruby\n# config/initializers/wor_requests.rb\n\nWor::Requests.configure do |config|\n  config.logger = Rails.logger\nend\n```\n\n## Generators\n```ruby\nrails generate wor:requests:service NAME\n```\n\n### Generator options\n#### module\nSpecifying the module name as:\n\n```ruby\nrails generate wor:requests:service NAME --module MODULE_NAME\n```\nWe can create a service with an inner class called NAME, and external module called MODULE_NAME\n\n```ruby\nmodule ModuleName\n  class NameService \u003c Wor::Requests::Base\n    # Your code here\n  end\nend\n```\n\n## Service example\nTo write your first Service using Wor-requests you can write something like this:\n\n```ruby\nrequire 'wor/requests'\n\nclass GithubService \u003c Wor::Requests::Base\n  def repositories(username)\n    get(\n      attempting_to: \"get repositories of #{username}\",\n      path: \"/users/#{username}/repos\"\n    )\n  rescue Wor::Requests::RequestError =\u003e e\n    puts e.message\n  end\n\n  protected\n\n  def base_url\n    'https://api.github.com'\n  end\nend\n\nputs GithubService.new.repositories('wolox')\n```\n\nIf you need to get the response headers, add a block in the call with the headers output\n\n```ruby\nGithubService.new.repositories('wolox') do |response|\n  puts response.headers\nend\n```\n\nIf you need to send body parameters in a post request you can write something like this:\n\n```ruby\nrequire 'wor/requests'\n\nclass ExternalService \u003c Wor::Requests::Base\n  def post_request_example(authorization)\n    post(\n      attempting_to: 'Make a POST request to an external service.',\n      path: '/some_endpoint',\n      headers: {\n        Authorization: authorization,\n        'Content-type' =\u003e 'application/json'\n      },\n      body: {\n        # Some Json\n      }\n    )\n  end\n\n  protected\n\n  def base_url\n    'https://external.service.com'\n  end\nend\n\nExternalService.new.post_request_example(token)\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. Run rubocop lint (`rubocop -R --format simple`)\n5. Run rspec tests (`bundle exec rspec`)\n6. Push your branch (`git push origin my-new-feature`)\n7. Create a new Pull Request\n\n## About ##\nThis project was developed by [Diego Raffo](https://github.com/enanodr) along with [Michel Agopian](https://github.com/mishuagopian) and it was written by [Wolox](http://www.wolox.com.ar).\n\nMaintainers: [Samir Tapiero](https://github.com/blacksam07)\n\nContributors: [Diego Raffo](https://github.com/enanodr) [Michel Agopian](https://github.com/mishuagopian)\n\n![Wolox](https://raw.githubusercontent.com/Wolox/press-kit/master/logos/logo_banner.png)\n\n## License\n\n**wor-requests** is available under the MIT [license](https://raw.githubusercontent.com/Wolox/wor-requests/master/LICENSE.md).\n\n    Copyright (c) 2017 Wolox\n\n    Permission is hereby granted, free of charge, to any person obtaining a copy\n    of this software and associated documentation files (the \"Software\"), to deal\n    in the Software without restriction, including without limitation the rights\n    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n    copies of the Software, and to permit persons to whom the Software is\n    furnished to do so, subject to the following conditions:\n\n    The above copyright notice and this permission notice shall be included in\n    all copies or substantial portions of the Software.\n\n    THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n    THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolox%2Fwor-requests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwolox%2Fwor-requests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwolox%2Fwor-requests/lists"}