Created
January 13, 2020 21:38
-
-
Save xavierzwirtz/10772ad482bca9e493de14f674351fd9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Imports System | |
Imports System.Collections | |
Imports System.Collections.Generic | |
Imports BirdDogSoftware | |
Imports BirdDogSoftware.Utilities | |
Imports BirdDogSoftware.Utilities.Http | |
Imports BirdDogSoftware.Framework | |
Imports BirdDogSoftware.Interfaces | |
Imports Newtonsoft.Json.Linq | |
Imports Chessie.ErrorHandling.CSharp | |
Imports Chessie.ErrorHandling | |
Imports System.Linq | |
Namespace Events | |
Public Class MagentoEvents | |
Public Shared Function GetCustomerNo( | |
Connection as MagentoConnector.MagentoConnection, | |
MagentoOrder As JObject, | |
CustomerID As Integer) as Maybe(Of String) | |
Dim resp = MagentoConnector.MakeRequest( | |
Connection, | |
HTTPMethods.Get, | |
"rest/all/V1/customers/" & CustomerID.ToString(), | |
{}, | |
""). | |
SucceededWith | |
dim respj = JObject.Parse(resp) | |
dim attr = respJ.Item("custom_attributes").SingleOrDefault( | |
Function(x) x.Item("attribute_code").ToObject(Of String) = "external_customer_no") | |
If attr Is Nothing Then | |
Throw New exception("Could not find 'external_customer_no' custom attribute") | |
End If | |
Return Maybe.Some(attr.Item("value").ToObject(Of String)) | |
End Function | |
End Class | |
End Namespace |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment