LineSDKLoginPermission.swift 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // LineSDKLoginPermission.swift
  3. //
  4. // Copyright (c) 2016-present, LY Corporation. All rights reserved.
  5. //
  6. // You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
  7. // copy and distribute this software in source code or binary form for use
  8. // in connection with the web services and APIs provided by LY Corporation.
  9. //
  10. // As with any software that integrates with the LY Corporation platform, your use of this software
  11. // is subject to the LINE Developers Agreement [http://terms2.line.me/LINE_Developers_Agreement].
  12. // This copyright notice shall be included in all copies or substantial portions of the software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
  15. // INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  17. // IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
  18. // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. //
  21. @objcMembers
  22. public class LineSDKLoginPermission: NSObject {
  23. let _value: LoginPermission
  24. convenience init(_ value: LoginPermission) {
  25. self.init(rawValue: value.rawValue)
  26. }
  27. public init(rawValue: String) {
  28. _value = .init(rawValue: rawValue)
  29. }
  30. public static func permissions(from string: String) -> Set<LineSDKLoginPermission> {
  31. let permissions = string.split(separator: " ").map { LineSDKLoginPermission(rawValue: String($0)) }
  32. return Set(permissions)
  33. }
  34. public static let openID = LineSDKLoginPermission(.openID)
  35. public static let profile = LineSDKLoginPermission(.profile)
  36. public static let friends = LineSDKLoginPermission(.friends)
  37. public static let groups = LineSDKLoginPermission(.groups)
  38. public static let oneTimeShare = LineSDKLoginPermission(.oneTimeShare)
  39. public static let messageWrite = LineSDKLoginPermission(.messageWrite)
  40. public static let email = LineSDKLoginPermission(.email)
  41. public static let phone = LineSDKLoginPermission(.phone)
  42. public static let gender = LineSDKLoginPermission(.gender)
  43. public static let birthdate = LineSDKLoginPermission(.birthdate)
  44. public static let address = LineSDKLoginPermission(.address)
  45. public static let realName = LineSDKLoginPermission(.realName)
  46. public static let openChatTermStatus = LineSDKLoginPermission(.openChatTermStatus)
  47. public static let openChatRoomCreateAndJoin = LineSDKLoginPermission(.openChatRoomCreateAndJoin)
  48. public static let openChatInfo = LineSDKLoginPermission(.openChatInfo)
  49. public static let openChatPlugManagement = LineSDKLoginPermission(.openChatPlugManagement)
  50. public static let openChatPlugInfo = LineSDKLoginPermission(.openChatPlugInfo)
  51. public static let openChatPlugProfile = LineSDKLoginPermission(.openChatPlugProfile)
  52. public static let openChatPlugSendMessage = LineSDKLoginPermission(.openChatPlugSendMessage)
  53. public static let openChatPlugReceiveMessageEvent = LineSDKLoginPermission(.openChatPlugReceiveMessageEvent)
  54. var unwrapped: LoginPermission { return _value }
  55. }