Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Models, Enums, Params and Requests #38

Open
wants to merge 45 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3962c25
Rename Balance.Available to Balance.Transferable
rezigned Sep 30, 2019
8318e45
Generate Models, Enums and Requests (wip)
rezigned Oct 7, 2019
82ab0e6
Add generated resource classes & request params
rezigned Oct 18, 2019
4de1cd5
Fix tests (wip)
rezigned Mar 10, 2020
f43083a
Use same NConsole version for local
rezigned Mar 16, 2020
31775a1
Remove old defined model classes
rezigned Mar 16, 2020
cb4e38c
Update generated files
rezigned Mar 17, 2020
587e8c0
Update CreateChargeRequest to use source
rezigned Mar 19, 2020
63c5ac6
Convert raw string in tests to Dictionary
rezigned Mar 19, 2020
380b474
Generate Token params
rezigned Mar 20, 2020
c575541
Remove Request.cs
rezigned Mar 23, 2020
4a87ed5
Rename PaymentSource to Source
rezigned Mar 23, 2020
0160ea8
Generate BankAccount params
rezigned Mar 23, 2020
3fe4528
Remove legacy Models.tt
rezigned Mar 24, 2020
52c5940
Regenerate ScheduleOnParams
rezigned Mar 24, 2020
48fa96d
Rename param classes
rezigned Mar 24, 2020
faa4de7
Generate nullable field types
rezigned Mar 25, 2020
19adcf0
Fix wrong reference type
rezigned Mar 26, 2020
8112ad2
Generate charge's refunds resource
rezigned Mar 26, 2020
6a860ac
Remove ChargeSpecifict*.cs
rezigned Mar 31, 2020
3b5c322
Remove Specific*.cs
rezigned Mar 31, 2020
3112295
Remove CustomerSpecific*.cs
rezigned Apr 1, 2020
50535a4
Remove *ScheduleResource.cs
rezigned Apr 1, 2020
5825c54
Regenerate Enum values
rezigned Apr 1, 2020
ca12746
Regenerate resources + rename interfaces
rezigned Apr 1, 2020
5a5af16
Rename IListRetrievable to IRetrievable
rezigned Apr 2, 2020
650802a
Remove Document + Card resources and re-gen Refund
rezigned Apr 2, 2020
133ea32
Fix newline in method definition
rezigned Apr 3, 2020
863f9aa
Sort interfaces
rezigned Apr 3, 2020
17c186e
Fix wrong commas
rezigned Apr 3, 2020
5775b0f
Regenerate Dispute + Link resources
rezigned Apr 7, 2020
49a07a4
Update Omise.Example
rezigned Apr 7, 2020
66a99c6
Clean dependencies + references
rezigned Apr 8, 2020
c6d5a52
Fix API version to 2019-05-29
rezigned Apr 8, 2020
a71d7a3
Move params to its own file
rezigned Apr 9, 2020
c60785f
Don't use T4 for fixtures data
rezigned Apr 9, 2020
d981cce
Add PromptPay tests + CapabilityResource
rezigned Apr 9, 2020
f16a813
Move testdata inside Omise.Tests
rezigned Apr 9, 2020
ce81eb1
Remove Models.cs
rezigned Apr 9, 2020
cc1976d
Update fixtures path
rezigned Apr 9, 2020
b6ccb09
Migrate to dotnet test command
rezigned Apr 10, 2020
7aa3e49
Add Github Actions
rezigned Apr 10, 2020
7441a92
Migrate legacy Omise.Example + Makefile to use dotnet command
rezigned Apr 13, 2020
f604236
Remove legacy packages.config
rezigned Apr 14, 2020
32d1fa5
Update version to 3.0.0
rezigned Apr 14, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/dotnetcore.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: .NET Core

on:
push:
pull_request:
branches: [ master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: 3.1.200
- name: Install dependencies
run: dotnet restore
- name: Build
run: dotnet build Omise --configuration Release --no-restore
- name: Test
run: dotnet test Omise.Tests --no-restore --verbosity normal
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ install:
- nuget restore Omise.sln
- nuget install NUnit.Console -Version 3.9.0 -OutputDirectory testrunner
script:
- make test
- dotnet test Omise.Tests
49 changes: 23 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,47 +1,44 @@
#!/usr/bin/make

CONFIG := Debug
PLATFORM := netstandard2.0
CONFIG := Debug
PLATFORM := netstandard2.0
FRAMEWORK := net462
MONO := mono
BUILD := dotnet build

OMISE_CSPROJ := Omise/Omise.csproj
OMISE_TEST_CSPROJ := Omise.Tests/Omise.Tests.csproj
OMISE_EXAM_CSPROJ := Omise.Examples/Omise.Examples.csproj
OMISE_DLL := Omise/bin/$(CONFIG)/$(PLATFORM)/Omise.dll
OMISE_TEST_DLL := Omise.Tests/bin/$(CONFIG)/Omise.Tests.dll
OMISE_EXAMPLE_EXE := Omise.Examples/bin/$(CONFIG)/$(FRAMEWORK)/Omise.Examples.exe

SRC_FILES := $(wildcard Omise/**/*.cs Omise/*.cs)
SRC_TEST_FILES := $(wildcard Omise.Tests/**/*.cs Omise.Tests/*.cs)
T4_FILES := $(wildcard Omise/**/*.tt Omise/*.tt Omise.Tests/**/*.tt Omise.Tests/*.tt)
T4_OUTPUT_FILES := $(T4_FILES:.tt=.cs)

MONO := mono
MSBUILD := msbuild /p:Configuration=$(CONFIG)
ifdef TRAVIS
NUNIT := $(MONO) ./testrunner/NUnit.ConsoleRunner.3.9.0/tools/nunit3-console.exe
else
NUNIT := $(MONO) packages/NUnit.ConsoleRunner.3.6.1/tools/nunit3-console.exe
endif
T4 := $(MONO) /Applications/Visual\ Studio.app/Contents/Resources/lib/monodevelop/AddIns/MonoDevelop.TextTemplating/TextTransform.exe

.PHONY: test clean

default: build

t4: $(T4_OUTPUT_FILES)
%.cs: %.tt
$(T4) -o="$@" "$<"

build: $(OMISE_DLL)
$(OMISE_DLL): $(OMISE_CSPROJ) $(SRC_FILES) $(T4_OUTPUT_FILES)
$(MSBUILD) /target:Build;Pack $(OMISE_CSPROJ)
$(OMISE_DLL): $(OMISE_CSPROJ) $(SRC_FILES)
$(BUILD) $(OMISE_CSPROJ)

build-test: $(OMISE_TEST_DLL) $(SRC_TEST_FILES)
$(OMISE_TEST_DLL): $(OMISE_TEST_CSPROJ) $(SRC_TEST_FILES) $(T4_OUTPUT_FILES)
$(MSBUILD) $(OMISE_TEST_CSPROJ)
$(OMISE_TEST_DLL): $(OMISE_TEST_CSPROJ) $(SRC_TEST_FILES)
$(BUILD) $(OMISE_TEST_CSPROJ)

build-example: $(OMISE_EXEAMPLE_EXE)
$(BUILD) $(OMISE_EXAM_CSPROJ)

pack: $(OMISE_DLL)
dotnet pack -c Release $(OMISE_CSPROJ)

clean:
$(MSBUILD) /target:Clean $(OMISE_CSPROJ)
clean-test:
$(MSBUILD) /target:Clean $(OMISE_TEST_CSPROJ)
dotnet clean

test: $(SRC_FILES) $(SRC_TEST_FILES)
dotnet test $(OMISE_TEST_CSPROJ)

test: $(OMISE_TEST_DLL)
$(NUNIT) --noresult $(OMISE_TEST_DLL)
run: build-example
$(MONO) $(OMISE_EXAMPLE_EXE)
39 changes: 30 additions & 9 deletions Omise.Examples/Example.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public Example()
// this as an example call to get token from cient-side.
protected async Task<Token> RetrieveToken()
{
return await Client.Tokens.Create(new CreateTokenRequest
return await Client.Tokens.Create(new CardParams
{
Name = "Somchai Prasert",
Number = "4242424242424242",
Expand All @@ -30,28 +30,49 @@ protected async Task<Token> RetrieveToken()
}

// Creates a new PaymentSource called RetrieveSourceInternetBanking, as sources can be created client-side (as well as server-side).
protected async Task<PaymentSource> RetrieveSourceInternetBanking()
protected async Task<Source> RetrieveSourceInternetBanking()
{
return await Client.Sources.Create(new CreatePaymentSourceRequest
return await Client.Sources.Create(new CreateSourceParams
{
Amount = 2000,
Currency = "thb",
Type = OffsiteTypes.InternetBankingBAY,
Flow = FlowTypes.Redirect
Type = SourceType.InternetBankingBAY,
});
}

// Creates a new PaymentSource called RetrieveSourceBillPayment, as sources can be created client-side (as well as server-side).
protected async Task<PaymentSource> RetrieveSourceBillPayment()
protected async Task<Source> RetrieveSourceBillPayment()
{
return await Client.Sources.Create(new CreatePaymentSourceRequest
return await Client.Sources.Create(new CreateSourceParams
{
Amount = 2000,
Currency = "thb",
Type = OffsiteTypes.BillPaymentTescoLotus,
Flow = FlowTypes.Offline
Type = SourceType.BillPaymentTescoLotus,
});
}

// Creates a new PaymentSource called RetrieveSourceBarcode, as sources can be created client-side (as well as server-side).
protected async Task<Source> RetrieveSourceBarcode()
{
return await Client.Sources.Create(new CreateSourceParams
{
Type = SourceType.BarcodeAlipay,
Barcode = "201234567890",
StoreId = "Store1",
StoreName = "Store 1",
TerminalId = "0001"
});
}

// Creates a new PromptPay source
protected async Task<Source> RetrieveSourcePromptPay()
{
return await Client.Sources.Create(new CreateSourceParams
{
Type = SourceType.PromptPay,
Amount = 20000,
Currency = "thb"
});
}
}
}
2 changes: 1 addition & 1 deletion Omise.Examples/Examples/Balances.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public class Balances : Example
public async Task Retrieve__Retrieve()
{
var balance = await Client.Balance.Get();
Console.WriteLine($"available balance: {balance.Available}");
Console.WriteLine($"available balance: {balance.Transferable}");
Console.WriteLine($"total balance: {balance.Total}");
}
}
Expand Down
14 changes: 14 additions & 0 deletions Omise.Examples/Examples/Capability.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Threading.Tasks;

namespace Omise.Examples
{
public class Capability : Example
{
public async Task Retrieve__Retrieve()
{
var capability = await Client.Capability.Get();
Console.WriteLine($"Country: {capability.Country}");
}
}
}
10 changes: 5 additions & 5 deletions Omise.Examples/Examples/Cards.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class Cards : Example
public async Task List__List()
{
var customerId = ExampleInfo.CUST_ID; // "cust_test_5aass4jqqb39x80fkta";
var cards = await Client.Customer(customerId).Cards.GetList();
var cards = await Client.Customers.Customer(customerId).Cards.GetList();
foreach (var card in cards)
{
Console.WriteLine($"card: {card.Id}");
Expand All @@ -21,7 +21,7 @@ public async Task Retrieve__Retrieve()
{
var customerId = ExampleInfo.CUST_ID; // "cust_test_5aass4jqqb39x80fkta";
var cardId = ExampleInfo.CARD_ID; // "card_test_5aaswlbxdrzhoornpfe";
var card = await Client.Customer(customerId).Cards.Get(cardId);
var card = await Client.Customers.Customer(customerId).Cards.Get(cardId);
Console.WriteLine($"first digits: {card.FirstDigits}");
Console.WriteLine($"last digits: {card.LastDigits}");
}
Expand All @@ -30,7 +30,7 @@ public async Task Update__Update()
{
var customerId = ExampleInfo.CUST_ID; // "cust_test_5aass4jqqb39x80fkta";
var cardId = ExampleInfo.CARD_ID; // "card_test_5aaswlbxdrzhoornpfe";
var card = await Client.Customer(customerId).Cards.Update(cardId, new UpdateCardRequest
var card = await Client.Customers.Customer(customerId).Cards.Update(cardId, new UpdateCustomerCardParams
{
Name = "Somchai Prasert",
ExpirationMonth = 8,
Expand All @@ -43,15 +43,15 @@ public async Task Update__Update()
public async Task Destroy__Destroy()
{
var customer = RetrieveCustomerWithCard();
var card = await Client.Customer(customer.Id).Cards.Destroy(customer.DefaultCard);
var card = await Client.Customers.Customer(customer.Id).Cards.Destroy(customer.DefaultCard);
Console.WriteLine($"destroyed card: {card.Id} of customer {customer.Id}");
}

protected Customer RetrieveCustomerWithCard()
{
var token = RetrieveToken().Result;
var customerId = ExampleInfo.CUST_ID_2; // "cust_test_5aass48w2i40qa5ivh9";
var customer = Client.Customers.Update(customerId, new UpdateCustomerRequest
var customer = Client.Customers.Update(customerId, new UpdateCustomerParams
{
Card = token.Id
}).Result;
Expand Down
21 changes: 11 additions & 10 deletions Omise.Examples/Examples/Charge_Schedules.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public async Task Customer_List__List()
{
var customerId = ExampleInfo.CUST_ID_3; // "cust_test_5aasqjmq7glo1c0pedk";
var schedules = await Client
.Customers
.Customer(customerId)
.Schedules
.GetList(order: Ordering.ReverseChronological);
Expand All @@ -29,13 +30,13 @@ public async Task Customer_List__List()

public async Task Create__Create_Daily()
{
var schedule = await Client.Schedules.Create(new CreateScheduleRequest
var schedule = await Client.Schedules.Create(new CreateScheduleParams
{
Every = 2,
Period = SchedulePeriod.Day,
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddYears(2),
On = new ScheduleOnRequest
On = new ScheduleOnParams
{
Weekdays = new[] { Weekdays.Monday }
},
Expand All @@ -52,13 +53,13 @@ public async Task Create__Create_Daily()

public async Task Create__Create_Weekly()
{
var schedule = await Client.Schedules.Create(new CreateScheduleRequest
var schedule = await Client.Schedules.Create(new CreateScheduleParams
{
Every = 1,
Period = SchedulePeriod.Week,
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddYears(2),
On = new ScheduleOnRequest
On = new ScheduleOnParams
{
Weekdays = new[] { Weekdays.Monday, Weekdays.Friday }
},
Expand All @@ -75,13 +76,13 @@ public async Task Create__Create_Weekly()

public async Task Create__Create_Monthly()
{
var schedule = await Client.Schedules.Create(new CreateScheduleRequest
var schedule = await Client.Schedules.Create(new CreateScheduleParams
{
Every = 3,
Period = SchedulePeriod.Month,
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddYears(2),
On = new ScheduleOnRequest
On = new ScheduleOnParams
{
DaysOfMonth = new[] { 1, 10, 15 }
},
Expand All @@ -98,13 +99,13 @@ public async Task Create__Create_Monthly()

public async Task Create__Create_Monthly_By_Week()
{
var schedule = await Client.Schedules.Create(new CreateScheduleRequest
var schedule = await Client.Schedules.Create(new CreateScheduleParams
{
Every = 1,
Period = SchedulePeriod.Month,
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddYears(2),
On = new ScheduleOnRequest
On = new ScheduleOnParams
{
WeekdayOfMonth = "2nd_monday"
},
Expand All @@ -128,13 +129,13 @@ public async Task Destroy__Destroy()

protected Schedule RetrieveSchedule()
{
return Client.Schedules.Create(new CreateScheduleRequest
return Client.Schedules.Create(new CreateScheduleParams
{
Every = 1,
Period = SchedulePeriod.Month,
StartDate = DateTime.Now,
EndDate = DateTime.Now.AddYears(2),
On = new ScheduleOnRequest
On = new ScheduleOnParams
{
WeekdayOfMonth = "2nd_monday"
},
Expand Down
Loading