{"action":"created","issue":{"url":"https://api.github.com/repos/Nexmo/nexmo-ruby/issues/47","repository_url":"https://api.github.com/repos/Nexmo/nexmo-ruby","labels_url":"https://api.github.com/repos/Nexmo/nexmo-ruby/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/Nexmo/nexmo-ruby/issues/47/comments","events_url":"https://api.github.com/repos/Nexmo/nexmo-ruby/issues/47/events","html_url":"https://github.com/Nexmo/nexmo-ruby/pull/47","id":146387652,"number":47,"title":"Ability to override API base url & use different types of hosts","user":{"login":"mertguldur","id":1219048,"avatar_url":"https://avatars.githubusercontent.com/u/1219048?v=3","gravatar_id":"","url":"https://api.github.com/users/mertguldur","html_url":"https://github.com/mertguldur","followers_url":"https://api.github.com/users/mertguldur/followers","following_url":"https://api.github.com/users/mertguldur/following{/other_user}","gists_url":"https://api.github.com/users/mertguldur/gists{/gist_id}","starred_url":"https://api.github.com/users/mertguldur/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mertguldur/subscriptions","organizations_url":"https://api.github.com/users/mertguldur/orgs","repos_url":"https://api.github.com/users/mertguldur/repos","events_url":"https://api.github.com/users/mertguldur/events{/privacy}","received_events_url":"https://api.github.com/users/mertguldur/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-04-06T17:56:20Z","updated_at":"2016-05-05T10:47:12Z","closed_at":"2016-05-05T10:47:12Z","pull_request":{"url":"https://api.github.com/repos/Nexmo/nexmo-ruby/pulls/47","html_url":"https://github.com/Nexmo/nexmo-ruby/pull/47","diff_url":"https://github.com/Nexmo/nexmo-ruby/pull/47.diff","patch_url":"https://github.com/Nexmo/nexmo-ruby/pull/47.patch"},"body":"This gives ability to \r\n\r\n- Override the base URL of https://api.nexmo.com requests.\r\n- Provide a host with HTTP or HTTPS.\r\n- Use HTTPS by default for hosts without a specified protocol. (to ensure backward compatibility with current behavior)"},"comment":{"url":"https://api.github.com/repos/Nexmo/nexmo-ruby/issues/comments/217122861","html_url":"https://github.com/Nexmo/nexmo-ruby/pull/47#issuecomment-217122861","issue_url":"https://api.github.com/repos/Nexmo/nexmo-ruby/issues/47","id":217122861,"user":{"login":"timcraft","id":896098,"avatar_url":"https://avatars.githubusercontent.com/u/896098?v=3","gravatar_id":"","url":"https://api.github.com/users/timcraft","html_url":"https://github.com/timcraft","followers_url":"https://api.github.com/users/timcraft/followers","following_url":"https://api.github.com/users/timcraft/following{/other_user}","gists_url":"https://api.github.com/users/timcraft/gists{/gist_id}","starred_url":"https://api.github.com/users/timcraft/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timcraft/subscriptions","organizations_url":"https://api.github.com/users/timcraft/orgs","repos_url":"https://api.github.com/users/timcraft/repos","events_url":"https://api.github.com/users/timcraft/events{/privacy}","received_events_url":"https://api.github.com/users/timcraft/received_events","type":"User","site_admin":false},"created_at":"2016-05-05T10:47:12Z","updated_at":"2016-05-05T10:47:12Z","body":"@mertguldur Because I disagree with the overall approach in the implementation, i.e. using symbol arguments to switch hosts. I'd also disagree with the implementations of make_request and build_uri, both in their naming and in the behaviour (i.e. allowing a host value with a protocol, and making it a bit too easy to send insecure requests without ssl). There are also some arbitrary changes, e.g. spaces around hash brackets, and renaming of variables.\r\n\r\nI've added an api_host option in v4.1.0 which you can use to send api.nexmo.com requests to a mock server or a service like runscope. I've also refactored those private methods a bit so if you want to send requests without ssl in a certain environments you could do something like this:\r\n\r\n```ruby\r\nclass InsecureNexmoClient < Nexmo::Client\r\n  if ENV['NEXMO_URI_SCHEME'] == 'HTTP' # TODO: whatever logic you need\r\n    def request(uri, message)\r\n      http = Net::HTTP.new(uri.host, Net::HTTP.http_default_port)\r\n      http.request(message)\r\n    end\r\n  end\r\nend\r\n```\r\n\r\nThere are various ways you could monkey-patch Nexmo::Client if you prefer not to use a subclass. Together that should give you the functionality you need.\r\n\r\nWhilst it might be more convenient for you, I don't think it's wise exposing an easy option for sending insecure requests because developers will lean on that when they have problems with ssl."}}