Skip to content

Commit f381b06

Browse files
committed
Initial commit.
0 parents  commit f381b06

21 files changed

+1730
-0
lines changed

AssemblyInfo.cs.template

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Copyright 2008-2012 Concur Technologies, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use this file except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
using System.Reflection;
18+
19+
[assembly: AssemblyTitle("TripIt API .NET Language Bindings")]
20+
[assembly: AssemblyCompany("TripIt, Inc.")]
21+
[assembly: AssemblyProduct("TripIt API .NET Language Bindings")]
22+
[assembly: AssemblyCopyright("Copyright 2010 TripIt, Inc.")]
23+
[assembly: AssemblyVersion("1.0.0.*")]

Credential.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2008-2012 Concur Technologies, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use this file except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
using System.Net;
18+
using System.Collections.Generic;
19+
20+
namespace TripIt {
21+
22+
/// <summary>
23+
/// An abstract credential that can authorize itself with a WebRequest.
24+
/// </summary>
25+
public interface Credential {
26+
/// <summary>
27+
/// Given a WebRequest and the contents of the request, modifies the
28+
/// request so that it
29+
/// </summary>
30+
/// <param name="request">
31+
/// A <see cref="WebRequest"/>
32+
/// </param>
33+
/// <param name="realm">
34+
/// The URL of the API, ex: https://api.tripit.com
35+
/// </param>
36+
/// <param name="urlBase">
37+
/// The base URL of the request, ex: https://api.tripit.com/list/trip
38+
/// </param>
39+
/// <param name="args">
40+
/// A <see cref="Dictionary"/> of the parameters to the request.
41+
/// </param>
42+
void Authorize(
43+
WebRequest request,
44+
string realm,
45+
string urlBase,
46+
Dictionary<string, string> args);
47+
}
48+
49+
}

Example.cs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* Copyright 2008-2012 Concur Technologies, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use this file except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
using System;
18+
using System.Net;
19+
20+
namespace TripIt.Example {
21+
22+
class Example {
23+
public static void Main(string[] args) {
24+
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatesPolicy();
25+
26+
if (args.Length < 5) {
27+
Console.WriteLine("Usage: Example.exe api_url consumer_key " +
28+
"consumer_secret authorized_token " +
29+
"authorized_token_secret");
30+
return;
31+
}
32+
33+
string apiUrl = args[0];
34+
string consumerKey = args[1];
35+
string consumerSecret = args[2];
36+
string authorizedToken = args[3];
37+
string authorizedTokenSecret = args[4];
38+
39+
Credential credential = new OAuthCredential(
40+
consumerKey, consumerSecret,
41+
authorizedToken, authorizedTokenSecret);
42+
43+
TripIt t = new TripIt(credential, apiUrl);
44+
45+
Console.WriteLine(t.ListTrip().Trip.Length);
46+
}
47+
}
48+
49+
}

Example.csproj

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.50727</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{C4D974B1-1DBC-4400-8067-7877E66A2D4B}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AssemblyName>Example</AssemblyName>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
22+
<DebugType>none</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Release</OutputPath>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<ItemGroup>
29+
<Compile Include="Example.cs" />
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ProjectReference Include="TripIt.csproj">
33+
<Project>{C2986992-E73A-42AE-BE2A-8D19C1FFF458}</Project>
34+
<Name>TripIt</Name>
35+
</ProjectReference>
36+
<ProjectReference Include="TrustAllCertificatesPolicy.csproj">
37+
<Project>{B857319C-1296-4E6B-ACDE-5A59E5C26922}</Project>
38+
<Name>TrustAllCertificatesPolicy</Name>
39+
</ProjectReference>
40+
</ItemGroup>
41+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
42+
<ItemGroup>
43+
<Reference Include="System" />
44+
</ItemGroup>
45+
<ProjectExtensions>
46+
<MonoDevelop>
47+
<Properties InternalTargetFrameworkVersion="3.5" />
48+
</MonoDevelop>
49+
</ProjectExtensions>
50+
</Project>

GetAuthorizedToken.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2008-2012 Concur Technologies, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use this file except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
using System;
18+
using System.Net;
19+
20+
namespace TripIt.Example {
21+
22+
class GetAuthorizedToken {
23+
public static void Main(string[] args) {
24+
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatesPolicy();
25+
26+
if (args.Length < 5) {
27+
Console.WriteLine("Usage: GetAuthorizedToken.exe api_url consumer_key " +
28+
"consumer_secret request_token " +
29+
"request_token_secret");
30+
return;
31+
}
32+
33+
string apiUrl = args[0];
34+
string consumerKey = args[1];
35+
string consumerSecret = args[2];
36+
string requestToken = args[3];
37+
string requestTokenSecret = args[4];
38+
39+
Credential credential = new OAuthCredential(
40+
consumerKey, consumerSecret,
41+
requestToken, requestTokenSecret);
42+
43+
TripIt t = new TripIt(credential, apiUrl);
44+
45+
OAuthCredential authorizedCredential = t.GetAccessToken();
46+
47+
Console.WriteLine("Authorized Token: " + authorizedCredential.Token);
48+
Console.WriteLine("Token Secret: " + authorizedCredential.TokenSecret);
49+
}
50+
}
51+
52+
}

GetAuthorizedToken.csproj

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.50727</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{78310BBF-4D30-4AE8-B876-8614F6A84A64}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AssemblyName>GetAuthorizedToken</AssemblyName>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
22+
<DebugType>none</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Release</OutputPath>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<ItemGroup>
29+
<Compile Include="GetAuthorizedToken.cs" />
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ProjectReference Include="TripIt.csproj">
33+
<Project>{C2986992-E73A-42AE-BE2A-8D19C1FFF458}</Project>
34+
<Name>TripIt</Name>
35+
</ProjectReference>
36+
<ProjectReference Include="TrustAllCertificatesPolicy.csproj">
37+
<Project>{B857319C-1296-4E6B-ACDE-5A59E5C26922}</Project>
38+
<Name>TrustAllCertificatesPolicy</Name>
39+
</ProjectReference>
40+
</ItemGroup>
41+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
42+
<ItemGroup>
43+
<Reference Include="System" />
44+
</ItemGroup>
45+
<ProjectExtensions>
46+
<MonoDevelop>
47+
<Properties InternalTargetFrameworkVersion="3.5" />
48+
</MonoDevelop>
49+
</ProjectExtensions>
50+
</Project>

GetRequestToken.cs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright 2008-2012 Concur Technologies, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
5+
* not use this file except in compliance with the License. You may obtain
6+
* a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13+
* License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
using System;
18+
using System.Net;
19+
20+
namespace TripIt.Example {
21+
22+
class GetRequestToken {
23+
public static void Main(string[] args) {
24+
System.Net.ServicePointManager.CertificatePolicy = new TrustAllCertificatesPolicy();
25+
26+
if (args.Length < 3) {
27+
Console.WriteLine("Usage: GetRequestToken.exe api_url consumer_key " +
28+
"consumer_secret");
29+
return;
30+
}
31+
32+
string apiUrl = args[0];
33+
string consumerKey = args[1];
34+
string consumerSecret = args[2];
35+
36+
Credential credential = new OAuthCredential(
37+
consumerKey, consumerSecret);
38+
39+
TripIt t = new TripIt(credential, apiUrl);
40+
41+
OAuthCredential authorizedCredential = t.GetRequestToken();
42+
43+
Console.WriteLine("Request Token: " + authorizedCredential.Token);
44+
Console.WriteLine("Token Secret: " + authorizedCredential.TokenSecret);
45+
}
46+
}
47+
48+
}

GetRequestToken.csproj

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.50727</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{CEA699A1-0483-489C-98F5-2B6C7EAD272D}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<AssemblyName>GetRequestToken</AssemblyName>
11+
</PropertyGroup>
12+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
13+
<DebugSymbols>true</DebugSymbols>
14+
<DebugType>full</DebugType>
15+
<Optimize>false</Optimize>
16+
<OutputPath>bin\Debug</OutputPath>
17+
<DefineConstants>DEBUG</DefineConstants>
18+
<ErrorReport>prompt</ErrorReport>
19+
<WarningLevel>4</WarningLevel>
20+
</PropertyGroup>
21+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
22+
<DebugType>none</DebugType>
23+
<Optimize>false</Optimize>
24+
<OutputPath>bin\Release</OutputPath>
25+
<ErrorReport>prompt</ErrorReport>
26+
<WarningLevel>4</WarningLevel>
27+
</PropertyGroup>
28+
<ItemGroup>
29+
<Compile Include="GetRequestToken.cs" />
30+
</ItemGroup>
31+
<ItemGroup>
32+
<ProjectReference Include="TripIt.csproj">
33+
<Project>{C2986992-E73A-42AE-BE2A-8D19C1FFF458}</Project>
34+
<Name>TripIt</Name>
35+
</ProjectReference>
36+
<ProjectReference Include="TrustAllCertificatesPolicy.csproj">
37+
<Project>{B857319C-1296-4E6B-ACDE-5A59E5C26922}</Project>
38+
<Name>TrustAllCertificatesPolicy</Name>
39+
</ProjectReference>
40+
</ItemGroup>
41+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
42+
<ItemGroup>
43+
<Reference Include="System" />
44+
</ItemGroup>
45+
<ProjectExtensions>
46+
<MonoDevelop>
47+
<Properties InternalTargetFrameworkVersion="3.5" />
48+
</MonoDevelop>
49+
</ProjectExtensions>
50+
</Project>

0 commit comments

Comments
 (0)