Skip to content

Commit 4a41cd0

Browse files
author
Pedro Gonçalves
authored
Merge pull request #98 from mercadopago/release/1.4.0
Release/1.4.0
2 parents 2f6bdeb + 8e03804 commit 4a41cd0

File tree

7 files changed

+174
-3
lines changed

7 files changed

+174
-3
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.ComponentModel.DataAnnotations;
2+
using Newtonsoft.Json.Linq;
3+
4+
namespace MercadoPago.DataStructures.Preference
5+
{
6+
public struct Track
7+
{
8+
#region Properties
9+
[StringLength(256)]
10+
private string _type;
11+
private JObject _values;
12+
#endregion
13+
14+
#region Accessors
15+
/// <summary>
16+
/// Track type
17+
/// </summary>
18+
public string Type
19+
{
20+
get { return _type; }
21+
set { _type = value; }
22+
}
23+
/// <summary>
24+
/// Track values
25+
/// </summary>
26+
public JObject Values
27+
{
28+
get { return _values; }
29+
set { _values = value; }
30+
}
31+
#endregion
32+
}
33+
}

px-dotnet/MercadoPagoSDK.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
1515
<FileAlignment>512</FileAlignment>
1616
<PackageId>mercadopago-sdk</PackageId>
17-
<PackageVersion>1.3.0</PackageVersion>
17+
<PackageVersion>1.4.0</PackageVersion>
1818
<Authors>Williner Rafael, Zachary Gerardo, Joel Ibaceta</Authors>
1919
<Description>MercadoPago SDK para .Net</Description>
2020
<Owners>MercadoPago</Owners>
@@ -193,6 +193,7 @@
193193
<Compile Include="Resources\Refund.cs" />
194194
<Compile Include="Common\ProcessingMode.cs" />
195195
<Compile Include="Common\TaxType.cs" />
196+
<Compile Include="DataStructures\Preference\Track.cs" />
196197
</ItemGroup>
197198
<ItemGroup>
198199
<None Include="packages.config" />

px-dotnet/Net/MPRESTClient.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using MercadoPago;
1+
using MercadoPago;
22
using Newtonsoft.Json;
33
using Newtonsoft.Json.Linq;
44
using System;
@@ -268,6 +268,17 @@ public MPRequest CreateRequest(HttpMethod httpMethod,
268268
}
269269
}
270270

271+
if (requestOptions.TrackHeaders != null)
272+
{
273+
foreach (var trackHeader in requestOptions.TrackHeaders)
274+
{
275+
if (mpRequest.Request.Headers[trackHeader.Key] == null && trackHeader.Value != null)
276+
{
277+
mpRequest.Request.Headers[trackHeader.Key] = trackHeader.Value;
278+
}
279+
}
280+
}
281+
271282
if (payload != null) // POST & PUT
272283
{
273284
byte[] data = null;

px-dotnet/Net/MPRequestOptions.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,19 @@ public class MPRequestOptions
1919

2020
public IDictionary<String, String> CustomHeaders { get; set; }
2121

22+
public IDictionary<String, String> TrackHeaders { get; private set; }
23+
2224
public MPRequestOptions()
2325
{
2426
Timeout = SDK.RequestsTimeout;
2527
Retries = SDK.RequestsRetries;
2628
Proxy = SDK.Proxy;
2729
CustomHeaders = new Dictionary<String, String>();
30+
TrackHeaders = new Dictionary<String, String> {
31+
{ "x-platform-id", SDK.GetPlatformId() },
32+
{ "x-corporation-id", SDK.GetCorporationId() },
33+
{ "x-integrator-id", SDK.GetIntegratorId() }
34+
};
2835
}
2936
}
3037
}

px-dotnet/Resources/Payment.cs

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ public Payment Refund(decimal? amount, MPRequestOptions requestOptions)
208208
private DateTime? _date_of_expiration;
209209
private long? _sponsor_id;
210210
private List<Taxes> _taxes;
211+
private string _integrator_id;
212+
private string _platform_id;
213+
private string _corporation_id;
211214
#endregion
212215

213216
#region Accessors
@@ -581,8 +584,26 @@ public List<Taxes> Taxes
581584
{
582585
get { return this._taxes; }
583586
set { this._taxes = value; }
587+
}
588+
589+
public string IntegratorId
590+
{
591+
get { return _integrator_id; }
592+
private set { _integrator_id = value; }
584593
}
585-
#endregion
594+
595+
public string PlatformId
596+
{
597+
get { return _platform_id; }
598+
private set { _platform_id = value; }
599+
}
600+
601+
public string CorporationId
602+
{
603+
get { return _corporation_id; }
604+
private set { _corporation_id = value; }
605+
}
606+
#endregion
586607

587608
}
588609
}

px-dotnet/Resources/Preference.cs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public Boolean Update(MPRequestOptions requestOptions)
105105
private bool? _binary_mode;
106106
private List<Tax> _taxes;
107107
private JObject _metadata;
108+
private List<Track> _tracks;
108109
#endregion
109110

110111
#region Accesors
@@ -510,6 +511,23 @@ public JObject Metadata
510511
get { return this._metadata; }
511512
set { this._metadata = value; }
512513
}
514+
515+
/// <summary>
516+
/// Preference ad tracks
517+
/// </summary>
518+
public List<Track> Tracks
519+
{
520+
get
521+
{
522+
if (_tracks == null)
523+
{
524+
_tracks = new List<Track>();
525+
}
526+
return _tracks;
527+
}
528+
529+
set { _tracks = value; }
530+
}
513531
#endregion
514532
}
515533
}

px-dotnet/SDK.cs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ public class SDK
2525
private static string _userToken;
2626
private static string _refreshToken;
2727
private static readonly string _version;
28+
private static string _corporationId;
29+
private static string _integratorId;
30+
private static string _platformId;
2831

2932
static SDK()
3033
{
@@ -311,5 +314,82 @@ public static JToken Put(string uri, JObject payload)
311314
return client.ExecuteGenericRequest(HttpMethod.PUT, uri, PayloadType.JSON, payload);
312315
}
313316

317+
/// <summary>
318+
/// Property that represent the corporation id.
319+
/// </summary>
320+
public static string CorporationId
321+
{
322+
get { return _corporationId; }
323+
set
324+
{
325+
if (!string.IsNullOrEmpty(_corporationId))
326+
{
327+
throw new MPConfException("corporationId setting can not be changed");
328+
}
329+
_corporationId = value;
330+
}
331+
}
332+
333+
/// <summary>
334+
/// Property that represent the integrator id.
335+
/// </summary>
336+
public static string IntegratorId
337+
{
338+
get { return _integratorId; }
339+
set
340+
{
341+
if(!string.IsNullOrEmpty(_integratorId))
342+
{
343+
throw new MPConfException("integratorId setting can not be changed");
344+
}
345+
_integratorId = value;
346+
}
347+
}
348+
349+
/// <summary>
350+
/// Property that represent the plataform id.
351+
/// </summary>
352+
public static string PlatformId
353+
{
354+
get { return _platformId; }
355+
set
356+
{
357+
if (!string.IsNullOrEmpty(_platformId))
358+
{
359+
throw new MPConfException("platformId setting can not be changed");
360+
}
361+
_platformId = value;
362+
}
363+
}
364+
365+
public static void SetCorporationId(string corporationId)
366+
{
367+
CorporationId = corporationId;
368+
}
369+
370+
public static string GetCorporationId()
371+
{
372+
return CorporationId;
373+
}
374+
375+
public static void SetIntegratorId(string integratorId)
376+
{
377+
IntegratorId = integratorId;
378+
}
379+
380+
public static string GetIntegratorId()
381+
{
382+
return IntegratorId;
383+
}
384+
385+
public static void SetPlatformId(string platformId)
386+
{
387+
PlatformId = platformId;
388+
}
389+
390+
public static string GetPlatformId()
391+
{
392+
return PlatformId;
393+
}
314394
}
315395
}

0 commit comments

Comments
 (0)