[Add] LogRocket 1.47.1
[CocoaPods.git] / Specs / 3 / 4 / 7 / XChanger / 0.0.8 / XChanger.podspec.json
blob264bd7eed924c327bb9521aa48900341868c010f
2   "name": "XChanger",
3   "version": "0.0.8",
4   "summary": "XChanger can exchange to behavior for URL request and response",
5   "description": "XChanger can exchange to behavior for URL request and response\n\n## Usage\nFirst, XChanger should call to start with `XChanger.register()`.\n```swift\nXChanger.register()\n```\n\nSecond, define URL request and response.   \nFor example, It will return body of the response is `{\"id\": 10, name:\"bannzai\"}` and the response status code is 200, when you make a request to `https://exmaple.com/v1/users/10`.\n\nDefine exchange.\n```swift\nlet url = \"https://exmaple.com/v1/users/10\"\nlet json = try! JSONEncoder().encode(User(id: 10, name: \"bannzai\"))\nXChanger.exchange().request(url: url).response(data: json, statusCode: 200).enable()\n```\n\nRequest actually with URLSession.\n```swift\nlet request = URLRequest(url: URL(string: \"https://exmaple.com/v1/users/10\")!)\nlet session = URLSession(configuration: URLSessionConfiguration.default)\nsession.dataTask(with: request) { data, response, error in\n  guard let httpResponse = response as? HTTPURLResponse else {\n      return fatalError(\"Unexpected response type of HTTPURLResponse\")\n  }\n  print(httpResponse.statusCode) // 200\n  \n  let decoded = try! JSONDecoder().decode(User.self, from: data!)\n  print(decoded) // User(id: 10, name: \"bannzai\")\n}.resume()\n```",
6   "homepage": "https://github.com/bannzai/XChanger",
7   "license": "MIT",
8   "authors": {
9     "bannzai": "kingkong999yhirose@gmail.com"
10   },
11   "source": {
12     "git": "https://github.com/bannzai/XChanger.git",
13     "tag": "0.0.8"
14   },
15   "source_files": "Sources/XChanger/*.swift",
16   "platforms": {
17     "ios": "11.0"
18   },
19   "swift_versions": "5.2",
20   "swift_version": "5.2"