ruby_http_client 3.4.0 → 3.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a76e3392d677cadaf41d419bdec64bafc4ddda722b1c805171cec97ff27767da
4
- data.tar.gz: 101c510d5c659e4108073466b6c963b54405fb770ccecd4f398c0b3328c9fd56
3
+ metadata.gz: 8e31d36787f9a9884ba0058c32dd4afcc9819c85449f9219fbfd06875a234ae5
4
+ data.tar.gz: 8d050bdebb3367d89ae53ebb83d1a2f0f7f2e639a9dec3d27cd71b819848c3d7
5
5
  SHA512:
6
- metadata.gz: be8d8d553070cde4f609c23a8b24392c92260dc01146391f60e0cb095d620f4b8d7ca013283d8384150b0729ce61902972e9072c82ae9e67fcbaaddd57594406
7
- data.tar.gz: e29ca74e02e911742d5d3af6e4ee537d78033e71ee4764762c8f092c76955bff5f377fa8b77070bf3c2bd73ee26578cbd04db0bdb1dd807567122bc17b5c0198
6
+ metadata.gz: d1bad69c5dd5b3c5195e62977f75b47ee584b8f9d0a096580ad447d23abbf6e1cae11b1532301689ea8668efc6ab0531ce9380e10f0afb72d87764a10a26e7aa
7
+ data.tar.gz: 3e396c3fa726e05f571b56af4c8209d081f4f1e0e553dfeeb8d397fdc7c242bb8a3d2d94135c68ad3a4637f1d23212547fa8d6c1da13eed1b2f483b5a8d6861d
data/.rubocop.yml CHANGED
@@ -23,13 +23,13 @@ Metrics/ModuleLength:
23
23
  Enabled: false
24
24
  PerceivedComplexity:
25
25
  Enabled: false
26
- Style/SpaceBeforeFirstArg:
26
+ Layout/SpaceBeforeFirstArg:
27
27
  Enabled: true
28
28
  Style/ClassAndModuleChildren:
29
29
  Enabled: false
30
- Style/EmptyLinesAroundBlockBody:
30
+ Layout/EmptyLinesAroundBlockBody:
31
31
  Enabled: true
32
- Style/FileName:
32
+ Naming/FileName:
33
33
  Enabled: true
34
34
  Style/RescueModifier:
35
35
  Enabled: true
@@ -39,7 +39,7 @@ Metrics/BlockLength:
39
39
  Enabled: false
40
40
  Style/NumericLiterals:
41
41
  Enabled: false
42
- Style/ExtraSpacing:
42
+ Layout/ExtraSpacing:
43
43
  Enabled: true
44
44
  AllowForAlignment: false
45
45
  ForceEqualSignAlignment: false
data/.travis.yml CHANGED
@@ -1,46 +1,31 @@
1
1
  env:
2
2
  global:
3
- - CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID
4
-
3
+ - CC_TEST_REPORTER_ID=$CC_TEST_REPORTER_ID
5
4
  language: ruby
6
5
  rvm:
7
- - ruby-head
8
- - 2.6
9
- - 2.5
10
- - 2.4
11
- - jruby
12
-
6
+ - ruby-head
7
+ - 2.6
8
+ - 2.5
9
+ - 2.4
10
+ - jruby
13
11
  before_install:
14
12
  - gem install minitest
15
13
  - gem install simplecov
16
-
17
- notifications:
18
- hipchat:
19
- rooms:
20
- secure: S0K355wxCRxwK2cOmbcVOaQitRtIEIq0OEEW7JZp8XtooupGwpmJSm22gqeo7GR6eidqlV8Tp6SUffpLE6SvS0hed3LDbJw7oWoXA7XvRp7gh/AKvLZ0e2uz/a1WPSYy0gNS3TJ72PcyoMS6rPCKR0FyDu8mQ2sW8CpZG07NDCmJPgO+dKfnpeuEmElZoh0AZxE6u1RjvUdSzxnmCVjve621ghtMaKInd0fnNPOM6tm9L0HKSbaLI/buphYhQ/DLpO+dLvt7W2yN+9BwaGqPv7X04Sn0UVAu9+EjSouLLBVNRIsdUfgRGeooStm8/Iw0c1brY4goyYJxGs0TiPkfPeWJcNmQ68YSZLDhUGoMZWCZwGq0Lm/oThJX8K777r3qt0Td4iAXNG+bVN+1KZtZRra6B/qBKBcpTTs1p4WRfIUY9D6udwyWZMcGEOFecsyt/MRlkjdmu+zSvZsadvhvQCL+m+aUmTtlUbswXu46g5NxQrHS9UKzzPkk/3mUrO1r4HLhhuuNtn3LRMbx9WVMdidMiFaAxG99VFC0Gon//FMvpTShNrRRuNSW7EJ0V8gwpx69SticfxC88pfka/MEeY9KoZc3MJdILbpgLK5oPuFMih2F/emJP1muWnk8mjaEHqHPqnSuKRr4oqO1xbh+r2ggKW58akCe08a4TihD4rg=
21
- template:
22
- - '<a href="https://travis-ci.org/%{repository}/builds/%{build_id}">%{repository}
23
- Build %{build_number}</a> on branch <i>%{branch}</i> by %{author}: <strong>%{message}</strong>
24
- <a href="https://github.com/sendgrid/%{repository}/commits/%{commit}">View on GitHub</a>'
25
- format: html
26
- notify: false
27
-
28
14
  before_script:
29
- - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
30
- - chmod +x ./cc-test-reporter
31
- - ./cc-test-reporter before-build
32
-
15
+ - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64
16
+ > ./cc-test-reporter
17
+ - chmod +x ./cc-test-reporter
18
+ - "./cc-test-reporter before-build"
33
19
  script:
34
- - rake
35
-
20
+ - rake
36
21
  after_script:
37
- - ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
38
-
22
+ - "./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT"
39
23
  deploy:
40
24
  provider: rubygems
41
25
  api_key:
42
- secure: CWlfN170i/fHPrIufHHLWQ0utjuhxf4ELSxKeypIuO2CNTqNMzocDAa2vxMt4XfO6d2wFPV/LC+IHR7i+sp7PKvjRoa4BLUUxjfBNDboc0gGESeUYlAxwsJo0tOVCNmpxgjQKqtPLz/19A/v/xpxLv2Im/9Idqa5ATd06sMDdM8=
43
- gem: ruby-http-client
26
+ secure: ubaCqrwnHN4TzLhFyM7/2WPicNya2FSeKbZiG9zqGGTklTNi3T/pP1BUDdVQGNSOsvBl/s20P6M+aKL6KTH9t4JpS4laFgI3iwBWyg4Q4fcchDMOrtMaChR7FvIfvOOFcCQYvvMB/U+Mr9GSnKkVHmcu2JQgZM/kBSst3FymAQeRa8+64IKg2s/DjPejT4aTvyuqJ75xN+pkCbv36KHic1jrKZgpSdWZ7UaOZfBJ7xdReCXYXignKFJs1240O1yfIyikFrgTs75Ch7/OmI792CaFIKIvODg97wYlCnu0FYCOxNfZw2JVwp+oYqXRkI5l2ljXWFvjPxdckGSP7rM4lL9GxSgVqgqBd1orXyab2Ad+POlbx97wEmoYLbIF4BHGoe7nXV7BXquQDWIm2o5vx5RxenTnWMOZNLbRBVUAdRbxrxW8iQhTRs+jjeJu3Cj9alWd7UPB/t2v8/c9MpOCNdH+QyAJW6dvZrKTyy75CofGAYbzezp2DA91IXAELiFQaPhCXXzkOTVHCh9+mBYG7b0t1iXQoN+MMcyQ3q89coZDxI1l77keNPbj8GcQQ35fRxRhmgsID+mQfuYXgkx8aTs5MYwJWy+sxyOrEBMAyehDhdk0JZjJdYhgsh+zIqfpy9meZIxNxNQ7+s1EGoFW4RggKark2t9Y8NML7hX+xIc=
27
+ gem: sendgrid-ruby
44
28
  on:
45
29
  tags: true
46
30
  rvm: '2.4'
31
+ skip_cleanup: true
data/CHANGELOG.md CHANGED
@@ -3,6 +3,24 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ [2020-02-19] Version 3.4.3
7
+ --------------------------
8
+ **Library - Fix**
9
+ - [PR #95](https://github.com/sendgrid/ruby-http-client/pull/95): JSON body reencoding and Rubocop configuration. Thanks to [@guillemm](https://github.com/guillemm)!
10
+
11
+
12
+ [2020-01-22] Version 3.4.2
13
+ --------------------------
14
+ **Library - Fix**
15
+ - [PR #114](https://github.com/sendgrid/ruby-http-client/pull/114): add skip_cleanup flag to fix travis deploy. Thanks to [@thinkingserious](https://github.com/thinkingserious)!
16
+
17
+
18
+ [2020-01-22] Version 3.4.1
19
+ --------------------------
20
+ **Library - Docs**
21
+ - [PR #113](https://github.com/sendgrid/ruby-http-client/pull/113): baseline all the templated markdown docs. Thanks to [@childish-sambino](https://github.com/childish-sambino)!
22
+
23
+
6
24
  [2020-01-09] Version 3.4.0
7
25
  --------------------------
8
26
  **Library - Fix**
data/CODE_OF_CONDUCT.md CHANGED
@@ -1,41 +1,73 @@
1
- # SendGrid Community Code of Conduct
1
+ # Contributor Covenant Code of Conduct
2
2
 
3
- The SendGrid open source community is made up of members from around the globe with a diverse set of skills, personalities, and experiences. It is through these differences that our community experiences successes and continued growth. When you're working with members of the community, we encourage you to follow these guidelines, which help steer our interactions and strive to maintain a positive, successful and growing community.
3
+ ## Our Pledge
4
4
 
5
- ### Be Open
6
- Members of the community are open to collaboration, whether it's on pull requests, code reviews, approvals, issues or otherwise. We're receptive to constructive comments and criticism, as the experiences and skill sets of all members contribute to the whole of our efforts. We're accepting of all who wish to take part in our activities, fostering an environment where anyone can participate, and everyone can make a difference.
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, sex characteristics, gender identity and expression,
9
+ level of experience, education, socio-economic status, nationality, personal
10
+ appearance, race, religion, or sexual identity and orientation.
7
11
 
8
- ### Be Considerate
9
- Members of the community are considerate of their peers, which include other contributors and users of SendGrid. We're thoughtful when addressing the efforts of others, keeping in mind that often the labor was completed with the intent of the good of the community. We're attentive in our communications, whether in person or online, and we're tactful when approaching differing views.
12
+ ## Our Standards
10
13
 
11
- ### Be Respectful
12
- Members of the community are respectful. We're respectful of others, their positions, their skills, their commitments and their efforts. We're respectful of the volunteer efforts that permeate the SendGrid community. We're respectful of the processes outlined in the community, and we work within them. When we disagree, we are courteous in raising our issues. Overall, we're good to each other. We contribute to this community not because we have to, but because we want to. If we remember that, these guidelines will come naturally.
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
13
16
 
14
- ## Additional Guidance
17
+ - Using welcoming and inclusive language
18
+ - Being respectful of differing viewpoints and experiences
19
+ - Gracefully accepting constructive criticism
20
+ - Focusing on what is best for the community
21
+ - Showing empathy towards other community members
15
22
 
16
- ### Disclose Potential Conflicts of Interest
17
- Community discussions often involve interested parties. We expect participants to be aware when they are conflicted due to employment or other projects they are involved in and disclose those interests to other project members. When in doubt, over-disclose. Perceived conflicts of interest are important to address so that the community’s decisions are credible even when unpopular, difficult or favorable to the interests of one group over another.
23
+ Examples of unacceptable behavior by participants include:
18
24
 
19
- ### Interpretation
20
- This Code is not exhaustive or complete. It is not a rulebook; it serves to distill our common understanding of a collaborative, shared environment and goals. We expect it to be followed in spirit as much as in the letter. When in doubt, try to abide by [SendGrid’s cultural values](https://sendgrid.com/blog/employee-engagement-the-4h-way) defined by our “4H’s”: Happy, Hungry, Humble and Honest.
25
+ - The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ - Trolling, insulting/derogatory comments, and personal or political attacks
28
+ - Public or private harassment
29
+ - Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ - Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
21
33
 
22
- ### Enforcement
23
- Most members of the SendGrid community always comply with this Code, not because of the existence of this Code, but because they have long experience participating in open source communities where the conduct described above is normal and expected. However, failure to observe this Code may be grounds for suspension, reporting the user for abuse or changing permissions for outside contributors.
34
+ ## Our Responsibilities
24
35
 
25
- ## If you have concerns about someone’s conduct
26
- **Initiate Direct Contact** - It is always appropriate to email a community member (if contact information is available), mention that you think their behavior was out of line, and (if necessary) point them to this Code.
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
27
39
 
28
- **Discuss Publicly** - Discussing publicly is always acceptable. Note, though, that approaching the person directly may be better, as it tends to make them less defensive, and it respects the time of other community members, so you probably want to try direct contact first.
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
29
45
 
30
- **Contact the Moderators** - You can reach the SendGrid moderators by emailing dx@sendgrid.com.
46
+ ## Scope
31
47
 
32
- ## Submission to SendGrid Repositories
33
- Finally, just a reminder, changes to the SendGrid repositories will only be accepted upon completion of the [SendGrid Contributor Agreement](https://cla.sendgrid.com).
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at open-source@twilio.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
34
67
 
35
68
  ## Attribution
36
69
 
37
- SendGrid thanks the following, on which it draws for content and inspiration:
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
38
72
 
39
- * [Python Community Code of Conduct](https://www.python.org/psf/codeofconduct/)
40
- * [Open Source Initiative General Code of Conduct](https://opensource.org/codeofconduct)
41
- * [Apache Code of Conduct](https://www.apache.org/foundation/policies/conduct.html)
73
+ [homepage]: https://www.contributor-covenant.org
data/CONTRIBUTING.md CHANGED
@@ -51,7 +51,7 @@ Before you decide to create a new issue, please try the following:
51
51
 
52
52
  ### Please use our Bug Report Template
53
53
 
54
- In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/ruby-http-client/.github/ISSUE_TEMPLATE) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
54
+ In order to make the process easier, we've included a [sample bug report template](https://github.com/sendgrid/ruby-http-client/ISSUE_TEMPLATE.md) (borrowed from [Ghost](https://github.com/TryGhost/Ghost/)). The template uses [GitHub flavored markdown](https://help.github.com/articles/github-flavored-markdown/) for formatting.
55
55
 
56
56
  <a name="improvements-to-the-codebase"></a>
57
57
  ## Improvements to the Codebase
data/ISSUE_TEMPLATE.md ADDED
@@ -0,0 +1,26 @@
1
+ <!--
2
+ If this is a feature request, make sure you search Issues for an existing request before creating a new one!
3
+ -->
4
+
5
+ ### Issue Summary
6
+ A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, or code examples.
7
+
8
+ ### Steps to Reproduce
9
+ 1. This is the first step
10
+ 2. This is the second step
11
+ 3. Further steps, etc.
12
+
13
+ ### Code Snippet
14
+ ```ruby
15
+ # paste code here
16
+ ```
17
+
18
+ ### Exception/Log
19
+ ```
20
+ # paste exception/log here
21
+ ```
22
+
23
+ ### Technical details:
24
+ * ruby-http-client version:
25
+ * ruby version:
26
+
@@ -1,13 +1,13 @@
1
- The MIT License (MIT)
1
+ MIT License
2
2
 
3
- Copyright (c) 2016-2020 Twilio SendGrid, Inc.
3
+ Copyright (C) 2020, Twilio SendGrid, Inc. <help@twilio.com>
4
4
 
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
9
+ of the Software, and to permit persons to whom the Software is furnished to do
10
+ so, subject to the following conditions:
11
11
 
12
12
  The above copyright notice and this permission notice shall be included in all
13
13
  copies or substantial portions of the Software.
@@ -0,0 +1,31 @@
1
+ <!--
2
+ We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines, then fill out the blanks below.
3
+
4
+ Please format the PR title appropriately based on the type of change:
5
+ <type>[!]: <description>
6
+ Where <type> is one of: docs, chore, feat, fix, test.
7
+ Add a '!' after the type for breaking changes (e.g. feat!: new breaking feature).
8
+
9
+ **All third-party contributors acknowledge that any contributions they provide will be made under the same open-source license that the open-source project is provided under.**
10
+
11
+ Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged!
12
+ e.g.
13
+ Fixes #1
14
+ Closes #2
15
+ -->
16
+
17
+ # Fixes #
18
+
19
+ A short description of what this PR does.
20
+
21
+ ### Checklist
22
+ - [ ] I acknowledge that all my contributions will be made under the project's license
23
+ - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
24
+ - [ ] I have read the [Contribution Guidelines](CONTRIBUTING.md) and my PR follows them
25
+ - [ ] I have titled the PR appropriately
26
+ - [ ] I have updated my branch with the master branch
27
+ - [ ] I have added tests that prove my fix is effective or that my feature works
28
+ - [ ] I have added necessary documentation about the functionality in the appropriate .md file
29
+ - [ ] I have added inline documentation to the code I modified
30
+
31
+ If you have questions, please file a [support ticket](https://twilio.com/help/contact), or create a GitHub Issue in this repository.
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  [![BuildStatus](https://travis-ci.org/sendgrid/ruby-http-client.svg?branch=master)](https://travis-ci.org/sendgrid/ruby-http-client)
4
4
  [![Email Notifications Badge](https://dx.sendgrid.com/badge/ruby)](https://dx.sendgrid.com/newsletter/ruby)
5
5
  [![Gem Version](https://badge.fury.io/rb/sendgrid-ruby.svg)](https://badge.fury.io/rb/sendgrid-ruby)
6
- [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.txt)
6
+ [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE.md)
7
7
  [![Twitter Follow](https://img.shields.io/twitter/follow/sendgrid.svg?style=social&label=Follow)](https://twitter.com/sendgrid)
8
8
  [![GitHub contributors](https://img.shields.io/github/contributors/sendgrid/ruby-http-client.svg)](https://github.com/sendgrid/ruby-http-client/graphs/contributors)
9
9
 
@@ -112,4 +112,4 @@ ruby-http-client is guided and supported by the SendGrid [Developer Experience T
112
112
  ruby-http-client is maintained and funded by SendGrid, Inc. The names and logos for ruby-http-client are trademarks of SendGrid, Inc.
113
113
 
114
114
  # License
115
- [The MIT License (MIT)](LICENSE.txt)
115
+ [The MIT License (MIT)](LICENSE.md)
@@ -149,7 +149,12 @@ module SendGrid
149
149
  (!@request_headers.key?('Content-Type') ||
150
150
  @request_headers['Content-Type'] == 'application/json')
151
151
 
152
- @request.body = @request_body.to_json
152
+ # If body is a hash, encode it; else leave it alone
153
+ @request.body = if @request_body.class == Hash
154
+ @request_body.to_json
155
+ else
156
+ @request_body
157
+ end
153
158
  @request['Content-Type'] = 'application/json'
154
159
  elsif !@request_body && (name.to_s == 'post')
155
160
  @request['Content-Type'] = ''
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = 'ruby_http_client'
6
- spec.version = '3.4.0'
6
+ spec.version = '3.4.3'
7
7
  spec.authors = ['Elmer Thomas']
8
8
  spec.email = 'dx@sendgrid.com'
9
9
  spec.summary = 'A simple REST client'
@@ -12,6 +12,14 @@ class MockResponse
12
12
  end
13
13
  end
14
14
 
15
+ class MockResponseWithRequestBody < MockResponse
16
+ attr_reader :request_body
17
+
18
+ def initialize(response)
19
+ @request_body = response['request_body']
20
+ end
21
+ end
22
+
15
23
  class MockRequest < SendGrid::Client
16
24
  def make_request(_http, _request)
17
25
  response = {}
@@ -22,6 +30,17 @@ class MockRequest < SendGrid::Client
22
30
  end
23
31
  end
24
32
 
33
+ class MockRequestWithRequestBody < SendGrid::Client
34
+ def make_request(_http, request)
35
+ response = {}
36
+ response['code'] = 200
37
+ response['body'] = { 'message' => 'success' }
38
+ response['headers'] = { 'headers' => 'test' }
39
+ response['request_body'] = request.body
40
+ MockResponseWithRequestBody.new(response)
41
+ end
42
+ end
43
+
25
44
  class TestClient < Minitest::Test
26
45
  def setup
27
46
  @headers = JSON.parse('
@@ -158,6 +177,48 @@ class TestClient < Minitest::Test
158
177
  assert_equal('hogebody', client.request.body)
159
178
  end
160
179
 
180
+ def test_json_body_encode
181
+ headers = {
182
+ 'Content-Type' => 'application/json'
183
+ }
184
+ client = MockRequestWithRequestBody.new(
185
+ host: 'https://localhost',
186
+ request_headers: headers
187
+ )
188
+ name = 'post'
189
+ args = [{ 'request_body' => { 'this_is' => 'json' } }]
190
+ response = client.build_request(name, args)
191
+ assert_equal('{"this_is":"json"}', response.request_body)
192
+ end
193
+
194
+ def test_json_body_do_not_reencode
195
+ headers = {
196
+ 'Content-Type' => 'application/json'
197
+ }
198
+ client = MockRequestWithRequestBody.new(
199
+ host: 'https://localhost',
200
+ request_headers: headers
201
+ )
202
+ name = 'post'
203
+ args = [{ 'request_body' => '{"this_is":"json"}' }]
204
+ response = client.build_request(name, args)
205
+ assert_equal('{"this_is":"json"}', response.request_body)
206
+ end
207
+
208
+ def test_json_body_do_not_reencode_simplejson
209
+ headers = {
210
+ 'Content-Type' => 'application/json'
211
+ }
212
+ client = MockRequestWithRequestBody.new(
213
+ host: 'https://localhost',
214
+ request_headers: headers
215
+ )
216
+ name = 'post'
217
+ args = [{ 'request_body' => 'true' }]
218
+ response = client.build_request(name, args)
219
+ assert_equal('true', response.request_body)
220
+ end
221
+
161
222
  def add_ssl
162
223
  uri = URI.parse('https://localhost:4010')
163
224
  http = Net::HTTP.new(uri.host, uri.port)
@@ -254,7 +315,7 @@ class TestClient < Minitest::Test
254
315
  end
255
316
 
256
317
  def test_issue_template_exists
257
- assert(File.file?('./.github/ISSUE_TEMPLATE'))
318
+ assert(File.file?('./ISSUE_TEMPLATE.md'))
258
319
  end
259
320
 
260
321
  def test_license_exists
@@ -262,7 +323,7 @@ class TestClient < Minitest::Test
262
323
  end
263
324
 
264
325
  def test_pull_request_template_exists
265
- assert(File.file?('./.github/PULL_REQUEST_TEMPLATE'))
326
+ assert(File.file?('./PULL_REQUEST_TEMPLATE.md'))
266
327
  end
267
328
 
268
329
  def test_readme_exists
@@ -278,7 +339,7 @@ class TestClient < Minitest::Test
278
339
  end
279
340
 
280
341
  def test_license_date_is_updated
281
- license_end_year = IO.read('LICENSE.txt').match(/Copyright \(c\) 2016-(\d{4}) Twilio SendGrid/)[1].to_i
342
+ license_end_year = IO.read('LICENSE.md').match(/Copyright \(C\) (\d{4}), Twilio SendGrid/)[1].to_i
282
343
  current_year = Time.new.year
283
344
  assert_equal(current_year, license_end_year)
284
345
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_http_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.0
4
+ version: 3.4.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elmer Thomas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest
@@ -74,8 +74,6 @@ extra_rdoc_files: []
74
74
  files:
75
75
  - ".codeclimate.yml"
76
76
  - ".env_sample"
77
- - ".github/ISSUE_TEMPLATE"
78
- - ".github/PULL_REQUEST_TEMPLATE"
79
77
  - ".gitignore"
80
78
  - ".rubocop.yml"
81
79
  - ".travis.yml"
@@ -83,8 +81,10 @@ files:
83
81
  - CODE_OF_CONDUCT.md
84
82
  - CONTRIBUTING.md
85
83
  - Gemfile
86
- - LICENSE.txt
84
+ - ISSUE_TEMPLATE.md
85
+ - LICENSE.md
87
86
  - Makefile
87
+ - PULL_REQUEST_TEMPLATE.md
88
88
  - README.md
89
89
  - Rakefile
90
90
  - TROUBLESHOOTING.md
@@ -1,17 +0,0 @@
1
- #### Issue Summary
2
-
3
- A summary of the issue and the environment in which it occurs. If suitable, include the steps required to reproduce the bug. Please feel free to include screenshots, screencasts, code examples.
4
-
5
-
6
- #### Steps to Reproduce
7
-
8
- 1. This is the first step
9
- 2. This is the second step
10
- 3. Further steps, etc.
11
-
12
- Any other information you want to share that is relevant to the issue being reported. Especially, why do you consider this to be a bug? What do you expect to happen instead?
13
-
14
- #### Technical details:
15
-
16
- * ruby-http-client Version: master (latest commit: [commit number])
17
- * Ruby Version: 2.2
@@ -1,24 +0,0 @@
1
- <!--
2
- We appreciate the effort for this pull request but before that please make sure you read the contribution guidelines given above, then fill out the blanks below.
3
-
4
-
5
- Please enter each Issue number you are resolving in your PR after one of the following words [Fixes, Closes, Resolves]. This will auto-link these issues and close them when this PR is merged!
6
- e.g.
7
- Fixes #1
8
- Closes #2
9
- -->
10
- # Fixes #
11
-
12
- ### Checklist
13
- - [ ] I have made a material change to the repo (functionality, testing, spelling, grammar)
14
- - [ ] I have read the [Contribution Guide] and my PR follows them.
15
- - [ ] I updated my branch with the development branch.
16
- - [ ] I have added tests that prove my fix is effective or that my feature works
17
- - [ ] I have added necessary documentation about the functionality in the appropriate .md file
18
- - [ ] I have added in line documentation to the code I modified
19
-
20
- ### Short description of what this PR does:
21
- -
22
- -
23
-
24
- If you have questions, please send an email to [Sendgrid](mailto:dx@sendgrid.com), or file a Github Issue in this repository.