Skip to content

Commit

Permalink
Documentation, access level tweaks, refactoring
Browse files Browse the repository at this point in the history
• Changed access level of main classes to 'open' allowing subclassing of certain main WooOS classes such as WooOrder and WooProduct.
• Changed acces levels of remaining classes and appropriate class members to 'public' to allow access outside the module for developers.
• Put WooID in its own file.
• Put WooTagOrderBy in its own file.
• Put WooTagRequestParameter in its own file and added documentation.
• Added documentation to the remaining classes that needed it. WooRequest convertible has still not been fully documented.
• Created WooAuthentication file in anticipation of refactoring auth functions out of WooAPI and into their own class.
  • Loading branch information
Brianna Lee committed Jun 11, 2018
1 parent c446484 commit 5d01799
Show file tree
Hide file tree
Showing 56 changed files with 448 additions and 432 deletions.
Binary file modified .DS_Store
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion Tests/WooOSTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
// Copyright © 2018 Brianna Lee. All rights reserved.
//

import ObjectMapper
import XCTest
@testable import WooOS

Expand All @@ -26,7 +27,7 @@ class WooOSTests: XCTestCase {
let wooOS = WooOS(baseURL: baseURL)
wooOS.api = WooAPI(url: baseURL)
wooOS.cart = WooCart()
wooOS.currentCustomer = WooCustomer(map: Map())
wooOS.currentCustomer = WooCustomer()
WooOS.main = wooOS
}

Expand Down
130 changes: 89 additions & 41 deletions WooOS.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions WooOS/WooAPI/WooAPI+Authentication.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public extension WooAPI {
/// - username: The chosen username by the customer.
/// - password: The given password by the customer.
/// - complete: Asynchronous callback containing a success flag and an error string if failed. If unsuccessful: success = false, error = String.
func signUp(with firstName: String,
public func signUp(with firstName: String,
lastName: String,
username: String,
email: String,
Expand Down Expand Up @@ -143,7 +143,7 @@ public extension WooAPI {
/// - username: String of Username provided by User.
/// - password: String of Password provided by User.
/// - complete: Asynchronous callback containing a success flag and an error string if failed. If unsuccessful: success = false, error = String.
func login(with username: String,
public func login(with username: String,
and password: String,
then complete: @escaping WooCompletion.Token) {

Expand Down Expand Up @@ -210,7 +210,7 @@ public extension WooAPI {
}

/// Log user out by revoking the token on the server, deleting the token locally, and deleting the stored user in `WooOS.main`.
func logout(then complete: WooCompletion.Completion? = nil) {
public func logout(then complete: WooCompletion.Completion? = nil) {

// Remove stored token
UserDefaults.standard.set(nil, forKey: "token")
Expand Down
8 changes: 4 additions & 4 deletions WooOS/WooAPI/WooAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,19 @@ public class WooAPI {
// -----------------------------------------------------------

/// The consumer key found in the WooCommerce API settings.
var consumerKey: String?
public var consumerKey: String?

/// The consumer secret found in the WooCommerce API settings.
var consumerSecret: String?
public var consumerSecret: String?

/// The baseURL for all the requests. A WooCommerce instance should be installed on the server this URL is pointing to.
var siteURL: URL
public var siteURL: URL

/// The stored token used to validate the user's authentication session, stored in the UserDefaults dictionary, accessed with the getter and setter on this variable.


/// The shared SessionManager instance for Alamofire.
let alamofireManager: SessionManager = {
public let alamofireManager: SessionManager = {

// Build the session manager with the configured session.
let manager = Alamofire.SessionManager(configuration: .default)
Expand Down
3 changes: 2 additions & 1 deletion WooOS/WooAttribute/WooAttribute.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import Foundation
import ObjectMapper

public class WooAttribute: Mappable {
/// An attribute object associated to a product.
open class WooAttribute: Mappable {

/// Unique identifier for the resource.
var id: WooID?
Expand Down
3 changes: 3 additions & 0 deletions WooOS/WooAttribute/WooAttributeRequestParameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

import Foundation

/// The request parameter used while requesting WooAttribute objects from WooCommerce.
///
/// - context: Scope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
public enum WooAttributeRequestParameter: WooRequestParameter {

case context(WooRequestContext)
Expand Down
2 changes: 1 addition & 1 deletion WooOS/WooAttributeTerm/WooAttributeTerm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Foundation
import ObjectMapper

/// The individual term of a product attribute. An attribute would be "Color", and the term would be "Blue".
public class WooAttributeTerm: Mappable {
open class WooAttributeTerm: Mappable {

/// Unique identifier for the resource.
var id: WooID?
Expand Down
9 changes: 9 additions & 0 deletions WooOS/WooAuthentication.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//
// WooAuthentication.swift
// WooOS-iOS
//
// Created by Brie on 6/10/18.
// Copyright © 2018 Brianna Lee. All rights reserved.
//

import Foundation
2 changes: 1 addition & 1 deletion WooOS/WooCart/WooBilling.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import ObjectMapper

/// <#Description#>
/// The billing information associated with an order.
public class WooBilling: Mappable {

/// First name.
Expand Down
5 changes: 0 additions & 5 deletions WooOS/WooCart/WooCart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
import Foundation
import Alamofire

public enum WooCartState: String {
case shopping = "shopping"
case checkout = "checkoutInProgress"
}

/// Singleton class designed to manage the client-side cart features of WooOS.
public class WooCart {

Expand Down
18 changes: 18 additions & 0 deletions WooOS/WooCart/WooCartState.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// WooCartState.swift
// WooOS-iOS
//
// Created by Brie on 6/10/18.
// Copyright © 2018 Brianna Lee. All rights reserved.
//

import Foundation

/// The current state of the cart.
///
/// - shopping: Customer is still currently shopping.
/// - checkout: Customer has
public enum WooCartState: String {
case shopping = "shopping"
case checkout = "checkoutInProgress"
}
164 changes: 1 addition & 163 deletions WooOS/WooCart/WooCurrency.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,169 +8,7 @@

import Foundation

/// <#Description#>
///
/// - aed: <#aed description#>
/// - afn: <#afn description#>
/// - all: <#all description#>
/// - amd: <#amd description#>
/// - ang: <#ang description#>
/// - aoa: <#aoa description#>
/// - ars: <#ars description#>
/// - aud: <#aud description#>
/// - awg: <#awg description#>
/// - azn: <#azn description#>
/// - bam: <#bam description#>
/// - bbd: <#bbd description#>
/// - bdt: <#bdt description#>
/// - bgn: <#bgn description#>
/// - bhd: <#bhd description#>
/// - bif: <#bif description#>
/// - bmd: <#bmd description#>
/// - bnd: <#bnd description#>
/// - bob: <#bob description#>
/// - brl: <#brl description#>
/// - bsd: <#bsd description#>
/// - btc: <#btc description#>
/// - btn: <#btn description#>
/// - bwp: <#bwp description#>
/// - byr: <#byr description#>
/// - bzd: <#bzd description#>
/// - cad: <#cad description#>
/// - cdf: <#cdf description#>
/// - chf: <#chf description#>
/// - clp: <#clp description#>
/// - cny: <#cny description#>
/// - cop: <#cop description#>
/// - crc: <#crc description#>
/// - cuc: <#cuc description#>
/// - cup: <#cup description#>
/// - cve: <#cve description#>
/// - czk: <#czk description#>
/// - djf: <#djf description#>
/// - dkk: <#dkk description#>
/// - dop: <#dop description#>
/// - dzd: <#dzd description#>
/// - egp: <#egp description#>
/// - ern: <#ern description#>
/// - etb: <#etb description#>
/// - eur: <#eur description#>
/// - fjd: <#fjd description#>
/// - fkp: <#fkp description#>
/// - gbp: <#gbp description#>
/// - gel: <#gel description#>
/// - ggp: <#ggp description#>
/// - ghs: <#ghs description#>
/// - gip: <#gip description#>
/// - gmd: <#gmd description#>
/// - gnf: <#gnf description#>
/// - gtq: <#gtq description#>
/// - gyd: <#gyd description#>
/// - hkd: <#hkd description#>
/// - hnl: <#hnl description#>
/// - hrk: <#hrk description#>
/// - htg: <#htg description#>
/// - huf: <#huf description#>
/// - idr: <#idr description#>
/// - ils: <#ils description#>
/// - imp: <#imp description#>
/// - inr: <#inr description#>
/// - iqd: <#iqd description#>
/// - irr: <#irr description#>
/// - irt: <#irt description#>
/// - isk: <#isk description#>
/// - jep: <#jep description#>
/// - jmd: <#jmd description#>
/// - jod: <#jod description#>
/// - jpy: <#jpy description#>
/// - kes: <#kes description#>
/// - kgs: <#kgs description#>
/// - khr: <#khr description#>
/// - kmf: <#kmf description#>
/// - kpw: <#kpw description#>
/// - KRW: <#KRW description#>
/// - kwd: <#kwd description#>
/// - kyd: <#kyd description#>
/// - kzt: <#kzt description#>
/// - lak: <#lak description#>
/// - lbp: <#lbp description#>
/// - lkr: <#lkr description#>
/// - lrd: <#lrd description#>
/// - lsl: <#lsl description#>
/// - lyd: <#lyd description#>
/// - mad: <#mad description#>
/// - mdl: <#mdl description#>
/// - mga: <#mga description#>
/// - mkd: <#mkd description#>
/// - mmk: <#mmk description#>
/// - mnt: <#mnt description#>
/// - mop: <#mop description#>
/// - mro: <#mro description#>
/// - mur: <#mur description#>
/// - mvr: <#mvr description#>
/// - mwk: <#mwk description#>
/// - mxn: <#mxn description#>
/// - myr: <#myr description#>
/// - mzn: <#mzn description#>
/// - nad: <#nad description#>
/// - ngn: <#ngn description#>
/// - nio: <#nio description#>
/// - nok: <#nok description#>
/// - npr: <#npr description#>
/// - nzd: <#nzd description#>
/// - omr: <#omr description#>
/// - pab: <#pab description#>
/// - pen: <#pen description#>
/// - pgk: <#pgk description#>
/// - php: <#php description#>
/// - pkr: <#pkr description#>
/// - pln: <#pln description#>
/// - prb: <#prb description#>
/// - pyg: <#pyg description#>
/// - qar: <#qar description#>
/// - ron: <#ron description#>
/// - rsd: <#rsd description#>
/// - rub: <#rub description#>
/// - rwf: <#rwf description#>
/// - sar: <#sar description#>
/// - sbd: <#sbd description#>
/// - scr: <#scr description#>
/// - sdg: <#sdg description#>
/// - sek: <#sek description#>
/// - sgd: <#sgd description#>
/// - shp: <#shp description#>
/// - sll: <#sll description#>
/// - sos: <#sos description#>
/// - srd: <#srd description#>
/// - ssp: <#ssp description#>
/// - std: <#std description#>
/// - syp: <#syp description#>
/// - szl: <#szl description#>
/// - thb: <#thb description#>
/// - tjs: <#tjs description#>
/// - tmt: <#tmt description#>
/// - tnd: <#tnd description#>
/// - top: <#top description#>
/// - try_: <#try_ description#>
/// - ttd: <#ttd description#>
/// - twd: <#twd description#>
/// - tzd: <#tzd description#>
/// - uah: <#uah description#>
/// - ugx: <#ugx description#>
/// - usd: <#usd description#>
/// - uyu: <#uyu description#>
/// - uzs: <#uzs description#>
/// - vef: <#vef description#>
/// - vnd: <#vnd description#>
/// - vuv: <#vuv description#>
/// - wst: <#wst description#>
/// - xaf: <#xaf description#>
/// - xcd: <#xcd description#>
/// - xof: <#xof description#>
/// - xpf: <#xpf description#>
/// - yer: <#yer description#>
/// - zar: <#zar description#>
/// - zmw: <#zmw description#>
/// An object representing the current currency of the cart and subsequent orders.
public enum WooCurrency: String {
case aed = "AED"
case afn = "AFN"
Expand Down
2 changes: 1 addition & 1 deletion WooOS/WooCart/WooShipping.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import Foundation
import ObjectMapper

/// <#Description#>
/// The shipping object for an order.
public class WooShipping: Mappable {

/// First name.
Expand Down
2 changes: 1 addition & 1 deletion WooOS/WooCategory/WooCategory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Foundation
import ObjectMapper

/// A collection of products arranged into a category.
public class WooCategory: Mappable {
open class WooCategory: Mappable {

/// Unique identifier for the resource.
var id: WooID?
Expand Down
4 changes: 2 additions & 2 deletions WooOS/WooCoupon/WooCoupon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
import Foundation
import ObjectMapper

/// <#Description#>
public class WooCoupon: Mappable {
/// An object representing a stored coupon in WooCommerce.
open class WooCoupon: Mappable {

/// Unique identifier for the object.
var id: WooID?
Expand Down
8 changes: 4 additions & 4 deletions WooOS/WooCoupon/WooCouponDiscountType.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

import Foundation

/// <#Description#>
/// The type of discount being applied with the coupon.
///
/// - percent: <#percent description#>
/// - fixedCart: <#fixedCart description#>
/// - fixedProduct: <#fixedProduct description#>
/// - percent: This coupon should use a percentage discount on the cart total.
/// - fixedCart: This coupon should apply a fixed discount to the cart total.
/// - fixedProduct: This coupon should apply a fixed discount to a product in the cart.
public enum WooCouponDiscountType: String {
case percent = "percent"
case fixedCart = "fixed_cart"
Expand Down
4 changes: 2 additions & 2 deletions WooOS/WooCustomer/WooCustomer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import Foundation
import ObjectMapper
import Locksmith

/// <#Description#>
public class WooCustomer: Mappable {
/// Object representing a customer stored on WooCommerce.
open class WooCustomer: Mappable {

/// Unique identifier for the resource.
var id: WooID?
Expand Down
8 changes: 4 additions & 4 deletions WooOS/WooDeepLink/WooDeepLink.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ import Foundation
// MARK: - WooDeepLink
// ------------------------------------------------------------------------

/// <#Description#>
/// The object used to represent a DeepLink action to a page in WooOS
public class WooDeepLink {

/// <#Description#>
var recognizer = DeepLinkRecognizer(deepLinkTypes: [ProductDeepLink.self])
/// The recognizer used to recognize product deep link.
var productRecognizer = DeepLinkRecognizer(deepLinkTypes: [ProductDeepLink.self])

/// <#Description#>
/// The deep link object used to link to a product.
struct ProductDeepLink: DeepLink {

let productName: String
Expand Down
File renamed without changes.
Loading

0 comments on commit 5d01799

Please sign in to comment.