devartis / passbook

Python library to create Apple Passbook (.pkpass) files
http://www.devartis.com/
MIT License
272 stars 108 forks source link

How I add currencyCode in primaryFields? #42

Closed imjaypatel closed 4 years ago

imjaypatel commented 7 years ago

How can I added currencyCode in addPrimaryField method. I wanna create following json in addPrimaryField method,

  "storeCard" : {
    "primaryFields" : [
      {
        "key" : "balance",
        "label" : "remaining balance",
        "value" : 21.75,
        "currencyCode" : "USD"
      }
    ],

As I check addPrimaryField method there is only 3 parameter are accept. passfile.passInformation.addPrimaryField('balance', 21.75, 'remaining balance')

I was found CurrencyField Class but I was not understand how to access CurrencyField Class with addAuxiliaryField Class. Thank you.

mbaechtold commented 7 years ago

I have not tested this, but it should be possible to directly append to primaryFields instead of using the helper method addPrimaryField():

balance_field = CurrencyField(
  'balance',
  float(22.00),
  'test label',
  'USD',
)

passfile.passInformation.primaryFields.append(balance_field)
mbaechtold commented 4 years ago

I'm closing this issue due to its age.