{"id":20287467,"url":"https://github.com/developerzelentsov/smsactivateapi","last_synced_at":"2025-03-04T04:15:17.825Z","repository":{"id":147107839,"uuid":"618574553","full_name":"DeveloperZelentsov/SMSActivateAPI","owner":"DeveloperZelentsov","description":"SmsActivateAPI Swift Library","archived":false,"fork":false,"pushed_at":"2023-04-06T11:00:26.000Z","size":30,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-14T08:27:14.742Z","etag":null,"topics":["ios","phone-number","sms-activate","sms-api","sms-client","sms-messages","smsactivate","swift"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DeveloperZelentsov.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-24T19:14:42.000Z","updated_at":"2024-01-11T07:30:00.000Z","dependencies_parsed_at":"2023-04-21T17:19:56.531Z","dependency_job_id":null,"html_url":"https://github.com/DeveloperZelentsov/SMSActivateAPI","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSMSActivateAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSMSActivateAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSMSActivateAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DeveloperZelentsov%2FSMSActivateAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DeveloperZelentsov","download_url":"https://codeload.github.com/DeveloperZelentsov/SMSActivateAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241780497,"owners_count":20019061,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ios","phone-number","sms-activate","sms-api","sms-client","sms-messages","smsactivate","swift"],"created_at":"2024-11-14T14:40:05.299Z","updated_at":"2025-03-04T04:15:17.804Z","avatar_url":"https://github.com/DeveloperZelentsov.png","language":"Swift","funding_links":["https://www.buymeacoffee.com/zelentsov"],"categories":[],"sub_categories":[],"readme":"# SmsActivateAPI Swift Library #\n\nA Swift package for interacting with the [SMS Activate](https://sms-activate.org/?ref=921566) API. This package provides an easy way to manage phone numbers for SMS-based verification services.\n\n[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/zelentsov)\n\n## Features ##\n\n* Get account balance and cashback information\n* Request a phone number for activation\n* Get activation status\n* Retrieve active activations\n* Set activation status\n* Get available operators for a given country\n* Retrieve the list of all countries\n\n## Requirements ##\n\n* iOS 15.0+\n* Swift 5.6+\n\n## Installation ##\n\nAdd the library to your project using Swift Package Manager:\n\n1. Open your project in Xcode.\n2. Go to File \u003e Swift Packages \u003e Add Package Dependency.\n3. Enter the repository URL `https://github.com/DeveloperZelentsov/SMSActivateAPI` for the SmsActivateAPI library and click Next.\n4. Choose the latest available version and click Next.\n5. Select the target where you want to use SmsActivateAPI and click Finish.\n\n## Usage ##\n\n### Initialization ###\n\nFirst, import the **_SmsActivateAPI_** library in your Swift file:\n\n```swift\nimport SmsHubAPI\n```\n\nTo start using the library, create an instance of **_SmsActivateAPI_** with your API key:\n\n```swift\nlet smsActivateAPI = SmsActivateAPI(apiKey: \"your_api_key_here\")\n```\n\n### Get account balance ###\n\nTo get the account balance, call the `getBalance(with state: BalanceState)` function:\n\n```swift\ndo {\n    let balance = try await smsActivateAPI.getBalance(with: .balance)\n    print(\"Account balance: \\(balance)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Request a phone number ###\n\nTo request a phone number, create a GetNumberRequest object and call the `getNumber(request: GetNumberRequest)` function:\n\n```swift\ndo {\n    let request = GetNumberRequest(service: \"your_service_code\", countryId: \"your_country_id\")\n    let (activationId, phoneNumber) = try await smsActivateAPI.getNumber(request: request)\n    print(\"Activation ID: \\(activationId), Phone Number: \\(phoneNumber)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Wait for code ###\n\nThe `waitForCode(id: Int, attempts: Int = 40, setStatusAfterCompletion: Bool = false)` function is an asynchronous method designed to simplify the process of waiting for an SMS code to be received for a specific activation. This function periodically checks the activation status until a code is received or a specified number of attempts has been reached.\n\n```swift\ndo {\n    let activationId = 12345\n    let code = try await smsActivateAPI.waitForCode(id: activationId)\n    print(\"Received code: \\(code)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Get activation status ###\n\nTo get the activation status, call the `getStatus(id: Int)` function:\n\n```swift\ndo {\n    let activationId = 12345\n    let (status, code) = try await smsActivateAPI.getStatus(id: activationId)\n    print(\"Status: \\(status), Code: \\(String(describing: code))\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Retrieve active activations ###\n\nTo get the list of active activations, call the `getActiveActivations()` function:\n\n```swift\ndo {\n    let activeActivations = try await smsActivateAPI.getActiveActivations()\n    print(\"Active activations: \\(activeActivations)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Set activation status ###\n\nTo set the activation status, create a SetStatusRequest object and call the `setStatus(request: SetStatusRequest)` function:\n\n```swift\ndo {\n    let activationId = 12345\n    let setStatus = SetStatus.ready\n    let request = SetStatusRequest(id: activationId, status: setStatus)\n    let response = try await smsActivateAPI.setStatus(request: request)\n    print(\"Status set response: \\(response)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Get available operators for a given country ###\n\nTo get available operators for a given country, call the `getOperators(countryId: Int?)` function:\n\n```swift\ndo {\n    let countryId = 1\n    let operators = try await smsActivateAPI.getOperators(countryId: countryId)\n    print(\"Available operators: \\(operators)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\n### Retrieve the list of all countries ###\n\nTo get the list of all countries, call the `getCountries()` function:\n\n```swift\ndo {\n    let countries = try await smsActivateAPI.getCountries()\n    print(\"Countries: \\(countries)\")\n} catch {\n    print(\"Error: \\(error)\")\n}\n```\n\nFor more information on the available methods and their parameters, refer to the **_ISmsActivateAPI_** protocol and the library's source code.\n\n## License ##\n\nThis project is released under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperzelentsov%2Fsmsactivateapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdeveloperzelentsov%2Fsmsactivateapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdeveloperzelentsov%2Fsmsactivateapi/lists"}