Skip to content

Commit

Permalink
Implement FileUpload model
Browse files Browse the repository at this point in the history
  • Loading branch information
jleclanche committed May 27, 2018
1 parent 5d3a878 commit e8697ae
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 1 deletion.
16 changes: 16 additions & 0 deletions djstripe/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,22 @@ class DisputeStatus(Enum):
lost = _("Lost")


class FileUploadPurpose(Enum):
dispute_evidence = _("Dispute evidence")
identity_document = _("Identity document")
tax_document_user_upload = _("Tax document user upload")


class FileUploadType(Enum):
pdf = _("PDF")
jpg = _("JPG")
png = _("PNG")
csv = _("CSV")
xls = _("XLS")
xlsx = _("XLSX")
docx = _("DOCX")


class PayoutFailureCode(Enum):
"""
Payout failure error codes.
Expand Down
35 changes: 35 additions & 0 deletions djstripe/migrations/0021_auto_20180115_1946.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Generated by Django 2.0.1 on 2018-01-15 18:46

from django.db import migrations, models
import djstripe.fields


class Migration(migrations.Migration):

dependencies = [
('djstripe', '0020_auto_20180110_0842'),
]

operations = [
migrations.CreateModel(
name='FileUpload',
fields=[
('djstripe_id', models.BigAutoField(primary_key=True, serialize=False, verbose_name='ID')),
('stripe_id', djstripe.fields.StripeIdField(max_length=255, unique=True)),
('livemode', djstripe.fields.StripeNullBooleanField(default=None, help_text='Null here indicates that the livemode status is unknown or was previously unrecorded. Otherwise, this field indicates whether this record comes from Stripe test mode or live mode operation.')),
('created', djstripe.fields.StripeDateTimeField(help_text='The datetime this object was created in stripe.', null=True)),
('metadata', djstripe.fields.StripeJSONField(blank=True, help_text='A set of key/value pairs that you can attach to an object. It can be useful for storing additional information about an object in a structured format.', null=True)),
('description', djstripe.fields.StripeTextField(blank=True, help_text='A description of this object.', null=True)),
('djstripe_created', models.DateTimeField(auto_now_add=True)),
('djstripe_updated', models.DateTimeField(auto_now=True)),
('filename', djstripe.fields.StripeCharField(help_text='A filename for the file, suitable for saving to a filesystem.', max_length=255)),
('purpose', djstripe.fields.StripeCharField(choices=[('dispute_evidence', 'Dispute evidence'), ('identity_document', 'Identity document'), ('tax_document_user_upload', 'Tax document user upload')], help_text='The purpose of the uploaded file.', max_length=24)),
('size', djstripe.fields.StripeIntegerField(help_text='The size in bytes of the file upload object.')),
('type', djstripe.fields.StripeCharField(choices=[('csv', 'CSV'), ('docx', 'DOCX'), ('jpg', 'JPG'), ('pdf', 'PDF'), ('png', 'PNG'), ('xls', 'XLS'), ('xlsx', 'XLSX')], help_text='The type of the file returned.', max_length=4)),
('url', djstripe.fields.StripeCharField(help_text='A read-only URL where the uploaded file can be accessed.', max_length=200)),
],
options={
'abstract': False,
},
),
]
18 changes: 17 additions & 1 deletion djstripe/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1526,7 +1526,23 @@ def customer(self):
return Customer._get_or_create_from_stripe_object(data, field)[0]


# TODO: class FileUpload(...)
class FileUpload(StripeObject):
filename = StripeCharField(
max_length=255, help_text="A filename for the file, suitable for saving to a filesystem."
)
purpose = StripeCharField(
max_length=24, choices=enums.FileUploadPurpose.choices,
help_text="The purpose of the uploaded file."
)
size = StripeIntegerField(help_text="The size in bytes of the file upload object.")
type = StripeCharField(
max_length=4, choices=enums.FileUploadType.choices,
help_text="The type of the file returned."
)
url = StripeCharField(
max_length=200,
help_text="A read-only URL where the uploaded file can be accessed."
)


class Payout(StripeObject):
Expand Down

0 comments on commit e8697ae

Please sign in to comment.