Skip to content

Instantly share code, notes, and snippets.

@xavierzwirtz
Created January 13, 2020 21:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xavierzwirtz/10772ad482bca9e493de14f674351fd9 to your computer and use it in GitHub Desktop.
Save xavierzwirtz/10772ad482bca9e493de14f674351fd9 to your computer and use it in GitHub Desktop.
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