Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup and Carthage fixes #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 167 additions & 43 deletions BinanceApi.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6C380925200E3FCA00670C25"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi iOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
language = ""
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6C380925200E3FCA00670C25"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi iOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "6C380925200E3FCA00670C25"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi iOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0900"
LastUpgradeVersion = "0920"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand All @@ -16,7 +16,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "E928A46A1F9A03AD0078BA33"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi"
BlueprintName = "BinanceApi macOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</BuildActionEntry>
Expand Down Expand Up @@ -45,7 +45,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "E928A46A1F9A03AD0078BA33"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi"
BlueprintName = "BinanceApi macOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -68,7 +68,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "E928A46A1F9A03AD0078BA33"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi"
BlueprintName = "BinanceApi macOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand All @@ -86,7 +86,7 @@
BuildableIdentifier = "primary"
BlueprintIdentifier = "E928A46A1F9A03AD0078BA33"
BuildableName = "BinanceApi.framework"
BlueprintName = "BinanceApi"
BlueprintName = "BinanceApi macOS"
ReferencedContainer = "container:BinanceApi.xcodeproj">
</BuildableReference>
</MacroExpansion>
Expand Down
6 changes: 3 additions & 3 deletions BinanceApi/Base.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public enum BinanceCandlesticksInterval: String, Codable {
}

public struct BinanceApi {
static let baseUrl = URL(string: "https://www.binance.com/api/")!
static let baseUrl = URL(string: "https://api.binance.com/api/")!

let session: SessionManager

Expand Down Expand Up @@ -190,8 +190,8 @@ public protocol BinanceRequest: Encodable, URLConvertible, URLRequestConvertible

public extension BinanceRequest {
public func asURL() throws -> URL {
let baseUrl = URL(string: "https://www.binance.com/api/")!
return URL(string: Self.endpoint, relativeTo: baseUrl)!
let baseUrl = URL(string: "https://api.binance.com/api/")!
return URL(string: Self.endpoint, relativeTo: baseUrl)!.absoluteURL
}

public func asURLRequest() throws -> URLRequest {
Expand Down
2 changes: 1 addition & 1 deletion BinanceApi/BinanceApi.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Sumant Manne. All rights reserved.
//

#import <Cocoa/Cocoa.h>
@import Foundation;

//! Project version number for BinanceApi.
FOUNDATION_EXPORT double BinanceApiVersionNumber;
Expand Down
22 changes: 18 additions & 4 deletions BinanceApi/BinanceApi.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ import Alamofire
public struct BinancePingRequest: BinanceRequest, Codable {
public static let endpoint = "v1/ping"
public static let method: HTTPMethod = .get


public init () {}

public struct Response: Codable {}
}

Expand All @@ -22,6 +24,8 @@ public struct BinanceTimeRequest: BinanceRequest {
public static let endpoint = "v1/time"
public static let method: HTTPMethod = .get

public init () {}

public struct Response: Decodable {
public let localTime = Date()
public let serverTime: Date
Expand Down Expand Up @@ -176,6 +180,10 @@ public struct Binance24HourTickerRequest: BinanceRequest, Codable {
public static let endpoint = "v1/ticker/24hr"
public static let method: HTTPMethod = .get

public init(symbol: String) {
self.symbol = symbol
}

public let symbol: String

public struct Response: Codable {
Expand All @@ -189,6 +197,8 @@ public struct Binance24HourTickerRequest: BinanceRequest, Codable {
public let openPrice: Decimal
public let highPrice: Decimal
public let lowPrice: Decimal
public let volume: Decimal
public let quoteVolume: Decimal
public let openTime: Date
public let closeTime: Date
public let firstId: UInt64
Expand All @@ -199,11 +209,13 @@ public struct Binance24HourTickerRequest: BinanceRequest, Codable {

/// Latest `price` for all `symbol`s.
public struct BinanceAllPricesRequest: BinanceRequest, Codable {
public static let endpoint = "v1/ticker/allPrices"
public static let endpoint = "v3/ticker/price"
public static let method: HTTPMethod = .get

public init () {}

public struct Response: Decodable {
let elements: [String: Decimal]
public let elements: [String: Decimal]

public init(from decoder: Decoder) throws {
var dict = [String: Decimal]()
Expand All @@ -230,6 +242,8 @@ public struct BinanceAllBookTickersRequest: BinanceRequest, Codable {
public static let endpoint = "v1/ticker/allBookTickers"
public static let method: HTTPMethod = .get

public init () {}

public struct Element: Codable {
public let bidPrice: Decimal
public let bidQuantity: Decimal
Expand Down Expand Up @@ -276,7 +290,7 @@ public struct BinanceAllBookTickersRequest: BinanceRequest, Codable {
public struct BinanceNewOrderRequest: BinanceSignedRequest, Codable {
public static let endpoint = "v3/order"
public static let method = HTTPMethod.post

public let symbol: String
public let side: BinanceOrderSide
public let type: BinanceOrderType
Expand Down
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Alamofire/Alamofire" ~> 4.5
github "Alamofire/Alamofire"
github "soffes/CommonCrypto"
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "Alamofire/Alamofire" "4.5.1"
github "Alamofire/Alamofire" "4.6.0"
github "soffes/CommonCrypto" "v1.1.0"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let api = BinanceApi()
let request = BinanceAllPricesRequest()

api.send(request) { response in
assert(request.result.isSuccess)
assert(response.result.isSuccess)

let elements = response.result.value!.elements
for (symbol, price) in elements {
Expand Down