This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function bytesToSize(bytes: number): string { | |
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']; | |
if (bytes === 0) return 'n/a'; | |
const i = Math.min(Math.floor(Math.log(bytes) / Math.log(1024)), sizes.length - 1); | |
if (i === 0) return `${bytes} ${sizes[i]}`; | |
return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`; | |
} | |
// Jest spec | |
describe('bytesToSize', () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Marketo has a [SOAP-based API](http://developers.marketo.com/documentation/soap) that allows you to interact with a lot of their data, and while there is a [Python library that supports it](https://github.com/segmentio/marketo-python), the library doesn't cover nearly all the methods supported in the API. | |
[suds](https://fedorahosted.org/suds/) is a Python SOAP library that will read WSDL and provide methods for calling into the service. | |
Here is an example of making a call to the getLead(...): | |
import hmac | |
import hashlib | |
import datetime | |
import time |