Skip to content

Commit

Permalink
initial commit.
Browse files Browse the repository at this point in the history
  • Loading branch information
kylewest committed Aug 15, 2011
0 parents commit 1a6881c
Show file tree
Hide file tree
Showing 19 changed files with 2,722 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
@@ -0,0 +1,11 @@
obj
Obj
bin
Bin
_ReSharper.*
*.csproj.user
*.resharper.user
*.ReSharper.user
*.suo
*.cache
~$*
20 changes: 20 additions & 0 deletions MIT-LICENSE
@@ -0,0 +1,20 @@
Copyright (c) 2011 RPMWare Inc.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
38 changes: 38 additions & 0 deletions Program.cs
@@ -0,0 +1,38 @@
using System;
using System.Collections.Generic;
using RPMWare.Api.Client.RPMWareOrder;

namespace RPMWare.Api.Client
{
/// <summary>
/// This is a quick implementation of a RPMWare API client application.
/// It shows how to connect to the RPMWare API and retrieve a list of orders. While the code here works,
/// it IS NOT INTENDED FOR PRODUCTION USE. PLEASE REVIEW ALL THE CODE CONTAINED IN THIS PROJECT BEFORE
/// USING IT FOR MISSION CRITICAL BUSINESS APPLICATIONS.
/// </summary>
internal class Program
{
private static void Main()
{
var service = new Order();
Result result = service.GetOrdersSinceLastOrderId(UserService.GetApiKey(), 25000);

if (result.Success == "SUCCESS")
{
foreach (Order1 order in (IEnumerable<Order1>) result.Data)
{
Console.WriteLine(order.Customer.AccountName);

foreach (OrderLineItem orderLineItem in order.LineItems)
{
Console.WriteLine(orderLineItem.PartNumber);
}

Console.WriteLine("======================================================");
}

Console.ReadLine();
}
}
}
}
39 changes: 39 additions & 0 deletions Properties/AssemblyInfo.cs
@@ -0,0 +1,39 @@
using System.Reflection;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.

[assembly: AssemblyTitle("RPMWare.Api.Client")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RPMWare.Api.Client")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.

[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM

[assembly: Guid("4b1aa91f-1291-4995-993f-275053cfe5a0")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
64 changes: 64 additions & 0 deletions Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Properties/Settings.settings
@@ -0,0 +1,18 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)" GeneratedClassNamespace="RPMWare.Api.Client.Properties" GeneratedClassName="Settings">
<Profiles />
<Settings>
<Setting Name="RPMWare_Api_Client_RPMWareOrder_Order" Type="(Web Service URL)" Scope="Application">
<Value Profile="(Default)">http://secure.rpmware.com/api/order.asmx</Value>
</Setting>
<Setting Name="RPMWare_Api_Client_RPMWareUser_User" Type="(Web Service URL)" Scope="Application">
<Value Profile="(Default)">http://secure.rpmware.com/api/user.asmx</Value>
</Setting>
<Setting Name="ApiEmail" Type="System.String" Scope="Application">
<Value Profile="(Default)">demo@rpmware.com</Value>
</Setting>
<Setting Name="ApiPassword" Type="System.String" Scope="Application">
<Value Profile="(Default)">admin</Value>
</Setting>
</Settings>
</SettingsFile>
129 changes: 129 additions & 0 deletions RPMWare.Api.Client.csproj
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
<ProductVersion>8.0.30703</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{19BDC14E-AD17-4862-BD3E-C5EC93266CB1}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>RPMWare.Api.Client</RootNamespace>
<AssemblyName>RPMWare.Api.Client</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<PlatformTarget>x86</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.EnterpriseServices" />
<Reference Include="System.Web.Services" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<None Include="readme.markdown" />
<None Include="MIT-LICENSE" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="UserService.cs" />
<Compile Include="Web References\RPMWareOrder\Reference.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Reference.map</DependentUpon>
<SubType>Component</SubType>
</Compile>
<Compile Include="Web References\RPMWareUser\Reference.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Reference.map</DependentUpon>
<SubType>Component</SubType>
</Compile>
</ItemGroup>
<ItemGroup>
<WebReferences Include="Web References\" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<None Include="Web References\RPMWareOrder\order.wsdl" />
<None Include="Web References\RPMWareOrder\Reference.map">
<Generator>MSDiscoCodeGenerator</Generator>
<LastGenOutput>Reference.cs</LastGenOutput>
</None>
<None Include="Web References\RPMWareOrder\Result.datasource">
<DependentUpon>Reference.map</DependentUpon>
</None>
<None Include="Web References\RPMWareUser\Reference.map">
<Generator>MSDiscoCodeGenerator</Generator>
<LastGenOutput>Reference.cs</LastGenOutput>
</None>
<None Include="Web References\RPMWareUser\Result.datasource">
<DependentUpon>Reference.map</DependentUpon>
</None>
<None Include="Web References\RPMWareUser\user.wsdl" />
</ItemGroup>
<ItemGroup>
<WebReferenceUrl Include="http://secure.rpmware.com/api/order.asmx%3fWSDL">
<UrlBehavior>Dynamic</UrlBehavior>
<RelPath>Web References\RPMWareOrder\</RelPath>
<UpdateFromURL>http://secure.rpmware.com/api/order.asmx%3fWSDL</UpdateFromURL>
<ServiceLocationURL>
</ServiceLocationURL>
<CachedDynamicPropName>
</CachedDynamicPropName>
<CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName>
<CachedSettingsPropName>RPMWare_Api_Client_RPMWareOrder_Order</CachedSettingsPropName>
</WebReferenceUrl>
<WebReferenceUrl Include="http://secure.rpmware.com/api/user.asmx%3fWSDL">
<UrlBehavior>Dynamic</UrlBehavior>
<RelPath>Web References\RPMWareUser\</RelPath>
<UpdateFromURL>http://secure.rpmware.com/api/user.asmx%3fWSDL</UpdateFromURL>
<ServiceLocationURL>
</ServiceLocationURL>
<CachedDynamicPropName>
</CachedDynamicPropName>
<CachedAppSettingsObjectName>Settings</CachedAppSettingsObjectName>
<CachedSettingsPropName>RPMWare_Api_Client_RPMWareUser_User</CachedSettingsPropName>
</WebReferenceUrl>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
20 changes: 20 additions & 0 deletions RPMWare.Api.Client.sln
@@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RPMWare.Api.Client", "RPMWare.Api.Client.csproj", "{19BDC14E-AD17-4862-BD3E-C5EC93266CB1}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{19BDC14E-AD17-4862-BD3E-C5EC93266CB1}.Debug|x86.ActiveCfg = Debug|x86
{19BDC14E-AD17-4862-BD3E-C5EC93266CB1}.Debug|x86.Build.0 = Debug|x86
{19BDC14E-AD17-4862-BD3E-C5EC93266CB1}.Release|x86.ActiveCfg = Release|x86
{19BDC14E-AD17-4862-BD3E-C5EC93266CB1}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
33 changes: 33 additions & 0 deletions UserService.cs
@@ -0,0 +1,33 @@
using System;
using System.Security.Authentication;
using RPMWare.Api.Client.Properties;
using RPMWare.Api.Client.RPMWareUser;

namespace RPMWare.Api.Client
{
public static class UserService
{
public static string GetApiKey()
{
string email = Settings.Default.ApiEmail;
// Do as I say, not as I do. You should store your password encrypted.
string password = Settings.Default.ApiPassword;

Console.WriteLine("Logging in as {0}.", email);

var service = new User();
Result result = service.Login(email, password);
if (result.Success == "SUCCESS")
{
var data = result.Data as ApiToken;
if (data != null)
{
return data.Token;
}
throw new AuthenticationException("Result.Data was null.");
}

throw new AuthenticationException(result.Message);
}
}
}

0 comments on commit 1a6881c

Please sign in to comment.