OmiseElixir 0.9.0 🎉

หลังจากที่ได้ลองศึก elixir มาได้สักพัก ก็ได้มีโอกาสทดลองเขียนและได้ contribute code เข้าใน OmiseElixir library บ้าง (https://hex.pm/packages/omise, https://github.com/omise/omise-elixir) โดยมี PR นี้ (https://github.com/omise/omise-elixir/pull/28) เป็น PR ตัวแรกของผมที่ส่วนร่วมในครั้งนี้

ในการเปลี่ยนเวอร์ชันจาก OmiseElixir 0.8.0 มาเป็น OmiseElixir 0.9.0 หลักๆคือการเพิ่ม attributes ให้กับทุก API และเพิ่มบาง API ที่ขาดหายไป เช่น Capability เป็นต้น โดยในเวอร์ชันนี้จะรองรับ attributes ต่างๆ ของ Omise API version 2019-05-29 ครับ

สิ่งที่เพิ่มเติมคือความสามารถในการ retrieve source ตัวอย่างเช่น

Omise.Source.retrieve("src_test_5mkpd5uqxnnqw4p411c")


{:ok,
%Omise.Source{
amount: 1000000,
barcode: nil,
charge_status: "pending",
created: nil,
currency: "THB",
flow: "offline",
id: "src_test_5mkpd5uqxnnqw4p411c",
installment_term: nil,
livemode: false,
location: "/sources/src_test_5mkpd5uqxnnqw4p411c",
mobile_number: nil,
name: nil,
object: "source",
phone_number: nil,
references: nil,
scannable_code: %Omise.Barcode{
image: %Omise.Document{
deleted: false,
download_uri: "https://api.omise.co/charges/chrg_test_5mkpd5wcoazpu1xde6c/documents/docu_test_5mkpd5xuko50s1rv98d/downloads/9D53860BFB89AC18",
filename: "qrcode.png",
id: "docu_test_5mkpd5xuko50s1rv98d",
livemode: false,
location: "/charges/chrg_test_5mkpd5wcoazpu1xde6c/documents/docu_test_5mkpd5xuko50s1rv98d",
object: "document"
},
object: "barcode",
type: "qr"
},
store_id: nil,
store_name: nil,
terminal_id: nil,
type: "promptpay",
zero_interest_installments: nil
}}

และการเรียกดูข้อมูล Capability ของ account ตัวเอง ตัวอย่างเช่น

Omise.Capability.retrieve()

{:ok,
 %Omise.Capability{
   banks: ["test", "bbl", "kbank", "rbs", "ktb", "jpm", "mufg", "tmb", "scb",
    "citi", "smbc", "sc", "cimb", "uob", "bay", "mega", "boa", "cacib", "gsb",
    "hsbc", "db", "ghb", "baac", "mb", "bnp", "tbank", "ibank", "tisco", "kk",
    "icbc", "tcrb", "lhb"],
   country: "TH",
   location: "/capability",
   object: "capability",
   payment_methods: [
     %Omise.PaymentMethod{
       card_brands: ["JCB", "Visa", "MasterCard"],
       currencies: ["THB", "JPY", "USD", "EUR", "GBP", "SGD", "AUD", "CHF",
        "CNY", "DKK", "HKD"],
       installment_terms: nil,
       name: "card",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "internet_banking_bay",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "internet_banking_ktb",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "internet_banking_scb",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "internet_banking_bbl",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "alipay",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: [3, 4, 6, 9, 10],
       name: "installment_bay",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: [3, 4, 6, 10],
       name: "installment_kbank",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: [3, 4, 5, 6, 7, 8, 9, 10],
       name: "installment_ktc",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: [4, 6, 8, 9, 10],
       name: "installment_bbl",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: [3, 4, 6, 9, 10, 12, 18, 24, 36],
       name: "installment_first_choice",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "bill_payment_tesco_lotus",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "barcode_alipay",
       object: "payment_method"
     },
     %Omise.PaymentMethod{ 
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "promptpay",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "mobile_banking_scb",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "truemoney",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: [3, 4, 6, 9, 10],
       name: "installment_scb",
       object: "payment_method"
     },
     %Omise.PaymentMethod{
       card_brands: nil,
       currencies: ["THB"],
       installment_terms: nil,
       name: "points_citi",
       object: "payment_method"
     }
   ],
   zero_interest_installments: false
 }}