Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
shopify_iossdk
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cemarose
shopify_iossdk
Commits
212596d3
Commit
212596d3
authored
Apr 28, 2016
by
Dima Bart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add BUYAccountCredentials object.
parent
14a6cc45
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
183 additions
and
0 deletions
+183
-0
BUYAccountCredentials.h
Mobile Buy SDK/Mobile Buy SDK/Models/BUYAccountCredentials.h
+64
-0
BUYAccountCredentials.m
Mobile Buy SDK/Mobile Buy SDK/Models/BUYAccountCredentials.m
+119
-0
No files found.
Mobile Buy SDK/Mobile Buy SDK/Models/BUYAccountCredentials.h
0 → 100644
View file @
212596d3
//
// BUYAccountCredentials.h
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2016 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import <Foundation/Foundation.h>
/**
* Intended for storing a collection of credential items representing individual values
*/
@class
BUYAccountCredentialItem
;
@interface
BUYAccountCredentials
:
NSObject
NS_ASSUME_NONNULL_BEGIN
+
(
BUYAccountCredentials
*
)
credentialsWithItems
:
(
NSArray
<
BUYAccountCredentialItem
*>
*
)
items
;
+
(
BUYAccountCredentials
*
)
credentialsWithItemKeys
:(
NSArray
<
NSString
*>
*
)
keys
;
@property
(
readonly
)
NSDictionary
*
JSONRepresentation
;
@property
(
nonatomic
,
readonly
,
getter
=
isValid
)
BOOL
valid
;
-
(
BUYAccountCredentialItem
*
)
objectForKeyedSubscript
:(
NSString
*
)
key
;
-
(
void
)
setObject
:(
BUYAccountCredentialItem
*
)
obj
forKeyedSubscript
:(
NSString
*
)
key
;
@end
/**
* Represents a key and KVC-validatable value
*/
@interface
BUYAccountCredentialItem
:
NSObject
+
(
instancetype
)
itemWithKey
:(
NSString
*
)
key
value
:(
NSString
*
)
value
;
@property
(
nonatomic
,
getter
=
isValid
)
BOOL
valid
;
@property
(
nonatomic
,
strong
)
NSString
*
key
;
@property
(
nonatomic
,
strong
)
NSString
*
value
;
NS_ASSUME_NONNULL_END
@end
Mobile Buy SDK/Mobile Buy SDK/Models/BUYAccountCredentials.m
0 → 100644
View file @
212596d3
//
// BUYAccountCredentials.m
// Mobile Buy SDK
//
// Created by Shopify.
// Copyright (c) 2016 Shopify Inc. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
#import "BUYAccountCredentials.h"
@class
BUYAccountCredentialItem
;
@interface
BUYAccountCredentials
()
@property
(
strong
,
nonatomic
)
NSMutableDictionary
<
NSString
*
,
BUYAccountCredentialItem
*>
*
items
;
@end
@implementation
BUYAccountCredentials
+
(
BUYAccountCredentials
*
)
credentialsWithItems
:(
NSArray
<
BUYAccountCredentialItem
*>
*
)
items
{
BUYAccountCredentials
*
credentials
=
[
BUYAccountCredentials
new
];
NSMutableDictionary
*
keyedItems
=
[
NSMutableDictionary
dictionary
];
for
(
BUYAccountCredentialItem
*
item
in
items
)
{
keyedItems
[
item
.
key
]
=
item
;
}
credentials
.
items
=
keyedItems
;
return
credentials
;
}
+
(
BUYAccountCredentials
*
)
credentialsWithItemKeys
:(
NSArray
<
NSString
*>
*
)
keys
{
NSMutableArray
*
items
=
[
NSMutableArray
array
];
for
(
NSString
*
key
in
keys
)
{
BUYAccountCredentialItem
*
item
=
[
BUYAccountCredentialItem
itemWithKey
:
key
value
:
@""
];
[
items
addObject
:
item
];
}
return
[
BUYAccountCredentials
credentialsWithItems
:
items
];
}
-
(
NSDictionary
*
)
JSONRepresentation
{
__block
NSMutableDictionary
*
customer
=
[
NSMutableDictionary
dictionary
];
[
self
.
items
enumerateKeysAndObjectsUsingBlock
:
^
(
NSString
*
_Nonnull
key
,
BUYAccountCredentialItem
*
_Nonnull
obj
,
BOOL
*
_Nonnull
stop
)
{
customer
[
key
]
=
obj
.
value
;
}];
return
@{
@"customer"
:
customer
};
}
-
(
BOOL
)
validateValue
:
(
inout
id
_Nullable
__autoreleasing
*
)
ioValue
forKey
:
(
NSString
*
)
inKey
error
:
(
out
NSError
*
_Nullable
__autoreleasing
*
)
outError
{
return
[
self
.
items
[
inKey
]
validateValue
:
ioValue
forKey
:
inKey
error
:
outError
];
}
-
(
BUYAccountCredentialItem
*
)
objectForKeyedSubscript
:
(
NSString
*
)
key
{
return
self
.
items
[
key
];
}
-
(
void
)
setObject
:
(
BUYAccountCredentialItem
*
)
obj
forKeyedSubscript
:
(
NSString
*
)
key
{
self
.
items
[
key
]
=
obj
;
}
-
(
BOOL
)
validationForKey
:
(
NSString
*
)
key
{
return
[
self
.
items
[
key
]
isValid
];
}
-
(
BOOL
)
isValid
{
__block
BOOL
valid
=
YES
;
[
self
.
items
enumerateKeysAndObjectsUsingBlock
:
^
(
NSString
*
_Nonnull
key
,
BUYAccountCredentialItem
*
_Nonnull
obj
,
BOOL
*
_Nonnull
stop
)
{
valid
=
valid
&&
[
obj
isValid
];
}];
return
valid
;
}
@end
@implementation
BUYAccountCredentialItem
+
(
instancetype
)
itemWithKey
:(
NSString
*
)
key
value
:(
NSString
*
)
value
{
BUYAccountCredentialItem
*
item
=
[
BUYAccountCredentialItem
new
];
item
.
key
=
key
;
item
.
value
=
value
;
return
item
;
}
-
(
NSString
*
)
value
{
return
_value
?:
@""
;
}
-
(
BOOL
)
validateValue
:
(
inout
id
_Nullable
__autoreleasing
*
)
ioValue
forKey
:
(
NSString
*
)
inKey
error
:
(
out
NSError
*
_Nullable
__autoreleasing
*
)
outError
{
self
.
value
=
*
ioValue
;
self
.
valid
=
self
.
value
.
length
>
0
;
return
[
self
isValid
];
}
@end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment