Skip to content

Instantly share code, notes, and snippets.

View Rickedb's full-sized avatar

Henrique Dal Bello Rickedb

View GitHub Profile
@Rickedb
Rickedb / SoapSnippet.cs
Created June 6, 2022 16:01
Basic soap call
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", "<token>");
var xml = "<xml>";
var soapAction = "<soap-action>";
var httpContent = new StringContent(xml, Encoding.UTF8, "text/xml");
var request = new HttpRequestMessage(new HttpMethod("POST"), url)
{
Content = httpContent
};
request.Headers.Add("SOAPAction", soapAction);
@Rickedb
Rickedb / TaskExtension.cs
Created March 23, 2022 00:40
Useful extensions examples
public static class TaskExtensions
{
public static Task Ignore<TException>(this Task task) where TException : Exception
{
return task.ContinueWith(x =>
{
if (x.IsCanceled || !x.IsFaulted)
{
return Task.CompletedTask;
}
name: master
on:
push:
branches:
- master
jobs:
build:
runs-on: windows-latest
Mid 0001 Start Communication
I: "00200001001 "
Mid 0002 Start Communication Acknowledge
C: "00570002001 010001020103Airbag1 "
Mid 0060 Last tightening result data subscribe (Receive every new tightening in real time)
I: "00200060001 "
Mid 0005 Command accepted (notice that the last 4 characters are the mid you send)
[Route("api/[controller]")]
[ApiController]
public class ReportController : ControllerBase
{
private readonly GoogleAdWordsService _service;
public ReportController(GoogleAdWordsService service)
{
_service = service;
}
public class GoogleAdWordsService
{
private readonly AdWordsAppConfig _config;
public GoogleAdWordsService(AdWordsAppConfig config)
{
_config = config;
}
public async Task<object> GetReport(string customerId)
<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<report>
<report-name name='MyReportName'/>
<date-range date='Aug 12, 2019-Aug 13, 2019'/>
<table>
<columns>
<column name='campaign' display='Campaign'/>
<column name='adGroup' display='Ad group'/>
<column name='day' display='Day'/>
<column name='cost' display='Cost'/>
public class Startup
{
public Startup(IConfiguration configuration)
{
Configuration = configuration;
}
public IConfiguration Configuration { get; }
// This method gets called by the runtime. Use this method to add services to the container.
{
"AdWordsApi": {
"client_id": "CLIENT_ID",
"project_id": "PROJECT_ID",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "\"",
"https": null,
"redirect_uris": [ "https://developers.google.com/oauthplayground" ],
"UserAgent": "AdWordsApiExample",
public class Person
{
public int Id { get; set; }
public string Name { get; set; }
public string Surname { get; set; }
public int Age { get; set; }
public string Document { get; set; }
public DateTime BornAt { get; set; }
}