Latest 0.0.8
Homepage https://github.com/ferusinfo/EtsySwift
License MIT
Platforms ios 11.0
Dependencies Alamofire, RxAlamofire, RxSwift
Authors

EtsySwift 🖼

EtsySwift is built on top of RxAlamofire for your iOS projects written in Swift 4.2. for easy API connection with Etsy.

Installation

  1. Add pod 'EtsySwift' to your Podfile
  2. Run pod install
  3. Add import EtsySwift wherever you want to use the library

Setup ⚒

To setup the library, you need to pass your consumer key and consumer secret keys.
Never leave your confidential keys in your repository – use any form of obfuscation or cryptography to keep your data safe.

class API {
    let shared = API()
    let etsy: EtsySwift
    init() {
        etsy = EtsySwift(consumerKey: "CONSUMER_KEY", consumerSecret: "CONSUMER_SECRET")
    }
}

Login

After that you need to login, passing your required scope, as defined in Etsy API.

API.shared.etsy.login(["email_r"], callback: "etsyintegration://oauth-callback")

The second argument you pass is the callback URL that will be triggered after user will log in – Etsy uses oAuth authorization – the library will open a Safari window for you. You need to register your custom scheme in your application and pass it there.
Additionally, you need to add following method to your AppDelegate:

func application(_ application: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any]) -> Bool {
    API.shared.etsy.callbackCalled(url: url)
    return true
}

Making Requests

After you authorize with the login method, you can easilly call any method from Etsy API that you have access to. I’ve also added a handy Rx extension for decoding the response from the API.

For now, the API only supports resources that I needed to use for my project (such as shops listing, products listing and getting images for products), but you can use the request(method:url:) method to request any resource you might need.
Let me know if you will need any other resources to be added to the library or submit a pull request.

API.shared.etsy.request(.shops("__SELF__")).decodedAs(EtsyResponse<EtsyShop>.self)

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Add your changes
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create new Pull Request

License

MIT

Latest podspec

{
    "name": "EtsySwift",
    "version": "0.0.8",
    "summary": "Small library allowing reactive authorization with Etsy",
    "homepage": "https://github.com/ferusinfo/EtsySwift",
    "license": "MIT",
    "authors": {
        "Maciej Kou0142ek": "[email protected]"
    },
    "social_media_url": "http://twitter.com/ferusinfo",
    "platforms": {
        "ios": "11.0"
    },
    "source": {
        "git": "https://github.com/ferusinfo/EtsySwift.git",
        "tag": "0.0.8"
    },
    "swift_version": "4.2",
    "source_files": [
        "Classes/Etsy/*/*",
        "Classes/Etsy/*"
    ],
    "dependencies": {
        "Alamofire": [
            "~> 4.7.3"
        ],
        "RxAlamofire": [
            "~> 4.2.0"
        ],
        "RxSwift": [
            "4.4.0"
        ]
    }
}

Pin It on Pinterest

Share This