mercadopago-sdk 1.2.0 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +10 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +28 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +19 -0
- data/.github/workflows/ruby.yml +35 -0
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +104 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/CODING_GUIDELINES.md +70 -0
- data/CONTRIBUTING.md +57 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +51 -12
- data/LICENSE.txt +21 -0
- data/README.md +45 -117
- data/Rakefile +3 -1
- data/docs/CODE_OF_CONDUCT_md.html +154 -0
- data/docs/CODING_GUIDELINES_md.html +188 -0
- data/docs/CONTRIBUTING_md.html +165 -0
- data/docs/LICENSE_txt.html +96 -0
- data/docs/Mercadopago/AdvancedPayment.html +279 -0
- data/docs/Mercadopago/Card.html +204 -0
- data/docs/Mercadopago/CardToken.html +160 -0
- data/docs/Mercadopago/Config.html +266 -0
- data/docs/Mercadopago/Customer.html +228 -0
- data/docs/Mercadopago/DisbursementRefund.html +183 -0
- data/docs/Mercadopago/HttpClient.html +249 -0
- data/docs/Mercadopago/IdentificationType.html +136 -0
- data/docs/Mercadopago/MPBase.html +316 -0
- data/docs/Mercadopago/MerchantOrder.html +209 -0
- data/docs/Mercadopago/Payment.html +208 -0
- data/docs/Mercadopago/PaymentMethods.html +136 -0
- data/docs/Mercadopago/Preference.html +184 -0
- data/docs/Mercadopago/Refund.html +160 -0
- data/docs/Mercadopago/RequestOptions.html +433 -0
- data/docs/Mercadopago/SDK.html +528 -0
- data/docs/Mercadopago/User.html +136 -0
- data/docs/Mercadopago.html +123 -0
- data/docs/README_md.html +181 -0
- data/docs/created.rid +25 -0
- data/docs/css/fonts.css +167 -0
- data/docs/css/rdoc.css +619 -0
- data/docs/fonts/Lato-Light.ttf +0 -0
- data/docs/fonts/Lato-LightItalic.ttf +0 -0
- data/docs/fonts/Lato-Regular.ttf +0 -0
- data/docs/fonts/Lato-RegularItalic.ttf +0 -0
- data/docs/fonts/SourceCodePro-Bold.ttf +0 -0
- data/docs/fonts/SourceCodePro-Regular.ttf +0 -0
- data/docs/images/add.png +0 -0
- data/docs/images/arrow_up.png +0 -0
- data/docs/images/brick.png +0 -0
- data/docs/images/brick_link.png +0 -0
- data/docs/images/bug.png +0 -0
- data/docs/images/bullet_black.png +0 -0
- data/docs/images/bullet_toggle_minus.png +0 -0
- data/docs/images/bullet_toggle_plus.png +0 -0
- data/docs/images/date.png +0 -0
- data/docs/images/delete.png +0 -0
- data/docs/images/find.png +0 -0
- data/docs/images/loadingAnimation.gif +0 -0
- data/docs/images/macFFBgHack.png +0 -0
- data/docs/images/package.png +0 -0
- data/docs/images/page_green.png +0 -0
- data/docs/images/page_white_text.png +0 -0
- data/docs/images/page_white_width.png +0 -0
- data/docs/images/plugin.png +0 -0
- data/docs/images/ruby.png +0 -0
- data/docs/images/tag_blue.png +0 -0
- data/docs/images/tag_green.png +0 -0
- data/docs/images/transparent.png +0 -0
- data/docs/images/wrench.png +0 -0
- data/docs/images/wrench_orange.png +0 -0
- data/docs/images/zoom.png +0 -0
- data/docs/index.html +109 -0
- data/docs/js/darkfish.js +84 -0
- data/docs/js/navigation.js +105 -0
- data/docs/js/navigation.js.gz +0 -0
- data/docs/js/search.js +110 -0
- data/docs/js/search_index.js +1 -0
- data/docs/js/search_index.js.gz +0 -0
- data/docs/js/searcher.js +229 -0
- data/docs/js/searcher.js.gz +0 -0
- data/docs/table_of_contents.html +562 -0
- data/lib/mercadopago/config/config.rb +42 -0
- data/lib/mercadopago/config/request_options.rb +85 -0
- data/lib/mercadopago/core/mp_base.rb +77 -0
- data/lib/mercadopago/http/http_client.rb +74 -0
- data/lib/mercadopago/resources/advanced_payment.rb +48 -0
- data/lib/mercadopago/resources/card.rb +31 -0
- data/lib/mercadopago/resources/card_token.rb +19 -0
- data/lib/mercadopago/resources/customer.rb +36 -0
- data/lib/mercadopago/resources/disbursement_refund.rb +24 -0
- data/lib/mercadopago/resources/identification_type.rb +13 -0
- data/lib/mercadopago/resources/merchant_order.rb +32 -0
- data/lib/mercadopago/resources/payment.rb +35 -0
- data/lib/mercadopago/resources/payment_methods.rb +13 -0
- data/lib/mercadopago/resources/preference.rb +26 -0
- data/lib/mercadopago/resources/refund.rb +24 -0
- data/lib/mercadopago/resources/user.rb +13 -0
- data/lib/mercadopago/sdk.rb +85 -0
- data/lib/mercadopago.rb +24 -389
- data/mercadopago.gemspec +15 -15
- data/tests/test_card.rb +78 -0
- data/tests/test_card_token.rb +39 -0
- data/tests/test_customer.rb +54 -0
- data/tests/test_identification_type.rb +16 -0
- data/tests/test_merchant_order.rb +94 -0
- data/tests/test_payment.rb +102 -0
- data/tests/test_payment_methods.rb +14 -0
- data/tests/test_preference.rb +49 -0
- data/tests/test_refund.rb +88 -0
- data/tests/test_refund_with_custom_headers.rb +97 -0
- data/tests/test_user.rb +17 -0
- data/tests/tests.rb +13 -56
- metadata +155 -36
- data/.travis.yml +0 -14
- data/examples/checkout-buttons/basic_preference/button.rb +0 -28
- data/examples/instant-payment-notifications/receive-ipn.rb +0 -25
- data/examples/payment-search/search-approved-payments.rb +0 -23
- data/examples/payment-search/search-creditcard-payments.rb +0 -23
- data/examples/payment-search/search-funded-payments-by-name.rb +0 -23
- data/examples/payment-search/search-payments-from-email-and-date.rb +0 -23
- data/examples/payment-search/search-payments.rb +0 -23
- data/examples/preapproval-payments/button.rb +0 -42
- data/lib/ssl_options_patch.rb +0 -15
- data/lib/version.rb +0 -2
- data/travis_Gemfile +0 -4
data/README.md
CHANGED
@@ -8,152 +8,80 @@ This library provides developers with a simple set of bindings to help you integ
|
|
8
8
|
|
9
9
|
## 💡 Requirements
|
10
10
|
|
11
|
-
|
11
|
+
Ruby version **2.3 or greater**.
|
12
12
|
|
13
13
|
## 📲 Installation
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
1. Run ```gem install mercadopago-sdk```
|
18
|
-
|
19
|
-
2. Copy the access_token in the [credentials](https://www.mercadopago.com/mlb/account/credentials) section of the page and replace YOUR_ACCESS_TOKEN with it.
|
20
|
-
|
21
|
-
Thats all, you have Mercado Pago SDK installed.
|
22
|
-
|
23
|
-
```ruby
|
24
|
-
preference = $mp.get_preference('PREFERENCE_ID')
|
25
|
-
|
26
|
-
puts $preferenceResult
|
27
|
-
```
|
15
|
+
Run ```gem install mercadopago-sdk```
|
28
16
|
|
29
17
|
## 🌟 Getting Started
|
30
|
-
|
31
|
-
Simple usage looks like:
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
require 'mercadopago.rb'
|
35
|
-
|
36
|
-
$mp = MercadoPago.new('YOUR_ACCESS_TOKEN')
|
37
|
-
|
38
|
-
preference_data = {
|
39
|
-
"items": [
|
40
|
-
{
|
41
|
-
"title": "testCreate",
|
42
|
-
"quantity": 1,
|
43
|
-
"unit_price": 10.2,
|
44
|
-
"currency_id": "ARS"
|
45
|
-
}
|
46
|
-
preference = $mp.create_preference(preference_data)
|
47
|
-
|
48
|
-
puts preference
|
49
|
-
```
|
50
|
-
|
51
|
-
#### Update an existent Checkout preference
|
52
|
-
|
53
|
-
```ruby
|
54
|
-
preferenceDataToUpdate = Hash["items" => Array(Array["title"=>"testUpdated", "quantity"=>1, "unit_price"=>2])]
|
55
|
-
|
56
|
-
preferenceUpdate = $mp.update_preference("PREFERENCE_ID", preferenceDataToUpdate)
|
57
|
-
|
58
|
-
puts preferenceUpdate
|
59
|
-
```
|
60
|
-
|
61
|
-
### Payments/Collections
|
62
|
-
|
63
|
-
#### Search for payments
|
64
|
-
|
65
|
-
```ruby
|
66
|
-
filters = Array["id"=>null, "external_reference"=>null]
|
67
|
-
|
68
|
-
searchResult = $mp.search_payment(filters)
|
69
18
|
|
70
|
-
|
71
|
-
```
|
72
|
-
|
73
|
-
#### Get payment data
|
74
|
-
|
75
|
-
```ruby
|
76
|
-
paymentInfo = $mp.get_payment("ID")
|
77
|
-
|
78
|
-
puts paymentInfo
|
79
|
-
```
|
19
|
+
First time using Mercado Pago? Create your [Mercado Pago account](https://www.mercadopago.com).
|
80
20
|
|
81
|
-
|
21
|
+
Copy your `Access Token` in the [credentials panel](https://www.mercadopago.com/developers/panel/credentials) and replace the text `YOUR_ACCESS_TOKEN` with it.
|
82
22
|
|
83
|
-
|
84
|
-
result = $mp.cancel_payment("ID");
|
85
|
-
|
86
|
-
// Show result
|
87
|
-
puts result
|
88
|
-
```
|
23
|
+
### Simple usage
|
89
24
|
|
90
|
-
|
25
|
+
To generate a `card token` read the [Checkout API](https://www.mercadopago.com/developers/en/guides/online-payments/checkout-api/introduction) documentation.
|
91
26
|
|
92
27
|
```ruby
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
28
|
+
require 'mercadopago'
|
29
|
+
|
30
|
+
sdk = Mercadopago::SDK.new('YOUR_ACCESS_TOKEN')
|
31
|
+
|
32
|
+
payment_data = {
|
33
|
+
transaction_amount: 100,
|
34
|
+
token: 'CARD_TOKEN',
|
35
|
+
description: 'Payment description',
|
36
|
+
payment_method_id: 'visa',
|
37
|
+
installments: 1,
|
38
|
+
payer: {
|
39
|
+
email: 'test_user_123456@testuser.com'
|
40
|
+
}
|
41
|
+
}
|
42
|
+
result = sdk.payment.create(payment_data)
|
43
|
+
payment = result[:response]
|
44
|
+
|
45
|
+
puts payment
|
97
46
|
```
|
98
47
|
|
99
|
-
|
100
|
-
## Customized checkout
|
101
|
-
|
102
|
-
### Configure your credentials
|
48
|
+
### Per-request configuration
|
103
49
|
|
104
|
-
|
105
|
-
* Argentina: [https://www.mercadopago.com/mla/account/credentials](https://www.mercadopago.com/mla/account/credentials)
|
106
|
-
* Brazil: [https://www.mercadopago.com/mlb/account/credentials](https://www.mercadopago.com/mlb/account/credentials)
|
107
|
-
* Mexico: [https://www.mercadopago.com/mlm/account/credentials](https://www.mercadopago.com/mlm/account/credentials)
|
108
|
-
* Venezuela: [https://www.mercadopago.com/mlv/account/credentials](https://www.mercadopago.com/mlv/account/credentials)
|
109
|
-
* Colombia: [https://www.mercadopago.com/mco/account/credentials](https://www.mercadopago.com/mco/account/credentials)
|
50
|
+
All methods that make API calls accept an optional `RequestOptions` object. This can be used to configure some special options of the request, such as changing credentials or custom headers.
|
110
51
|
|
111
52
|
```ruby
|
112
|
-
require 'mercadopago
|
53
|
+
require 'mercadopago'
|
113
54
|
|
114
|
-
|
115
|
-
|
55
|
+
request_options = Mercadopago::RequestOptions.new(access_token: 'YOUR_ACCESS_TOKEN')
|
56
|
+
# ...
|
116
57
|
|
117
|
-
|
118
|
-
|
119
|
-
```ruby
|
120
|
-
$mp.post ("/v1/payments", payment_data);
|
58
|
+
result = sdk.payment.create(payment_data, request_options: request_options)
|
59
|
+
payment = result[:response]
|
121
60
|
```
|
122
61
|
|
123
|
-
|
62
|
+
## 📚 Documentation
|
124
63
|
|
125
|
-
|
126
|
-
|
127
|
-
|
64
|
+
Visit our Dev Site for further information regarding:
|
65
|
+
- [APIs](https://www.mercadopago.com/developers/en/reference)
|
66
|
+
- [Checkout Pro](https://www.mercadopago.com/developers/en/guides/online-payments/checkout-pro/introduction)
|
67
|
+
- [Checkout API](https://www.mercadopago.com/developers/en/guides/online-payments/checkout-api/introduction)
|
68
|
+
- [Web Tokenize Checkout](https://www.mercadopago.com/developers/en/guides/online-payments/web-tokenize-checkout/introduction)
|
128
69
|
|
129
70
|
Check our official code reference to explore all available functionalities.
|
130
71
|
|
131
|
-
|
132
|
-
$mp.get ("/v1/customers/CUSTOMER_ID");
|
133
|
-
```
|
72
|
+
## 🤝 Contributing
|
134
73
|
|
135
|
-
|
74
|
+
All contributions are welcome, ranging from people wanting to triage issues, others wanting to write documentation, to people wanting to contribute code.
|
136
75
|
|
137
|
-
|
76
|
+
Please read and follow our [contribution guidelines](CONTRIBUTING.md). Contributions not following this guidelines will be disregarded. The guidelines are in place to make all of our lives easier and make contribution a consistent process for everyone.
|
138
77
|
|
139
|
-
|
140
|
-
// Get a resource, with optional URL params. Also you can disable authentication for public APIs
|
141
|
-
$mp.get ("/resource/uri", [params], [authenticate=true])
|
78
|
+
## ❤️ Support
|
142
79
|
|
143
|
-
|
144
|
-
$mp.post ("/resource/uri", data, [params])
|
80
|
+
If you require technical support, please contact our support team at [developers.mercadopago.com](https://developers.mercadopago.com).
|
145
81
|
|
146
|
-
|
147
|
-
$mp.put ("/resource/uri", data, [params])
|
82
|
+
## 🏻 License
|
148
83
|
|
149
|
-
// Delete a resource with optional URL params.
|
150
|
-
$mp.delete ("/resource/uri", [params])
|
151
84
|
```
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
```ruby
|
156
|
-
$sites = $mp.get ("/sites", null, false)
|
157
|
-
|
158
|
-
puts $sites
|
85
|
+
MIT license. Copyright (c) 2021 - Mercado Pago / Mercado Libre
|
86
|
+
For more information, see the LICENSE file.
|
159
87
|
```
|
data/Rakefile
CHANGED
@@ -0,0 +1,154 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>CODE_OF_CONDUCT - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="file">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="./index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
<div class="nav-section">
|
58
|
+
<h3>Table of Contents</h3>
|
59
|
+
|
60
|
+
<ul class="link-list" role="directory">
|
61
|
+
<li><a href="#label-Contributor+Covenant+Code+of+Conduct">Contributor Covenant Code of Conduct</a>
|
62
|
+
<li><a href="#label-Our+Pledge">Our Pledge</a>
|
63
|
+
<li><a href="#label-Our+Standards">Our Standards</a>
|
64
|
+
<li><a href="#label-Our+Responsibilities">Our Responsibilities</a>
|
65
|
+
<li><a href="#label-Scope">Scope</a>
|
66
|
+
<li><a href="#label-Enforcement">Enforcement</a>
|
67
|
+
<li><a href="#label-Attribution">Attribution</a>
|
68
|
+
</ul>
|
69
|
+
</div>
|
70
|
+
|
71
|
+
|
72
|
+
<div id="project-metadata">
|
73
|
+
|
74
|
+
<div id="fileindex-section" class="nav-section">
|
75
|
+
<h3>Pages</h3>
|
76
|
+
|
77
|
+
<ul class="link-list">
|
78
|
+
<li><a href="./CODE_OF_CONDUCT_md.html">CODE_OF_CONDUCT</a>
|
79
|
+
<li><a href="./CODING_GUIDELINES_md.html">CODING_GUIDELINES</a>
|
80
|
+
<li><a href="./CONTRIBUTING_md.html">CONTRIBUTING</a>
|
81
|
+
<li><a href="./LICENSE_txt.html">LICENSE</a>
|
82
|
+
<li><a href="./README_md.html">README</a>
|
83
|
+
</ul>
|
84
|
+
</div>
|
85
|
+
|
86
|
+
</div>
|
87
|
+
</nav>
|
88
|
+
|
89
|
+
<main role="main" aria-label="Page CODE_OF_CONDUCT.md">
|
90
|
+
|
91
|
+
<h1 id="label-Contributor+Covenant+Code+of+Conduct">Contributor Covenant Code of Conduct<span><a href="#label-Contributor+Covenant+Code+of+Conduct">¶</a> <a href="#top">↑</a></span></h1>
|
92
|
+
|
93
|
+
<h2 id="label-Our+Pledge">Our Pledge<span><a href="#label-Our+Pledge">¶</a> <a href="#top">↑</a></span></h2>
|
94
|
+
|
95
|
+
<p>In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.</p>
|
96
|
+
|
97
|
+
<h2 id="label-Our+Standards">Our Standards<span><a href="#label-Our+Standards">¶</a> <a href="#top">↑</a></span></h2>
|
98
|
+
|
99
|
+
<p>Examples of behavior that contributes to creating a positive environment include:</p>
|
100
|
+
<ul><li>
|
101
|
+
<p>Using welcoming and inclusive language</p>
|
102
|
+
</li><li>
|
103
|
+
<p>Being respectful of differing viewpoints and experiences</p>
|
104
|
+
</li><li>
|
105
|
+
<p>Gracefully accepting constructive criticism</p>
|
106
|
+
</li><li>
|
107
|
+
<p>Focusing on what is best for the community</p>
|
108
|
+
</li><li>
|
109
|
+
<p>Showing empathy towards other community members</p>
|
110
|
+
</li></ul>
|
111
|
+
|
112
|
+
<p>Examples of unacceptable behavior by participants include:</p>
|
113
|
+
<ul><li>
|
114
|
+
<p>The use of sexualized language or imagery and unwelcome sexual attention or advances</p>
|
115
|
+
</li><li>
|
116
|
+
<p>Trolling, insulting/derogatory comments, and personal or political attacks</p>
|
117
|
+
</li><li>
|
118
|
+
<p>Public or private harassment</p>
|
119
|
+
</li><li>
|
120
|
+
<p>Publishing others' private information, such as a physical or electronic address, without explicit permission</p>
|
121
|
+
</li><li>
|
122
|
+
<p>Other conduct which could reasonably be considered inappropriate in a professional setting</p>
|
123
|
+
</li></ul>
|
124
|
+
|
125
|
+
<h2 id="label-Our+Responsibilities">Our Responsibilities<span><a href="#label-Our+Responsibilities">¶</a> <a href="#top">↑</a></span></h2>
|
126
|
+
|
127
|
+
<p>Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.</p>
|
128
|
+
|
129
|
+
<p>Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.</p>
|
130
|
+
|
131
|
+
<h2 id="label-Scope">Scope<span><a href="#label-Scope">¶</a> <a href="#top">↑</a></span></h2>
|
132
|
+
|
133
|
+
<p>This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.</p>
|
134
|
+
|
135
|
+
<h2 id="label-Enforcement">Enforcement<span><a href="#label-Enforcement">¶</a> <a href="#top">↑</a></span></h2>
|
136
|
+
|
137
|
+
<p>Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at danilo.elias@mercadolivre.com. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.</p>
|
138
|
+
|
139
|
+
<p>Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.</p>
|
140
|
+
|
141
|
+
<h2 id="label-Attribution">Attribution<span><a href="#label-Attribution">¶</a> <a href="#top">↑</a></span></h2>
|
142
|
+
|
143
|
+
<p>This Code of Conduct is adapted from the <a href="https://contributor-covenant.org">Contributor Covenant</a>, version 1.4, available at <a href="https://contributor-covenant.org/version/1/4/">contributor-covenant.org/version/1/4</a></p>
|
144
|
+
|
145
|
+
</main>
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
<footer id="validator-badges" role="contentinfo">
|
150
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
151
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.0.
|
152
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
153
|
+
</footer>
|
154
|
+
|
@@ -0,0 +1,188 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta charset="UTF-8">
|
6
|
+
|
7
|
+
<title>CODING_GUIDELINES - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<script type="text/javascript">
|
10
|
+
var rdoc_rel_prefix = "./";
|
11
|
+
var index_rel_prefix = "./";
|
12
|
+
</script>
|
13
|
+
|
14
|
+
<script src="./js/navigation.js" defer></script>
|
15
|
+
<script src="./js/search.js" defer></script>
|
16
|
+
<script src="./js/search_index.js" defer></script>
|
17
|
+
<script src="./js/searcher.js" defer></script>
|
18
|
+
<script src="./js/darkfish.js" defer></script>
|
19
|
+
|
20
|
+
<link href="./css/fonts.css" rel="stylesheet">
|
21
|
+
<link href="./css/rdoc.css" rel="stylesheet">
|
22
|
+
|
23
|
+
|
24
|
+
<body id="top" role="document" class="file">
|
25
|
+
<nav role="navigation">
|
26
|
+
<div id="project-navigation">
|
27
|
+
<div id="home-section" role="region" title="Quick navigation" class="nav-section">
|
28
|
+
<h2>
|
29
|
+
<a href="./index.html" rel="home">Home</a>
|
30
|
+
</h2>
|
31
|
+
|
32
|
+
<div id="table-of-contents-navigation">
|
33
|
+
<a href="./table_of_contents.html#pages">Pages</a>
|
34
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
35
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
36
|
+
</div>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<div id="search-section" role="search" class="project-section initially-hidden">
|
40
|
+
<form action="#" method="get" accept-charset="utf-8">
|
41
|
+
<div id="search-field-wrapper">
|
42
|
+
<input id="search-field" role="combobox" aria-label="Search"
|
43
|
+
aria-autocomplete="list" aria-controls="search-results"
|
44
|
+
type="text" name="search" placeholder="Search" spellcheck="false"
|
45
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
46
|
+
</div>
|
47
|
+
|
48
|
+
<ul id="search-results" aria-label="Search Results"
|
49
|
+
aria-busy="false" aria-expanded="false"
|
50
|
+
aria-atomic="false" class="initially-hidden"></ul>
|
51
|
+
</form>
|
52
|
+
</div>
|
53
|
+
|
54
|
+
</div>
|
55
|
+
|
56
|
+
|
57
|
+
<div class="nav-section">
|
58
|
+
<h3>Table of Contents</h3>
|
59
|
+
|
60
|
+
<ul class="link-list" role="directory">
|
61
|
+
<li><a href="#label-Coding+Guidelines">Coding Guidelines</a>
|
62
|
+
<li><a href="#label-Language+Guidelines">Language Guidelines</a>
|
63
|
+
<li><a href="#label-Code+Guidelines">Code Guidelines</a>
|
64
|
+
<li><a href="#label-Comment+Guidelines">Comment Guidelines</a>
|
65
|
+
<li><a href="#label-Branching+Guidelines">Branching Guidelines</a>
|
66
|
+
<li><a href="#label-Git+Guidelines">Git Guidelines</a>
|
67
|
+
</ul>
|
68
|
+
</div>
|
69
|
+
|
70
|
+
|
71
|
+
<div id="project-metadata">
|
72
|
+
|
73
|
+
<div id="fileindex-section" class="nav-section">
|
74
|
+
<h3>Pages</h3>
|
75
|
+
|
76
|
+
<ul class="link-list">
|
77
|
+
<li><a href="./CODE_OF_CONDUCT_md.html">CODE_OF_CONDUCT</a>
|
78
|
+
<li><a href="./CODING_GUIDELINES_md.html">CODING_GUIDELINES</a>
|
79
|
+
<li><a href="./CONTRIBUTING_md.html">CONTRIBUTING</a>
|
80
|
+
<li><a href="./LICENSE_txt.html">LICENSE</a>
|
81
|
+
<li><a href="./README_md.html">README</a>
|
82
|
+
</ul>
|
83
|
+
</div>
|
84
|
+
|
85
|
+
</div>
|
86
|
+
</nav>
|
87
|
+
|
88
|
+
<main role="main" aria-label="Page CODING_GUIDELINES.md">
|
89
|
+
|
90
|
+
<h1 id="label-Coding+Guidelines">Coding Guidelines<span><a href="#label-Coding+Guidelines">¶</a> <a href="#top">↑</a></span></h1>
|
91
|
+
|
92
|
+
<p>The Mercado Pago Ruby SDK is a collaborative effort from the start. The SDK team thinks that contributions from different developer will enrich it's feature set and make it more relevant to the community.</p>
|
93
|
+
|
94
|
+
<p>However; absorbing all contributions as-is, while expedient, might lead to difficulties in maintenance of the codebase is left unchecked. Collaborative codebases often establish guidelines for contributors to ensure code remains maintainable over time. The effort to maintain the SDK is no different in this regard so a bit of guidance is in order.</p>
|
95
|
+
|
96
|
+
<p>The purpose of this guide is to set a baseline for contributions. These guidelines are not intended to limit the tools at your disposal nor to rewire the way you think but rather to encourage good neighbor behavior.</p>
|
97
|
+
|
98
|
+
<h2 id="label-Language+Guidelines">Language Guidelines<span><a href="#label-Language+Guidelines">¶</a> <a href="#top">↑</a></span></h2>
|
99
|
+
|
100
|
+
<p>We use <strong>english</strong> language. This is to be consistent everywhere, and to be considerate with developers that do not speak our native language.</p>
|
101
|
+
|
102
|
+
<p>Therefore: source code, comments, documentation, commit messages, review comments, and any other kind of contribution <em>MUST</em> use english language.</p>
|
103
|
+
|
104
|
+
<p>Typos are unavoidable, but try to reduce them by using a spellchecker. Most IDEs can be configured to run one automatically.</p>
|
105
|
+
|
106
|
+
<h2 id="label-Code+Guidelines">Code Guidelines<span><a href="#label-Code+Guidelines">¶</a> <a href="#top">↑</a></span></h2>
|
107
|
+
<ul><li>
|
108
|
+
<p>Set your IDE to follow the <a href="https://editorconfig.org/">.editorconfig</a> in each repository.</p>
|
109
|
+
</li><li>
|
110
|
+
<p>Follow the <a href="https://github.com/rubocop/ruby-style-guide">RuboCop Ruby Style Guide</a>.</p>
|
111
|
+
</li></ul>
|
112
|
+
|
113
|
+
<p>Generally speaking, be conscious when contributing and try following the same style that the code in the SDK already has. If you have any doubts, just ask us!</p>
|
114
|
+
|
115
|
+
<p>This rules will be enforced automatically when making a pull requests, and checks will fail if you do not follow them, resulting in your contribution being automatically rejected until fixed.</p>
|
116
|
+
|
117
|
+
<h2 id="label-Comment+Guidelines">Comment Guidelines<span><a href="#label-Comment+Guidelines">¶</a> <a href="#top">↑</a></span></h2>
|
118
|
+
|
119
|
+
<p>Comments in code are a hard thing to write, not because the words are difficult to produce but because it is hard to make relevant comments. Too much of it and people do not read comments (and it obfuscates code reading) and too little of it gives you no recourse but to read large portions of codebase to get insight as to what a feature/codeblock is doing. Both situations are undesirable and efforts should be made at all time to have a please comment reading experience</p>
|
120
|
+
|
121
|
+
<p>As a general rule you would have to comment on decisions you made while coding that are not part of any specification.</p>
|
122
|
+
|
123
|
+
<p>In particular you should always comment any decision that:</p>
|
124
|
+
<ul><li>
|
125
|
+
<p>Departs from common wisdom or convention (The <strong>why's</strong> are necessary).</p>
|
126
|
+
</li><li>
|
127
|
+
<p>Takes a significant amount of time to produce. A good rule of thumb here is that if you spent more than 1 hour thinking on how to produce a fragment of code that took 2 minutes of wrist time to write you should document your thinking to aid reader and allow for validation.</p>
|
128
|
+
</li><li>
|
129
|
+
<p>Need to preserve properties of the implementation. This is the case of performance sensitive portions of the codebase, goroutines synchronization, implementations of security primitives, congestion control algorithms, etc.</p>
|
130
|
+
</li></ul>
|
131
|
+
|
132
|
+
<p>As a general rule of what not to comment you should avoid:</p>
|
133
|
+
<ul><li>
|
134
|
+
<p>Commenting on structure of programs that is already part of a convention, specified or otherwise.</p>
|
135
|
+
</li><li>
|
136
|
+
<p>Having pedantic explanations of behavior that can be found by immediate examination of the surrounding code artifacts.</p>
|
137
|
+
</li><li>
|
138
|
+
<p>Commenting on behavior you cannot attest.</p>
|
139
|
+
</li></ul>
|
140
|
+
|
141
|
+
<h3 id="label-Branching+Guidelines">Branching Guidelines<span><a href="#label-Branching+Guidelines">¶</a> <a href="#top">↑</a></span></h3>
|
142
|
+
|
143
|
+
<p>Currently <code>master</code> is our only long term branch, below a few suggestions of short term branches naming:</p>
|
144
|
+
<ul><li>
|
145
|
+
<p><code>hotfix/something-needs-fix</code>: Small routine patches in code to features already there.</p>
|
146
|
+
</li><li>
|
147
|
+
<p><code>feature/something-new</code>: A new feature or a change in a existent feature. Beware of breaking changes that would require a major version bump.</p>
|
148
|
+
</li><li>
|
149
|
+
<p><code>doc/improves-documentation-for-this-feature</code>: If you add or change documentation with no impact to the source code.</p>
|
150
|
+
</li></ul>
|
151
|
+
|
152
|
+
<h3 id="label-Git+Guidelines">Git Guidelines<span><a href="#label-Git+Guidelines">¶</a> <a href="#top">↑</a></span></h3>
|
153
|
+
|
154
|
+
<p>All commits <strong>SHOULD</strong> follow the <a href="https://chris.beams.io/posts/git-commit">seven rules of a great Git commit message</a>:</p>
|
155
|
+
<ol><li>
|
156
|
+
<p>Separate subject from body with a blank line.</p>
|
157
|
+
</li><li>
|
158
|
+
<p>Limit the subject line to 72 characters.</p>
|
159
|
+
</li><li>
|
160
|
+
<p>Capitalize the subject line.</p>
|
161
|
+
</li><li>
|
162
|
+
<p>Do not end the subject line with a period.</p>
|
163
|
+
</li><li>
|
164
|
+
<p>Use the imperative mood in the subject line.</p>
|
165
|
+
</li><li>
|
166
|
+
<p>Wrap the body at 72 characters.</p>
|
167
|
+
</li><li>
|
168
|
+
<p>Use the body to explain what and why vs. how.</p>
|
169
|
+
</li></ol>
|
170
|
+
|
171
|
+
<p>Commits such as “fix tests”, “now it's working” and many other common messages we find usually in code <strong>WON'T</strong> be accepted.</p>
|
172
|
+
|
173
|
+
<p>Ideally we would like to enforce these rules, but we are realistic and understand that it might be a big change for some people. So unless deviating heavily from what was stated we might accept your commits even if not following these rules perfectly.</p>
|
174
|
+
|
175
|
+
<p>Please avoid taking to much time to deliver code, and always <a href="https://git-scm.com/docs/git-rebase">rebase</a> your code to avoid reverse merge commits.</p>
|
176
|
+
|
177
|
+
<p>When reviewing, check if the PR adheres to <a href="https://github.com/rubocop/ruby-style-guide">RuboCop Ruby Style Guide</a>.</p>
|
178
|
+
|
179
|
+
</main>
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
<footer id="validator-badges" role="contentinfo">
|
184
|
+
<p><a href="https://validator.w3.org/check/referer">Validate</a>
|
185
|
+
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.0.
|
186
|
+
<p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
|
187
|
+
</footer>
|
188
|
+
|