-
Notifications
You must be signed in to change notification settings - Fork 48
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Attachment model missing __init__ #24
Comments
FYI -- this is still an issue. Just need to add this to the
|
I think there is a littel typo on the message above. Here is the complete Attachment class : class Attachment(Model):
_valid_properties = {'content': None, 'type': None, 'name': None}
def __init__(self, **kwargs):
for key, default in Attachment._valid_properties.items():
setattr(self, key, kwargs.get(key, default))
@classmethod
def parse(cls, json):
attachment = cls()
for key, val in json.items():
if key in cls._valid_properties:
setattr(attachment, key, val)
return attachment and here is a working example to put attachment using the python api : with open("attachment.png", 'rb') as bin_blob:
b64_attachment_content = base64.b64encode(bin_blob.read())
attachment_mimetype = mimetypes.guess_type(attachment.png)[0]
template = Template(name="test",
html="<h1> hello world </h1>",
subject="click click bang bang",
attachments=[Attachment.parse({"name":"attachment.png", "type":attachment_mimetype, "content":b64_attachment_content.decode()})])
template = api.templates.post(template) |
EuanKerr
added a commit
to EuanKerr/api-client-python
that referenced
this issue
Oct 4, 2022
fixing from gophish#24
EuanKerr
added a commit
to EuanKerr/api-client-python
that referenced
this issue
Oct 4, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was trying to programmatically build templates with attachments and found that I couldn't do it due to an error in the models.py file. I modified it on my own end and it works perfectly now. I will submit a pull request with the update.
The text was updated successfully, but these errors were encountered: