Skip to content

Commit eb1a1d2

Browse files
Merge pull request #63 from DripEmail/extract_content_type_constant
Extract content type to constant
2 parents 1f70c34 + 7506fdf commit eb1a1d2

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1212
- `Drip::Client#url_prefix` parameter no longer includes `/vN` part of the URL in order to prepare for Shopper Activity API. This breaks backwards compatibility for this option, but there is no expected production usage of this parameter.
1313
- `Drip::Client#get`, `Drip::Client#post`, `Drip::Client#put`, and `Drip::Client#delete` methods no longer auto-prepend `/v2` if the given path starts with `v2/` or `v3/`. This behavior is deprecated and will produce a warning. If you are using one of these methods and get this warning, just add `v2/` to the beginning of the path when you call it.
1414
- `Drip::Client#generate_resource` is deprecated and will be removed in a future version.
15+
- `Drip::Client#content_type` is deprecated and will be removed in a future version. It is no longer used internally, effective immediately.
1516

1617
### Removed
1718
- Drop support for Ruby 2.1.

lib/drip/client.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
require "json"
2020

2121
module Drip
22-
class Client
22+
class Client # rubocop:disable Metrics/ClassLength
2323
include Accounts
2424
include Broadcasts
2525
include Campaigns
@@ -39,6 +39,9 @@ class Client
3939

4040
attr_accessor :access_token, :api_key, :account_id, :url_prefix, :http_open_timeout, :http_timeout
4141

42+
JSON_API_CONTENT_TYPE = "application/vnd.api+json".freeze
43+
private_constant :JSON_API_CONTENT_TYPE
44+
4245
def initialize(options = {})
4346
@account_id = options[:account_id]
4447
@access_token = options[:access_token]
@@ -55,7 +58,8 @@ def generate_resource(key, *args)
5558
end
5659

5760
def content_type
58-
'application/vnd.api+json'
61+
warn "[DEPRECATED] Drip::Client#content_type is deprecated and will be removed in a future version"
62+
JSON_API_CONTENT_TYPE
5963
end
6064

6165
def get(url, options = {})
@@ -105,7 +109,7 @@ def make_request(verb_klass, uri, options, step = 0)
105109
end
106110

107111
request['User-Agent'] = "Drip Ruby v#{Drip::VERSION}"
108-
request['Content-Type'] = content_type
112+
request['Content-Type'] = JSON_API_CONTENT_TYPE
109113
request['Accept'] = "*/*"
110114

111115
if access_token

0 commit comments

Comments
 (0)